Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new stereo matching validator for multiple camera calibration #678

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HViktorTsoi
Copy link
Contributor

@HViktorTsoi HViktorTsoi commented Mar 30, 2024

This PR add a new stereo matching validator to validate and visualize the result of multiple camera calibration. It uses the calibration result (the yaml file) from the last kalibr_calibrate_cameras step, undistorts and recitifies the images, and then run a stereo matcher to calculate the disparity map. No Calibration Target is Required in This Validator.

The stereo disparity map offers an intuitive, direct and comprehensive way to quickly visualize the calibration result. For example, a successful calibration may yield the following disparity results:

(with opencv sgbm stereo matcher)
Screenshot from 2024-03-31 02-04-09

(with opencv bm stereo matcher)
Screenshot from 2024-03-31 02-00-58
The depth of the ground plane and object surface is uniform and smooth.

While a bad calibration result leads to failed stereo matching (because of poor rectification) , resulting in a disparity map looks like this
Screenshot from 2024-03-31 02-03-17
Note there are lots of speckles and the ground plane is missing.

Usage:

python kalibr_camera_validator_stereo_match --cam ${path-to-camchain.yaml} --matcher bm --scale 2

or

python kalibr_camera_validator_stereo_match --cam ${path-to-camchain.yaml} --matcher sgbm --scale 2

the --matcher option selects the stereo matching algorithm (bm or sgbm). The --scale option determines how many times we downsample the image to speed up stereo matching .

np_image = np.array(cv_image)
if np_image.shape[1] > 1:
np_image = cv2.cvtColor(np_image, cv2.COLOR_RGB2GRAY)
except CvBridgeError, e:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                except CvBridgeError as e:

Make it also compatible with python3, which seems to be my default when using rosrun with Dockerfile_ros1_20_04...

Also needs updated to added to CMakeLists.

There are a few other things I think are needed for python3 compatibility, I didn't look too deeply into why mine is running in python3 but I did check on the kalibr_...validator one and that's also running in python3 so I think compatibility should be maintained?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants