ehong-tl / camera_2d_lidar_calibration

ROS camera 2D Lidar extrinsic calibration tool
58 stars 19 forks source link

Why is there a negative value #6

Open gokcesena opened 4 months ago

gokcesena commented 4 months ago

Hi, Thank you for your work. When I add the following lines in the reprojection.py file "for i in range(len(img_points)): try: cv2.circle(img, (np.int32(round(img_points[i][0])),np.int32(round(img_points[i][1]))), laser_point_radius, (0,255,0), 1) print((np.int32(round(img_points[i][0]))),np.int32(round(img_points[i][1]))))"

The following values are printed to the terminal:

" ... (-401, 462) (-388, 462) (-374, 463) (-359, 463) (-344, 463) (-327, 464) (-310, 465) (-291, 465) (-272, 466) (-251, 466) (-230, 467) (-207, 468) (-183, 468) (-159, 469) (-132, 470) (-105, 470) (-76, 471) (-45, 472) (-13, 473) (20, 474) (55, 475) (92, 476) (130, 477) (170, 478) (213, 479) (257, 480) (303, 481) (351, 482) (401, 483) (454, 485) (509, 486) (567, 487) (628, 489) (691, 490) (757, 492) (826, 493) (898, 495) (974, 497) (1052, 498) (1134, 500) (1220, 502) (1310, 504) (1403, 506) (1501, 508) (1604, 510) (1711, 513) (1822, 515) (1939, 518) (2061, 520) (2188, 523) (2321, 526) (2460, 529) (2605, 532) (2757, 535) (2916, 538) ..." My question is, although the pixel width of the camera is 1280, why do I get values greater than 1280 or why are there negative values? Thank you in advance for your reply!

ehong-tl commented 4 months ago

Hi @gokcesena

Values beyond the image boundaries (negative value or pixel value beyond image width in your current case) means that the 3D points projected outside of the image boundaries. It is normal to have this during reprojection. If you frequently encounter them, please try to refine your calibration.

gokcesena commented 4 months ago

Thank you for your quick reply @ehong-tl, the rmse value is high when I take samples frequently. I did it with 13 samples for calibration, but I will do what you said and take more samples. thanks

gokcesena commented 4 months ago

I'm wondering: Can I only publish point clouds that fall in front of the camera? I think this line: "objPoints = objPoints[Z > 0]" should give the pointcloud data falling in front of the camera, can you direct me?

ehong-tl commented 4 months ago

Yes, these 2 lines of code will remove points that are falling behind the camera.

Z = get_z(q, objPoints, K)
objPoints = objPoints[Z > 0]