我正在使用 python 中的 opencv 和face_recognition 库捕获图像,
这是我的程序的片段
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 保存裁剪后的图像吗?
尝试这个cv2.imwrite('path/to/face.png',cropped)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)