-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(image_projection_based_fusion): add cache for camera projection (#…
…9635) * add camera_projection class and projection cache Signed-off-by: a-maumau <[email protected]> * style(pre-commit): autofix * fix FOV filtering Signed-off-by: a-maumau <[email protected]> * style(pre-commit): autofix * remove unused includes Signed-off-by: a-maumau <[email protected]> * update schema Signed-off-by: a-maumau <[email protected]> * fix cpplint error Signed-off-by: a-maumau <[email protected]> * apply suggestion: more simple and effcient computation Signed-off-by: a-maumau <[email protected]> * correct terminology Signed-off-by: a-maumau <[email protected]> * style(pre-commit): autofix * fix comments Signed-off-by: a-maumau <[email protected]> * fix var name Signed-off-by: a-maumau <[email protected]> Co-authored-by: Taekjin LEE <[email protected]> * fix variable names Signed-off-by: a-maumau <[email protected]> Co-authored-by: Taekjin LEE <[email protected]> * fix variable names Signed-off-by: a-maumau <[email protected]> Co-authored-by: Taekjin LEE <[email protected]> * fix variable names Signed-off-by: a-maumau <[email protected]> Co-authored-by: Taekjin LEE <[email protected]> * fix variable names Signed-off-by: a-maumau <[email protected]> Co-authored-by: Taekjin LEE <[email protected]> * fix variable names Signed-off-by: a-maumau <[email protected]> * fix initialization Co-authored-by: badai nguyen <[email protected]> Signed-off-by: a-maumau <[email protected]> * add verification to point_project_to_unrectified_image when loading Co-authored-by: badai nguyen <[email protected]> Signed-off-by: a-maumau <[email protected]> * chore: add option description to project points to unrectified image Signed-off-by: Taekjin LEE <[email protected]> --------- Signed-off-by: a-maumau <[email protected]> Signed-off-by: Taekjin LEE <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Taekjin LEE <[email protected]> Co-authored-by: badai nguyen <[email protected]> Co-authored-by: Taekjin LEE <[email protected]>
- Loading branch information
1 parent
308eefb
commit ca3afdd
Showing
20 changed files
with
522 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...jection_based_fusion/include/autoware/image_projection_based_fusion/camera_projection.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2024 TIER IV, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef AUTOWARE__IMAGE_PROJECTION_BASED_FUSION__CAMERA_PROJECTION_HPP_ | ||
#define AUTOWARE__IMAGE_PROJECTION_BASED_FUSION__CAMERA_PROJECTION_HPP_ | ||
|
||
#define EIGEN_MPL2_ONLY | ||
|
||
#include <Eigen/Core> | ||
#include <opencv2/core/core.hpp> | ||
|
||
#include <sensor_msgs/msg/camera_info.hpp> | ||
|
||
#include <image_geometry/pinhole_camera_model.h> | ||
|
||
#include <memory> | ||
|
||
namespace autoware::image_projection_based_fusion | ||
{ | ||
struct PixelPos | ||
{ | ||
float x; | ||
float y; | ||
}; | ||
|
||
class CameraProjection | ||
{ | ||
public: | ||
explicit CameraProjection( | ||
const sensor_msgs::msg::CameraInfo & camera_info, const float grid_cell_width, | ||
const float grid_cell_height, const bool unrectify, const bool use_approximation); | ||
CameraProjection() : cell_width_(1.0), cell_height_(1.0), unrectify_(false) {} | ||
void initialize(); | ||
std::function<bool(const cv::Point3d &, Eigen::Vector2d &)> calcImageProjectedPoint; | ||
sensor_msgs::msg::CameraInfo getCameraInfo(); | ||
bool isOutsideHorizontalView(const float px, const float pz); | ||
bool isOutsideVerticalView(const float py, const float pz); | ||
bool isOutsideFOV(const float px, const float py, const float pz); | ||
|
||
protected: | ||
bool calcRectifiedImageProjectedPoint( | ||
const cv::Point3d & point3d, Eigen::Vector2d & projected_point); | ||
bool calcRawImageProjectedPoint(const cv::Point3d & point3d, Eigen::Vector2d & projected_point); | ||
bool calcRawImageProjectedPointWithApproximation( | ||
const cv::Point3d & point3d, Eigen::Vector2d & projected_point); | ||
void initializeCache(); | ||
|
||
sensor_msgs::msg::CameraInfo camera_info_; | ||
uint32_t image_height_, image_width_; | ||
double tan_h_x_, tan_h_y_; | ||
double fov_left_, fov_right_, fov_top_, fov_bottom_; | ||
|
||
uint32_t cache_size_; | ||
float cell_width_; | ||
float cell_height_; | ||
float inv_cell_width_; | ||
float inv_cell_height_; | ||
int grid_width_; | ||
int grid_height_; | ||
|
||
bool unrectify_; | ||
bool use_approximation_; | ||
|
||
std::unique_ptr<PixelPos[]> projection_cache_; | ||
image_geometry::PinholeCameraModel camera_model_; | ||
}; | ||
|
||
} // namespace autoware::image_projection_based_fusion | ||
|
||
#endif // AUTOWARE__IMAGE_PROJECTION_BASED_FUSION__CAMERA_PROJECTION_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.