-
Notifications
You must be signed in to change notification settings - Fork 98
stereo_undistort: accept output_camera_info_source parameter #53
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,14 @@ constexpr int kQueueSize = 10; | |
| // true to load input cam_info from ros parameters, false to get it from a | ||
| // cam_info topic | ||
| constexpr bool kDefaultInputCameraInfoFromROSParams = true; | ||
| // source of output camera information, the options are as follows- | ||
| // "auto_generated": (default), automatically generated based on the input, the | ||
| // focal length is the average of fx and fy of the input, the center point is | ||
| // in the center of the image, R=I and only x-translation is preserved. | ||
| // Resolution is set to the largest area that contains no empty pixels. The | ||
| // size of the output can also be modified with the "scale" parameter | ||
| // "match_input": intrinsic values are taken from the input camera parameters | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is taking the exact input intrinsics desirable for a stereo pair? At the very least I think you will have to ensure that both cameras are rectified using the same focal length or you will probably get pretty poor stereo depth. One possible solution could be to arbitrarily pick one camera and use its intrinsics to set the output for both cameras.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a copy-paste of the documentation of the parameter from the other header. the step which obtains an equal fov from both cameras and so on is still performed. my change mostly sets the resolution the same as the input. otherwise, the current code produces an image which can become much larger (particulary, wider) than the input, due to how the undistortion works. this leads to wasted computation if this bigger image is processed. this is specially important for embedded image processing. moreover, this produces an output similar to what you obtain with opencv and is what most users expect (see #50). in any case, I've only added an option and the default is the same, so I doesn't hurt.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just went back and checked, your using the function setOutputFromInput, which sets all intrinsic and extrinsic camera parameters to match the input, not just the image size. The best approach is probably the creation of a new function that just fixes the focal length, updates image size and moves the principle to the center. |
||
| const std::string kDefaultOutputCameraInfoSource = "auto_generated"; | ||
| // namespace to use when loading first camera parameters from ros params | ||
| const std::string kDefaultFirstCameraNamespace = "first_camera"; | ||
| // namespace to use when loading second camera parameters from ros params | ||
|
|
@@ -124,6 +132,11 @@ class StereoUndistort { | |
| // camera parameters | ||
| std::shared_ptr<StereoCameraParameters> stereo_camera_parameters_ptr_; | ||
|
|
||
| enum class OutputInfoSource { | ||
| AUTO_GENERATED, | ||
| MATCH_INPUT, | ||
| }; | ||
|
|
||
| // undistorters | ||
| std::shared_ptr<Undistorter> first_undistorter_ptr_; | ||
| std::shared_ptr<Undistorter> second_undistorter_ptr_; | ||
|
|
@@ -133,6 +146,7 @@ class StereoUndistort { | |
| int queue_size_; | ||
| int process_every_nth_frame_; | ||
| std::string output_image_type_; | ||
| OutputInfoSource output_camera_info_source_; | ||
| bool publish_tf_; | ||
| std::string first_output_frame_; | ||
| std::string second_output_frame_; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why add void? From memory this style of syntax, while valid only makes a difference in old C code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no reason, just a habbit. you can discard this change if you want