Python+OpenCV: cv2.imwrite

后端 未结 3 1200
离开以前
离开以前 2021-01-30 09:23

I\'m trying to detect a face and write down area with the face in a separate file. How can I do it? I think that i must use \"faces\" (you can see this var in code). But how?

3条回答
  •  悲&欢浪女
    2021-01-30 09:55

    wtluo, great ! May I propose a slight modification of your code 2. ? Here it is:

    for i, detected_box in enumerate(detect_boxes):
        box = detected_box["box"]
        face_img = img[ box[1]:box[1] + box[3], box[0]:box[0] + box[2] ]
        cv2.imwrite("face-{:03d}.jpg".format(i+1), face_img)
    

提交回复
热议问题