-
Notifications
You must be signed in to change notification settings - Fork 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
moved undistorter to cameras and added point processing function #34
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 |
---|---|---|
|
@@ -107,16 +107,32 @@ class NCamera { | |
/// Get the geometry object for camera i. | ||
const Camera& getCamera(size_t camera_index) const; | ||
|
||
/// Get the geometry object for camera i. | ||
/// The method will assert that the camera is not in the rig! | ||
const Camera& getCamera(const CameraId& camera_id) const; | ||
|
||
/// Get the geometry object for camera i. | ||
Camera& getCameraMutable(size_t camera_index); | ||
|
||
/// Get the geometry object for camera i. | ||
/// The method will assert that the camera is not in the rig! | ||
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. same? 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. and below |
||
Camera& getCameraMutable(const CameraId& camera_id); | ||
|
||
/// Get the geometry object for camera i. | ||
std::shared_ptr<Camera> getCameraShared(size_t camera_index); | ||
|
||
/// Get the geometry object for camera i. | ||
/// The method will assert that the camera is not in the rig! | ||
std::shared_ptr<Camera> getCameraShared(const CameraId& camera_id); | ||
|
||
/// Get the geometry object for camera i. | ||
std::shared_ptr<const Camera> getCameraShared(size_t camera_index) const; | ||
|
||
/// Get the geometry object for camera i. | ||
/// The method will assert that the camera is not in the rig! | ||
std::shared_ptr<const Camera> getCameraShared(const CameraId& camera_id) const; | ||
|
||
/// Set the geometry object for camera i. | ||
void setCamera(size_t camera_index, std::shared_ptr<Camera> camera); | ||
|
||
/// How many cameras does this system have? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
#ifndef ASLAM_PIPELINE_MAPPED_UNDISTORTER_INL_H_ | ||
#define ASLAM_PIPELINE_MAPPED_UNDISTORTER_INL_H_ | ||
#ifndef ASLAM_CAMERAS_MAPPED_UNDISTORTER_INL_H_ | ||
#define ASLAM_CAMERAS_MAPPED_UNDISTORTER_INL_H_ | ||
|
||
#include <aslam/cameras/camera-factory.h> | ||
#include <aslam/cameras/camera.h> | ||
#include <aslam/cameras/convert-maps-legacy.h> | ||
#include <aslam/common/undistort-helpers.h> | ||
|
||
namespace aslam { | ||
|
||
template <> | ||
inline std::unique_ptr<MappedUndistorter> createMappedUndistorter( | ||
inline std::shared_ptr<MappedUndistorter> createMappedUndistorter( | ||
const aslam::Camera& camera, float alpha, float scale, | ||
aslam::InterpolationMethod interpolation_type) { | ||
switch (camera.getType()) { | ||
|
@@ -34,13 +35,12 @@ inline std::unique_ptr<MappedUndistorter> createMappedUndistorter( | |
} | ||
|
||
template <typename CameraType> | ||
inline std::unique_ptr<MappedUndistorter> createMappedUndistorter( | ||
inline std::shared_ptr<MappedUndistorter> createMappedUndistorter( | ||
const CameraType& camera, float alpha, float scale, | ||
aslam::InterpolationMethod interpolation_type) { | ||
CHECK_GE(alpha, 0.0); | ||
CHECK_LE(alpha, 1.0); | ||
CHECK_GT(scale, 0.0); | ||
|
||
// Create a copy of the input camera. | ||
aslam::Camera::Ptr input_camera(camera.clone()); | ||
CHECK(input_camera); | ||
|
@@ -70,8 +70,7 @@ inline std::unique_ptr<MappedUndistorter> createMappedUndistorter( | |
input_camera); | ||
CHECK(unified_proj_cam_ptr != nullptr) | ||
<< "Cast to unified projection camera failed."; | ||
intrinsics << unified_proj_cam_ptr->xi(), output_camera_matrix(0, 0), | ||
output_camera_matrix(1, 1), output_camera_matrix(0, 2), | ||
output_camera_matrix(1, 1), output_camera_matrix(0, 2), | ||
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 seems fishy, is there a line missing here? |
||
output_camera_matrix(1, 2); | ||
output_camera.reset( | ||
new UnifiedProjectionCamera(intrinsics, output_width, output_height)); | ||
|
@@ -88,9 +87,16 @@ inline std::unique_ptr<MappedUndistorter> createMappedUndistorter( | |
common::buildUndistortMap( | ||
*input_camera, *output_camera, CV_16SC2, map_u, map_v); | ||
|
||
return std::unique_ptr<MappedUndistorter>(new MappedUndistorter( | ||
input_camera, output_camera, map_u, map_v, interpolation_type)); | ||
// Convert map to non-fixed point representation for easy lookup of values. | ||
cv::Mat map_u_float = map_u.clone(); | ||
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. does it make sense to clone the cv::Mat and then later I guess you just overwrite everything again or even reallocate them? Why not initialize them to the right size and type here or inside the function? |
||
cv::Mat map_v_float = map_v.clone(); | ||
aslam::convertMapsLegacy(map_u, map_v, map_u_float, map_v_float, CV_32FC1); | ||
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. why do we need to use a legacy function in this core functionality? Is this reverting the map convention to legacy? |
||
|
||
return std::shared_ptr<MappedUndistorter>( | ||
new MappedUndistorter( | ||
input_camera, output_camera, map_u, map_v, map_u_float, map_v_float, | ||
interpolation_type)); | ||
} | ||
|
||
} // namespace aslam | ||
#endif // ASLAM_PIPELINE_MAPPED_UNDISTORTER_INL_H_ | ||
#endif // ASLAM_CAMERAS_MAPPED_UNDISTORTER_INL_H_ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
#ifndef ASLAM_PIPELINE_MAPPED_UNDISTORTER_H_ | ||
#define ASLAM_PIPELINE_MAPPED_UNDISTORTER_H_ | ||
#ifndef ASLAM_CAMERAS_MAPPED_UNDISTORTER_H_ | ||
#define ASLAM_CAMERAS_MAPPED_UNDISTORTER_H_ | ||
|
||
#include <opencv2/core/core.hpp> | ||
|
||
#include <aslam/common/types.h> | ||
#include <aslam/cameras/camera.h> | ||
#include <aslam/cameras/camera-pinhole.h> | ||
#include <aslam/cameras/camera-unified-projection.h> | ||
#include <aslam/pipeline/undistorter.h> | ||
#include <aslam/cameras/undistorter.h> | ||
|
||
namespace aslam { | ||
|
||
|
@@ -24,7 +24,7 @@ namespace aslam { | |
/// @param[in] interpolation_type Check \ref InterpolationMethod to see the available types. | ||
/// @return Pointer to the created mapped undistorter. | ||
template <typename CameraType> | ||
std::unique_ptr<MappedUndistorter> createMappedUndistorter( | ||
std::shared_ptr<MappedUndistorter> createMappedUndistorter( | ||
const CameraType& camera, float alpha, float scale, | ||
aslam::InterpolationMethod interpolation_type); | ||
|
||
|
@@ -39,7 +39,7 @@ std::unique_ptr<MappedUndistorter> createMappedUndistorter( | |
/// @param[in] scale Output image size scaling parameter wrt. to input image size. | ||
/// @param[in] interpolation_type Check \ref MappedUndistorter to see the available types. | ||
/// @return Pointer to the created mapped undistorter. | ||
std::unique_ptr<MappedUndistorter> createMappedUndistorterToPinhole( | ||
std::shared_ptr<MappedUndistorter> createMappedUndistorterToPinhole( | ||
const aslam::UnifiedProjectionCamera& unified_proj_camera, | ||
float alpha, float scale, aslam::InterpolationMethod interpolation_type); | ||
|
||
|
@@ -69,13 +69,21 @@ class MappedUndistorter : public Undistorter { | |
/// \param[in] interpolation Interpolation method used for undistortion. | ||
/// (\ref InterpolationMethod) | ||
MappedUndistorter(aslam::Camera::Ptr input_camera, aslam::Camera::Ptr output_camera, | ||
const cv::Mat& map_u, const cv::Mat& map_v, InterpolationMethod interpolation); | ||
const cv::Mat& map_u, const cv::Mat& map_v, | ||
const cv::Mat& map_u_float, const cv::Mat& map_v_float, | ||
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. why does this now take both the fixed point maps and the float map? Shouldn't it only need one of the two? |
||
InterpolationMethod interpolation); | ||
|
||
virtual ~MappedUndistorter() = default; | ||
|
||
/// \brief Produce an undistorted image from an input image. | ||
virtual void processImage(const cv::Mat& input_image, cv::Mat* output_image) const; | ||
|
||
/// \brief Undisort a point using the map. | ||
void processPoint(const Eigen::Vector2d& input_point, Eigen::Vector2d* output_point) const; | ||
|
||
/// \brief Undistort a point using the map. | ||
void processPoint(Eigen::Vector2d* point) const; | ||
|
||
/// Get the undistorter map for the u-coordinate. | ||
const cv::Mat& getUndistortMapU() const { return map_u_; }; | ||
|
||
|
@@ -87,12 +95,16 @@ class MappedUndistorter : public Undistorter { | |
const cv::Mat map_u_; | ||
/// \brief LUT for v coordinates. | ||
const cv::Mat map_v_; | ||
/// \brief Non-fixed point LUT for u coordinates. | ||
const cv::Mat map_u_float_; | ||
/// \brief Non-fixed point LUT for v coordinates. | ||
const cv::Mat map_v_float_; | ||
/// \brief Interpolation strategy | ||
InterpolationMethod interpolation_method_; | ||
}; | ||
|
||
} // namespace aslam | ||
|
||
#include "aslam/pipeline/undistorter-mapped-inl.h" | ||
#include "aslam/cameras/undistorter-mapped-inl.h" | ||
|
||
#endif // ASLAM_PIPELINE_MAPPED_UNDISTORTER_H_ | ||
#endif // ASLAM_CAMERAS_MAPPED_UNDISTORTER_H_ |
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.
that the camera IS in the rig
?