Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python OpenCV轮廓区域异常_Python_Opencv - Fatal编程技术网

Python OpenCV轮廓区域异常

Python OpenCV轮廓区域异常,python,opencv,Python,Opencv,我对opencv非常陌生,我有一个问题: #Find contours of the filtered frame contours, hierarchy, _= cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) #Draw Contours #cv2.drawContours(frame, cnt, -1, (122,122,0), 3) #cv2.imshow('Dilation',median) #Fin

我对opencv非常陌生,我有一个问题:

#Find contours of the filtered frame
contours, hierarchy, _= cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)   

#Draw Contours
#cv2.drawContours(frame, cnt, -1, (122,122,0), 3)
#cv2.imshow('Dilation',median)

#Find Max contour area (Assume that hand is in the frame)
max_area=100
ci=0    
for i in range(len(contours)):
    cnt=contours[i]
    area = cv2.contourArea(cnt)
    if(area>max_area):
        max_area=area
        ci=i
我在互联网上找到了这个,一些手工追踪的东西,但我得到了一个例外:

File "C:\Users\123\Desktop\cv\track.py", line 87, 
in<module>
area = cv2.contourArea(cnt)
error: C:\projects\opencv-
python\opencv\modules\imgproc\src\shapedescr.cpp:320: error: (-215) npoints 
>= 0 && (depth == CV_32F || depth == CV_32S) in function cv::contourArea
你能告诉我为什么会发生这种情况,解决办法是什么吗? 我使用的是Python2.7.13和OpenCV版本3.3.0。 此处的完整代码:

cv2.findContours返回img、轮廓、层次结构,请参阅文档

在通话中切换顺序,它应该会起作用


也见。

谢谢你,工作得很好。请考虑接受我的回答: