Ask Your Question

Raki's profile - activity

2023-07-27 10:25:11 -0600 received badge  Popular Question (source)
2023-07-27 10:25:11 -0600 received badge  Notable Question (source)
2021-04-14 17:56:58 -0600 received badge  Popular Question (source)
2020-11-08 20:41:09 -0600 received badge  Popular Question (source)
2020-10-20 00:09:05 -0600 marked best answer 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.0) for 4 times, then the error is thrown.

Any idea?

2020-06-07 16:14:40 -0600 received badge  Famous Question (source)
2020-03-08 17:45:22 -0600 received badge  Popular Question (source)
2020-03-08 17:45:22 -0600 received badge  Notable Question (source)
2019-09-18 02:03:09 -0600 edited question Getting the coordinates of intense non-black pixels

Getting the coordinates of intense non-black pixels I have the below image as an output of my prediction function (of a

2019-09-18 02:02:22 -0600 asked a question Getting the coordinates of intense non-black pixels

Getting the coordinates of intense non-black pixels I have the below image as an output of my prediction function (of a

2019-07-26 09:14:18 -0600 edited question What's the frame OpenCV uses?

What's the frame OpenCV uses? I have two cameras, monocular and stereo. I calibrated both and they're mounted at a fix r

2019-07-26 09:11:23 -0600 edited question What's the frame OpenCV uses?

What's the frame OPENCV uses? I have two cameras, monocular and stereo. I calibrated both and they're mounted at a fix r

2019-07-26 09:10:35 -0600 asked a question What's the frame OpenCV uses?

What's the frame OPENCV uses? I have two cameras, monocular and stereo. I calibrated both and they're mounted at a fix r

2019-07-15 21:50:09 -0600 received badge  Self-Learner (source)
2019-07-15 07:43:24 -0600 marked best answer findChessboardCorners() does not work[SOLVED]

I've my checkerboard fixed at a flat surface and I am looking at it with a 4K monocular camera, yet, the code provided does not work. My goal is to find the board's pose w.r.t the camera.

# algorithm parameters
WINDOW_SIZE = 100 # for 4k image
CHECKERBOARD_WIDTH = 6
CHECKERBOARD_HEIGHT = 4
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
objp = np.zeros((CHECKERBOARD_HEIGHT * CHECKERBOARD_WIDTH, 3), np.float32)
objp[:,:2] = np.mgrid[0:CHECKERBOARD_HEIGHT, 0:CHECKERBOARD_WIDTH].T.reshape(-1,2)


 # read the input image
ap = argparse.ArgumentParser()
ap.add_argument('-i', '--image', required=True,  help='Path to the image')
args = vars(ap.parse_args())
img = cv2.imread(args['image'])

gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret, corners = cv2.findChessboardCorners(gray, (CHECKERBOARD_HEIGHT,CHECKERBOARD_WIDTH),None)

it can't continue from the last line, which means it cannot find the squares/corners. Here is my checkerboard

I thought it was not finding it due to the scratches and dirt, so I tried with a better image and it still did not work.

Is this function kinda buggy or somehow sensitive that it takes such a big effort to make it work?

EDIT: Changing the lightning conditions did not help either:

image description

2019-07-15 07:42:42 -0600 answered a question findChessboardCorners() does not work[SOLVED]

Okay, got it, the problem was while passing the image.png, I did not use the appropriate path, so the function never eve

2019-07-15 07:28:00 -0600 edited question findChessboardCorners() does not work[SOLVED]

findChessboardCorners() does not work I've my checkerboard fixed at a flat surface and I am looking at it with a 4K mono

2019-07-15 07:23:18 -0600 asked a question findChessboardCorners() does not work[SOLVED]

findChessboardCorners() does not work I've my checkerboard fixed at a flat surface and I am looking at it with a 4K mono

2019-07-15 06:53:48 -0600 commented answer How to generate checkerboard for camera calibration?

Would circle one work for monocular camera calibration, or is it used for stereo?

2019-07-02 04:49:08 -0600 edited question Camera Pose from Checkerboard Pose

Camera Pose from Checkerboard Pose I am using the code given by the OpenCV to find tvecs and rvecs of the camera which I

2019-03-13 04:06:15 -0600 commented question OpenCV Error: Null pointer (NULL guiReceiver (please create a window))

Facing the same. Unbelievable that no one has replied yet.

2019-03-13 04:05:26 -0600 commented question Camera Pose from Checkerboard Pose

Yes I used that code, as I wrote in the question body.

2019-03-06 10:55:37 -0600 edited answer Camera Pose from Checkerboard Pose

So, this is how it is done. First, you calibrate your camera intrinsically. Get the matrices required for the calculati

2019-03-06 10:54:17 -0600 edited answer Camera Pose from Checkerboard Pose

So, this is how it is done. First, you calibrate your camera intrinsically. Get the matrices required for the calculati

2019-03-06 10:43:41 -0600 edited answer Camera Pose from Checkerboard Pose

So, this is how it is done. First, you calibrate your camera intrinsically. Get the matrices required for the calculati

2019-03-06 10:35:30 -0600 edited answer Camera Pose from Checkerboard Pose

So, this is how it is done. First, you calibrate your camera intrinsically. Get the matrices required for the calculati

2019-03-06 09:01:35 -0600 commented question Camera Pose from Checkerboard Pose

These matrices can be passed in to the function like this : retval, rvecs, tvecs, inliers = cv2.solvePnPRansac(objp, cor

2019-03-06 09:00:28 -0600 commented question Camera Pose from Checkerboard Pose

As an example, here are mine: M_MATRIX = np.asmatrix([21696.117836, 0.000000, 1956.264838, 0.000000, 22075.059632, 531.

2019-03-06 08:59:23 -0600 commented question Camera Pose from Checkerboard Pose

@supra56 That is the output of your intrinsic calibration procedure, but you can also simply create two arrays containin

2019-03-06 03:14:12 -0600 edited answer Camera Pose from Checkerboard Pose

So, this is how it is done. First, you calibrate your camera intrinsically. Get the matrices required for the calculati

2019-03-06 03:12:42 -0600 edited answer Camera Pose from Checkerboard Pose

So, this is how it is done. First, you calibrate your camera intrinsically. Get the matrices required for the calculati

2019-03-06 03:12:39 -0600 received badge  Self-Learner (source)
2019-03-06 03:12:20 -0600 marked best answer Camera Pose from Checkerboard Pose

I am using the code given by the OpenCV to find tvecs and rvecs of the camera which I calibrated intrinsically. I do get these two vectors, no problem.

image description

rvecs: [[-0.73059634]
 [-0.02493155]
 [ 0.1556929 ]]
tvecs: [[-2.8194188 ]
 [ 1.25920043]
 [77.38695895]]

However, I am not sure if these are the values for my camera or my checkerboard. The language used in the tutorial isn't totally clear. But I think these are the values for the checkerboard, like, this isn't the pose of the camera, but rather the pose of the board, which is not why people use this code in the first place.

Also, if these are actually the camera parameters, then one must multiply 77 with the size of one checker that he uses. Mine has 11 mm side, so for me the height would correspond to 77 * 1.1, which is also wrong since I measured the height and it's not that high.

Something is fishy here.

My question is, how could we go to camera extrinsics from these vectors?

2019-03-06 03:12:01 -0600 edited answer Camera Pose from Checkerboard Pose

So, this is how it is done. First, you calibrate your camera intrinsically. Get the matrices required for the calculati