删除图像的特定部分以外的所有部分
Remove all but specific part of image
我正在使用 Python 人脸识别库来检测图像中的人脸,它会返回图像中人脸的坐标。我想删除除人脸识别函数返回的坐标外的所有坐标
import face_recognition
image1 = face_recognition.load_image_file("image extract/image.jpg")
face_locations = face_recognition.face_locations(image1)
print(face_locations)
感谢@Mark Setchell 和@Bohdan 的帮助
count2=0
for file in image_folder:
loc=f"image extract/frame{count2}.jpg"
image1 = face_recognition.load_image_file("image extract/"+file)
face_locations = face_recognition.face_locations(image1)
width, height =0,0
for face_location in face_locations:
top, right, bottom, left = face_location
face_image = image1[top+20:bottom+20, left+20:right+20]
pil_image = Image2.fromarray(face_image)
if (pil_image.size[0]*pil_image.size[1]>width*height):
width, height = pil_image.size
pil_image.save(loc)
我正在使用 Python 人脸识别库来检测图像中的人脸,它会返回图像中人脸的坐标。我想删除除人脸识别函数返回的坐标外的所有坐标
import face_recognition
image1 = face_recognition.load_image_file("image extract/image.jpg")
face_locations = face_recognition.face_locations(image1)
print(face_locations)
感谢@Mark Setchell 和@Bohdan 的帮助
count2=0
for file in image_folder:
loc=f"image extract/frame{count2}.jpg"
image1 = face_recognition.load_image_file("image extract/"+file)
face_locations = face_recognition.face_locations(image1)
width, height =0,0
for face_location in face_locations:
top, right, bottom, left = face_location
face_image = image1[top+20:bottom+20, left+20:right+20]
pil_image = Image2.fromarray(face_image)
if (pil_image.size[0]*pil_image.size[1]>width*height):
width, height = pil_image.size
pil_image.save(loc)