Apollo 11.0
自动驾驶开放平台
camera_util.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16#pragma once
17
18#include <memory>
19#include <vector>
20
26
27namespace apollo {
28namespace perception {
29namespace fusion {
30
31// @brief: get object eight vertices
32// @param [in]: object
33// @param [in/out]: vertices
35 std::shared_ptr<const base::Object> obj,
37
48template <typename VectorType>
49bool IsPtInFrustum(const VectorType& pt, double width, double height) {
50 if (pt[0] < 0 || pt[0] > width || pt[1] < 0 || pt[1] > height) {
51 return false;
52 }
53 return true;
54}
55
65template <typename Type>
67 const base::BBox2D<Type>& box2,
68 const Type& augmented_buffer) {
69 base::BBox2D<Type> augmented_box1 = box1;
70 augmented_box1.xmin -= augmented_buffer;
71 augmented_box1.ymin -= augmented_buffer;
72 augmented_box1.xmax += augmented_buffer;
73 augmented_box1.ymax += augmented_buffer;
74 base::BBox2D<Type> augmented_box2 = box2;
75 augmented_box2.xmin -= augmented_buffer;
76 augmented_box2.ymin -= augmented_buffer;
77 augmented_box2.xmax += augmented_buffer;
78 augmented_box2.ymax += augmented_buffer;
79 Type augmented_iou =
80 algorithm::CalculateIOUBBox(augmented_box1, augmented_box2);
81 return augmented_iou;
82}
83
84// @brief: project 3d point to 2d point in camera
85// @param [in]: pt3d
86// @param [in]: world2camera_pose
87// @param [in]: camera_model
88// @param [in/out]: pt2d
89// @return: true if local 3d point z > 0, else false
90bool Pt3dToCamera2d(const Eigen::Vector3d& pt3d,
91 const Eigen::Matrix4d& world2camera_pose,
92 base::BaseCameraModelPtr camera_model,
93 Eigen::Vector2d* pt2d);
94
95// @brief: whether object eight vertices' local 3d point z < 0
96// @param [in]: obj
97// @param [in]: world2camera_pose
98// @param [in]: camera_model
100 const std::shared_ptr<const base::Object>& obj,
101 const Eigen::Matrix4d& world2camera_pose,
102 base::BaseCameraModelPtr camera_model);
103
104// @brief: compute the ratio of object in camera view
105// @param [in]: sensor_object
106// @param [in]: camera_model
107// @param [in]: camera_sensor2world_pose
108// @param [in]: camera_timestamp
109// @param [in]: camera_max_dist, the max distace can be detected by camera
110// @param [in]: motion_compenseation
111// @param [in]: all_in, if all_in is true, just return 0.0 or 1.0
112float ObjectInCameraView(SensorObjectConstPtr sensor_object,
113 base::BaseCameraModelPtr camera_model,
114 const Eigen::Affine3d& camera_sensor2world_pose,
115 double camera_ts, double camera_max_dist,
116 bool motion_compensation, bool all_in);
117
118} // namespace fusion
119} // namespace perception
120} // namespace apollo
std::vector< EigenType, Eigen::aligned_allocator< EigenType > > EigenVector
Definition eigen_defs.h:33
Type CalculateIOUBBox(const base::BBox2D< Type > &box1, const base::BBox2D< Type > &box2)
Definition common.h:211
std::shared_ptr< BaseCameraModel > BaseCameraModelPtr
Definition camera.h:75
std::shared_ptr< const SensorObject > SensorObjectConstPtr
bool IsObjectEightVerticesAllBehindCamera(const std::shared_ptr< const base::Object > &obj, const Eigen::Matrix4d &world2camera_pose, base::BaseCameraModelPtr camera_model)
bool Pt3dToCamera2d(const Eigen::Vector3d &pt3d, const Eigen::Matrix4d &world2camera_pose, base::BaseCameraModelPtr camera_model, Eigen::Vector2d *pt2d)
Type CalculateAugmentedIOUBBox(const base::BBox2D< Type > &box1, const base::BBox2D< Type > &box2, const Type &augmented_buffer)
Calculate augmented IOU BBox
Definition camera_util.h:66
float ObjectInCameraView(SensorObjectConstPtr sensor_object, base::BaseCameraModelPtr camera_model, const Eigen::Affine3d &camera_sensor2world_pose, double camera_ts, double camera_max_dist, bool motion_compensation, bool all_in)
void GetObjectEightVertices(std::shared_ptr< const base::Object > obj, EigenVector< Eigen::Vector3d > *vertices)
bool IsPtInFrustum(const VectorType &pt, double width, double height)
Is point lies in the frustum
Definition camera_util.h:49
class register implement
Definition arena_queue.h:37