【发布时间】:2020-01-03 00:10:49
【问题描述】:
我正在应用一些关于绘制轮廓的代码,但出现以下错误: t = cv2.drawContours(img, 轮廓, -1, (0,255,0), 3)
错误:OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\imgproc\src\drawing.cpp:2509: 错误: (-215:Assertion failed) npoints > 0 in function 'cv ::drawContours'
谁能告诉我问题出在哪里??
【问题讨论】:
-
轮廓是空的吗?
-
我正在尝试修复代码并将其包含在消息中但系统非常困难我不知道该怎么做这个系统很难使用
-
import cv2 import numpy as np import matplotlib.pyplot as plt img = cv2.imread('00048421.bmp', 0) img = cv2.medianBlur(img, 5) thresh = cv2.adaptiveThreshold( img,8,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,\ cv2.THRESH_BINARY,11,2) t = cv2.drawContours(img, contours, -1, (0,255,0), 3) plt.figure(figsize=(12, 12)) plt.imshow(thresh) plt.show()
标签: python-3.x