-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add camera_projection class and projection cache
Signed-off-by: a-maumau <[email protected]>
- Loading branch information
Showing
19 changed files
with
458 additions
and
173 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
88 changes: 88 additions & 0 deletions
88
...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,88 @@ | ||
// 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 <autoware/universe_utils/system/lru_cache.hpp> | ||
|
||
#include <sensor_msgs/msg/camera_info.hpp> | ||
|
||
#include <opencv2/core/core.hpp> | ||
|
||
#include <image_geometry/pinhole_camera_model.h> | ||
|
||
#include <map> | ||
#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_width, const float grid_height, | ||
const bool unrectify, | ||
const bool use_approximation | ||
); | ||
CameraProjection(): grid_w_size_(1.0), grid_h_size_(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); | ||
|
||
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_h_, image_w_; | ||
double tan_h_x_, tan_h_y_; | ||
|
||
uint32_t cache_size_; | ||
float grid_w_size_; | ||
float grid_h_size_; | ||
float half_grid_w_size_; | ||
float half_grid_h_size_; | ||
float inv_grid_w_size_; | ||
float inv_grid_h_size_; | ||
uint32_t grid_x_num_; | ||
uint32_t grid_y_num_; | ||
float index_grid_out_h_; | ||
float index_grid_out_w_; | ||
|
||
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
Oops, something went wrong.