llSourcell / Object_Detection_demo_LIVE

This is the code for the "How to do Object Detection with OpenCV" live session by Siraj Raval on Youtube
103 stars 80 forks source link

Run fails on Arch Linux #1

Closed codingquark closed 7 years ago

codingquark commented 7 years ago

First issue is this line: contours, hierarchy = cv2.findContours(image, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

This says too many values to unpack. Also changed the name of the image from yo to berry.

So I added one more variable and getting this error:

OpenCV Error: Assertion failed (npoints >= 0 && (depth == CV_32F || depth == CV_32S)) in contourArea, file /build/opencv/src/opencv-3.1.0/modules/imgproc/src/shapedescr.cpp, line 314
Traceback (most recent call last):
  File "demo.py", line 132, in <module>
    result = find_strawberry(image)
  File "demo.py", line 113, in find_strawberry
    big_strawberry_contour, mask_strawberries = find_biggest_contour(mask_clean)
  File "demo.py", line 38, in find_biggest_contour
    contour_sizes = [(cv2.contourArea(contour), contour) for contour in contours]
  File "demo.py", line 38, in <listcomp>
    contour_sizes = [(cv2.contourArea(contour), contour) for contour in contours]
cv2.error: /build/opencv/src/opencv-3.1.0/modules/imgproc/src/shapedescr.cpp:314: error: (-215) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function contourArea

May be it is due to the OpenCV version I'm using, but I am not sure.

Karmahero commented 7 years ago

In order for demo.py to work with OpenCV 3, update these lines:

[35] _, contours, hierarchy = cv2.findContours(image, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
[51] cv2.ellipse(image_with_ellipse, ellipse, green, 2, cv2.LINE_AA)
codingquark commented 7 years ago

Awesome. Thanks!