Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

pointPolygonTest() throws error for some reason

I am using the following piece of code to check if a point is inside the contour or not:

    # form the contour from points 
    cnt = []
    for pose in component.part_outline.outline_poses.poses:
                    point = (pose.position.x, pose.position.y)
                    cnt.append(point)    
    cnt = np.array(cnt)

    # get the point to be tested
    point = (screw.pose.position.x, screw.pose.position.y)

    # run the test
    is_inside = cv2.pointPolygonTest(cnt,point, False) 
    if is_inside > 0:
             print("bla bla") # act upon the outcome

and I get the following error for some reason:

"error: OpenCV(3.4.4) /io/opencv/modules/imgproc/src/geometry.cpp:103: error: (-215:Assertion failed) total >= 0 && (depth == CV_32S || depth == CV_32F) in function 'pointPolygonTest'\n\n"

This error message does not tell much to be honest, and I have absolutely no idea why this is happening. I checked the image, it's there. The contour and the point are also there, nothing is null or whatsoever.

Any idea?

pointPolygonTest() throws error for some reason

I am using the following piece of code to check if a point is inside the contour or not:

    # form the contour from points 
    cnt = []
    for pose in component.part_outline.outline_poses.poses:
                    point = (pose.position.x, pose.position.y)
                    cnt.append(point)    
    cnt = np.array(cnt)

    # get the point to be tested
    point = (screw.pose.position.x, screw.pose.position.y)

    # run the test
    is_inside = cv2.pointPolygonTest(cnt,point, False) 
    if is_inside > 0:
             print("bla bla") # act upon the outcome

and I get the following error for some reason:

"error: OpenCV(3.4.4) /io/opencv/modules/imgproc/src/geometry.cpp:103: error: (-215:Assertion failed) total >= 0 && (depth == CV_32S || depth == CV_32F) in function 'pointPolygonTest'\n\n"

This error message does not tell much to be honest, and I have absolutely no idea why this is happening. I checked the image, it's there. The contour and the point are also there, nothing is null or whatsoever.

P.S: In case if it helps, I tried to print the variable is_inside and it prints (-1) for some times, then the error is thrown.

Any idea?

pointPolygonTest() throws error for some reason

I am using the following piece of code to check if a point is inside the contour or not:

    # form the contour from points 
    cnt = []
    for pose in component.part_outline.outline_poses.poses:
                    point = (pose.position.x, pose.position.y)
                    cnt.append(point)    
    cnt = np.array(cnt)

    # get the point to be tested
    point = (screw.pose.position.x, screw.pose.position.y)

    # run the test
    is_inside = cv2.pointPolygonTest(cnt,point, False) 
    if is_inside > 0:
             print("bla bla") # act upon the outcome

and I get the following error for some reason:

"error: OpenCV(3.4.4) /io/opencv/modules/imgproc/src/geometry.cpp:103: error: (-215:Assertion failed) total >= 0 && (depth == CV_32S || depth == CV_32F) in function 'pointPolygonTest'\n\n"

This error message does not tell much to be honest, and I have absolutely no idea why this is happening. I checked the image, it's there. The contour and the point are also there, nothing is null or whatsoever.

P.S: In case if it helps, I tried to print the variable is_inside and it prints (-1) for some 4 times, then the error is thrown.

Any idea?

pointPolygonTest() throws error for some reason

I am using the following piece of code to check if a point is inside the contour or not:

    # form the contour from points 
    cnt = []
    for pose in component.part_outline.outline_poses.poses:
                    point = (pose.position.x, pose.position.y)
                    cnt.append(point)    
    cnt = np.array(cnt)

    # get the point to be tested
    point = (screw.pose.position.x, screw.pose.position.y)

    # run the test
    is_inside = cv2.pointPolygonTest(cnt,point, False) 
    if is_inside > 0:
             print("bla bla") # act upon the outcome

and I get the following error for some reason:

"error: OpenCV(3.4.4) /io/opencv/modules/imgproc/src/geometry.cpp:103: error: (-215:Assertion failed) total >= 0 && (depth == CV_32S || depth == CV_32F) in function 'pointPolygonTest'\n\n"

This error message does not tell much to be honest, and I have absolutely no idea why this is happening. I checked the image, it's there. The contour and the point are also there, nothing is null or whatsoever.

P.S: In case if it helps, I tried to print the variable is_inside and it prints (-1) (-1.0) for 4 times, then the error is thrown.

Any idea?