0
$\begingroup$

Rosanswers logo

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/tutorial_py_calibration.html 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?


Originally posted by Roshan on ROS Answers with karma: 51 on 2022-02-08

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by ljaniec with karma: 3064 on 2022-02-08

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Roshan on 2022-02-08:
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

Comment by ljaniec on 2022-02-09:
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

Comment by Roshan on 2022-02-09:
The error was because of the node using python2, same issue as described here; https://answers.ros.org/question/385702/ros-noetic-runninh-camera_checker-shows-no-module-named-rospkg/. Images are being published, confirmed through image_view. Will try to compile from source and add the print though

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

Comment by Roshan on 2022-02-09:
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

Comment by ljaniec on 2022-02-09:
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

Comment by ljaniec on 2022-03-11:
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?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.