here에서 예제를 실행 해 봅니다. 내가 "계층"을 삭제하면opencv 3 beta/python에서 findContours 및 drawContours 오류가 발생했습니다.
import numpy as np
import cv2
img = cv2.imread('final.jpg')
imgray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(imgray,127,255,0)
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(img, contours, -1, (0,255,0), 3)
오류가
Traceback (most recent call last):
File "E:\PC\opencv3Try\findCExample.py", line 7, in <module>
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
ValueError: too many values to unpack (expected 2)
인 오류가 drawContours에서 발생 :
TypeError: contours is not a numpy array, neither a scalar
내가 윤곽을 사용하는 경우 [0] drawContours
에서cv2.error: E:\opencv\opencv\sources\modules\imgproc\src\drawing.cpp:2171: error: (-215) npoints > 0 in function cv::drawContours
여기에 어떤 문제가있을 수 있습니까?
OpenCV 3.0 설명서는 현재 찾기가 어렵습니다 (위의 링크는 현재 실패 함). 3.0에서 findContours()가 여전히 이미지를 수정하는지 여부를 확인했습니다. 그것은 수행하고, 통과 된 이미지와 리턴 된 이미지는'is'에 따라 동일합니다. –
[여기] (http://docs.opencv.org/3.0-last-rst/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours#findcontours) OpenCV 3.0.0-dev 문서에 대한 작업 링크 findContours의 Python 버전에 대한 세 개의 반환 값을 보여줍니다. –