ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Checking camera calibration

asked 2022-02-08 05:54:05 -0600

Roshan gravatar image

I have calibrated a camera and want to check how good the calibration is. I have used the camera_calibration package to calibrate the camera, and the camera_info now looks like this:

  seq: 107890
  stamp: 
    secs: 1644410751
    nsecs: 887102635
  frame_id: "tb3_1/camera"
height: 480
width: 640
distortion_model: "plumb_bob"
D: [0.02671649678130836, -0.06818375047433628, 0.001356081223209799, -2.099463419728962e-05, 0.0]
K: [649.0186923124629, 0.0, 315.2563179012676, 0.0, 651.6174092664056, 235.6077408121116, 0.0, 0.0, 1.0]
R: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
P: [649.7420654296875, 0.0, 314.7318835226943, 0.0, 0.0, 651.9991455078125, 235.5246928536799, 0.0, 0.0, 0.0, 1.0, 0.0]
binning_x: 0
binning_y: 0
roi: 
  x_offset: 0
  y_offset: 0
  height: 0
  width: 0
  do_rectify: False

In the package there is a cameracheck.py that should let you check how good the calibration is, but this does not run. I've made sure I'm using the rectified image by using the image_proc package.

Running it like this does not work:

python3 cameracheck.py --size 8x6 --square 0.25 image:=/cv_camera/image_rect_color camera:=/cv_camera

And running it like this does not work either:

python3 cameracheck.py --size 8x6 --square 0.25 image:=/cv_camera/image_rect_color monocular:=/forearm

The node just does nothing, running it results in no response.

As an alternative I tried following https://docs.opencv.org/4.x/dc/dbb/tu... to check how good the calibration is, but I don't fully understand what the values mtx, dist, rvecs, tvecs are supposed to be. The mtx should be K, dist is D, but how do I get tvecs and rvecs?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-02-08 08:59:04 -0600

ljaniec gravatar image

Both cameracalibrator.py and cameracheck.py are ROS Nodes, shouldn't you use rather rosrun camera_calibration cameracalibrator.py ... / rosrun camera_calibration cameracheck.py ...?

From the documentation there:

4. NODES

4.1 cameracalibrator.py

cameracalibrator.py subscribes to ROS raw image topics, and presents a calibration window. It can run in both monocular and stereo modes. The calibration window shows the current images from the cameras, highlighting the checkerboard. When the user presses the CALIBRATE button, the node computes the camera calibration parameters. When the user clicks COMMIT, the node uploads these new calibration parameters to the camera driver using a service call.

...

4.2 cameracheck.py

cameracheck.py subscribes to ROS rectified image topics and their associated camera_info, and prints out an error estimate. It can run in both monocular and stereo modes. The program expects to see a standard checkerboard target.

You should publish your ROS rectified images to the correct topics, then cameracheck.py will prints out error estimates.

edit flag offensive delete link more

Comments

I did try rosrun for the nodes but an eariler error made it so I had to use python3 to run instead, it should still run the nodes as usual though. I have followed the cameracalibrator documentation, have calibrated using a checkerboard, commited and then the calibration parameters were uploaded. Then using image_proc the rectified images are published to /cv_camera/image_rect_color or /cv_camera/image_rect depending on if you want colors or not.

So now that the rectified image is being published you can use it in the cameracheck.py like this: python3 cameracheck.py --size 8x6 --square 0.25 image:=/cv_camera/image_rect_color monocular:=/forearm, but the node does not respond and does nothing

Roshan gravatar image Roshan  ( 2022-02-08 09:18:05 -0600 )edit

What was this error with the nodes at the start? Maybe it is something to fix. Did you check images being published? You can try to compile the package from source after adding there some printed logs (just to see the responsiveness of the node) and use it to test it

ljaniec gravatar image ljaniec  ( 2022-02-09 02:38:19 -0600 )edit
1

The error was because of the node using python2, same issue as described here; https://answers.ros.org/question/3857.... Images are being published, confirmed through image_view. Will try to compile from source and add the print though

Roshan gravatar image Roshan  ( 2022-02-09 02:42:38 -0600 )edit

It is possible that the package has some bugs there - and maybe you can add your fix there/on your fork later! :)

ljaniec gravatar image ljaniec  ( 2022-02-09 03:22:11 -0600 )edit

Does the cameracheck.py work for you? I've seen several people not managing to get it work but noone says if they got it working eventually or not

Roshan gravatar image Roshan  ( 2022-02-09 03:28:13 -0600 )edit
1

Right now I don't use ROS1 but ROS2 + I am working remotely, so I don't have direct access to laboratory right now :( I will try to check it in my free time but don't expect it soon

ljaniec gravatar image ljaniec  ( 2022-02-09 03:39:28 -0600 )edit

Sorry for long time without response. Can you try these steps from this blog post to check your camera and it's calibration? I didn't get this package to work either but OpenCV has an instruction to calculate Re-projection Error (bottom of the page) which gives a good estimation of just how exact the found parameters are. Maybe this will be enough?

ljaniec gravatar image ljaniec  ( 2022-03-11 07:50:20 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2022-02-08 05:54:05 -0600

Seen: 901 times

Last updated: Feb 08 '22