반응형
250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- Spring Error
- Python
- Kafka
- codepipeline
- Jenkins
- kubeflow
- codebuild
- AWS CI/CD 구축하기
- or some instances in your deployment group are experiencing problems.
- java bigdecimal
- codedeploy error
- docker
- codedeploy
- PostgreSQL
- aws cicd
- COALESCE
- chartjs
- VPN
- node
- Airflow
- aws
- IntelliJ
- Flux
- 도커
- JavaScript
- chart.js
- redis
- SQL
- Spring
- bootstrap
Archives
- Today
- Total
Small Asteroid Blog
python face_recognition 로 얼굴영역만 자르기 본문
728x90
face_recognition 를 이용해서 얼굴영역만 크롭하기
import face_recognition
from matplotlib import pyplot as plt
import cv2
from PIL import Image
# open할 이미지 경로
imgfile='D:/my/video frame/test_rec1/LESSON_319.jpg'
savepath = 'D:/my/video frame/test_rec1/'
file = 'LESSON_319.jpg'
image = face_recognition.load_image_file(imgfile)
face_locations = face_recognition.face_locations(image)
#눈코입 찾아서 얼굴있으면 개수 알려줌
print("I found {} face(s) in this photograph.".format(len(face_locations)))
for face_location in face_locations:
# Print the location of each face in this image
top, right, bottom, left = face_location
print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right))
# You can access the actual face itself like this:
face_image = image[top:bottom, left:right]
pil_image = Image.fromarray(face_image)
p_image = pil_image.resize((48,48))
#pil_image.show()
plt.imshow(p_image)
p_image.save(savepath+'f_'+file)
face_recognition 의 github 주소는 아래 링크에서 확인 가능함
github.com/ageitgey/face_recognition/blob/master/README_Korean.md
728x90
반응형