【发布时间】:2021-02-12 05:24:31
【问题描述】:
我在 python 中使用 opencv 和 face_recognition 库捕获图像, 这是我的程序的sn-p
while True:
ret,frame = video_capture.read()
rgb_frame = frame[:,:,::-1]
face_locations = fr.face_locations(rgb_frame)
face_encodings = fr.face_encodings(rgb_frame,face_locations)
cv2.imwrite('test.png', frame)
if len(face_encodings)!=0:
print(face_locations)
temp = list(face_locations[0])
img = cv2.imread('test.png')
cropped = img[temp[0]:temp[2],temp[0]:temp[1]]
cv2.imshow("cropped", cropped)
cv2.imwrite('face.png',cropped)
我正在尝试将裁剪后的图像保存到我的目录中。但是上面的代码不起作用。你知道如何使用 opencv 保存裁剪后的图像吗?
【问题讨论】:
-
什么意思不起作用,根本不保存或出现错误或保存到其他地方而不是您想要的地方?
-
temp[3] 怎么样?
-
对不起,已经成功了,谢谢
标签: python image opencv crop face-recognition