opencv
田遥远
这个作者很懒,什么都没留下…
展开
-
findContours,ValueError: too many values to unpack (expected 2)报错
源代码发生报错:contours, hierarchy = cv2.findContours(imgThreshold, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) # FIND ALL CONTOURSValueError: too many values to unpack (expected 2)contours, hierarchy = cv2.findContours(imgThreshold, cv2.RETR_EXTERNAL, cv2.CHA原创 2020-08-10 09:24:37 · 378 阅读 · 0 评论 -
python保存图片到目录,如果不存在该目录,则创建该目录
import cv2import osimg = cv2.imread('img.jpg', 1) # 读取img图片dirs = 'result/10' # 想要保存的路径if not os.path.exists(dirs): # 如果不存在路径,则创建这个路径,关键函数就在这两行,其他可以改变 os.makedirs(dirs)path = dirs+'/'+'img.jpg' # 将文件路径与文件名进行结合,得到完整的文件路径以及名称cv2.imwrite(pa原创 2020-08-06 15:36:26 · 5197 阅读 · 0 评论 -
opencv函数错误TypeError: Incorrect type of self (must be ‘Feature2D‘ or its derivative)
1、TypeError: Incorrect type of self (must be ‘Feature2D’ or its derivative)错误在编辑opencv中fast函数:fast = cv2.FastFeatureDetector()时候,会出现上面那个错误。要将函数修改为:fast = cv2.FastFeatureDetector_create()其他基本也是后面加一个create2、 后面还出现一个错误:img2 = cv2.drawKeypoints(img, kp原创 2020-07-31 09:09:30 · 725 阅读 · 0 评论