OpenCV Assertion failed: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S)

前端 未结 6 1008
天命终不由人
天命终不由人 2020-12-10 15:34

I have found the following code on this website:

import os
import os.path
import cv2
import glob
import imutils
CAPTCHA_IMAGE_FOLDER = \"generated_captcha_im         


        
6条回答
  •  情深已故
    2020-12-10 15:55

    I wrote the same code in following way:

    _, contours, hierarchy = cv2.findContours(img,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
    

    and my code worked. I think previously it was returning 2 variables now we have to unpack into three variables. If this doesn't work try the following:

    _, contours, _ = cv2.findContours(img,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
    

    this should work.

    For more information, you can visit the OpenCV documentation page: https://docs.opencv.org/3.1.0/d4/d73/tutorial_py_contours_begin.html

    I hope this will help you.

提交回复
热议问题