udacity/CarND-LaneLines-P1

region_of_interest issue with fillPoly()

Closed this issue ยท 6 comments

The region_of_interest() function says it takes vertices which it passes to cv2.fillPoly(), but it seems like what that function is supposed to take is an Array of shapes.

I think that function should be updated like so:

-cv2.fillPoly(mask, vertices, ignore_mask_color)
+# We need to pass in an array of shapes (each shape is an array of vertices)
+cv2.fillPoly(mask, [vertices], ignore_mask_color)

Causes error: error: /home/travis/miniconda/conda-bld/conda_1486587071158/work/opencv-3.1.0/modules/imgproc/src/drawing.cpp:2276: error: (-215) p.checkVector(2, CV_32S) >= 0 in function fillPoly

See related error http://stackoverflow.com/questions/17241830/opencv-polylines-function-in-python-throws-exception/18817152#18817152

Yep, the second argument is an array of array of points. The cpp interface has a proxy object called InputArrayOfArray.

this should make a pull request

Actually, it wants a numpy array of (arrays of) 32 bit integers, so it's more like:

cv2.fillPoly(mask, np.array([vertices], dtype=np.int32), ignore_mask_color)

The way this is demonstrated in the classroom quiz includes vertices as being an array of shapes already - vertices = np.array([[(0,imshape[0]),(0, 0), (imshape[1], 0), (imshape[1],imshape[0])]], dtype=np.int32) (this is before tuning :) ). I think it may be more confusing to change this within the notebook, as the vertices themselves are already supposed to be in an array.

What are your thoughts? Perhaps just editing the docstring to mention that vertices is an array of integer points might solve it.

Updated the docstring to clarify this further.