OpenCV resize fails on large image with “error: (-215) ssize.area() > 0 in function cv::resize”

后端 未结 13 2104
醉酒成梦
醉酒成梦 2021-01-01 10:08

I\'m using OpenCV 3.0.0 and Python 3.4.3 to process a very large RGB image (107162,79553,3). While I\'m trying to resize it using the following code:

import         


        
13条回答
  •  -上瘾入骨i
    2021-01-01 10:39

    You can manually place a check in your code. Like this -

    
        if result != []:
            for face in result:
                bounding_box = face['box']
                x, y, w, h = bounding_box[0], bounding_box[1], bounding_box[2], bounding_box[3]
                rect_face = cv2.rectangle(frame, (x, y), (x+w, y+h), (46, 204, 113), 2)
                face = rgb[y:y+h, x:x+w]
    
                #CHECK FACE SIZE (EXIST OR NOT)
                if face.shape[0]*face.shape[1] > 0:
    
                    predicted_name, class_probability = face_recognition(face)
    
                    print("Result: ", predicted_name, class_probability)
    `
    

提交回复
热议问题