52 ADEBUG <<
"Do not run obstacle postprocessor.";
56 Eigen::Vector4d plane;
57 if (!calibration_service_->QueryGroundPlaneInCameraFrame(&plane)) {
58 AINFO <<
"No valid ground plane in the service.";
61 float query_plane[4] = {
62 static_cast<float>(plane(0)),
static_cast<float>(plane(1)),
63 static_cast<float>(plane(2)),
static_cast<float>(plane(3))};
67 for (
size_t i = 0; i < 3; ++i) {
68 for (
size_t j = 0; j < 3; ++j) {
69 k_mat[i * 3 + j] = camera_k_matrix(i, j);
72 AINFO <<
"Camera k matrix input to obstacle postprocessor: \n"
73 << k_mat[0] <<
", " << k_mat[1] <<
", " << k_mat[2] <<
"\n"
74 << k_mat[3] <<
", " << k_mat[4] <<
", " << k_mat[5] <<
"\n"
75 << k_mat[6] <<
", " << k_mat[7] <<
", " << k_mat[8] <<
"\n";
79 postprocessor_->Init(k_mat, width_image, height_image);
86 float object_center[3] = {obj->camera_supplement.local_center(0),
87 obj->camera_supplement.local_center(1),
88 obj->camera_supplement.local_center(2)};
90 obj->camera_supplement.box.xmin, obj->camera_supplement.box.ymin,
91 obj->camera_supplement.box.xmax, obj->camera_supplement.box.ymax};
93 float bottom_center[2] = {(bbox2d[0] + bbox2d[2]) / 2, bbox2d[3]};
94 float h_down = (
static_cast<float>(height_image) - k_mat[5]) *
97 is_in_roi(bottom_center,
static_cast<float>(width_image),
98 static_cast<float>(height_image), k_mat[5], h_down);
104 ADEBUG <<
"Pass for obstacle postprocessor.";
108 float dimension_hwl[3] = {obj->size(2), obj->size(1), obj->size(0)};
109 float box_cent_x = (bbox2d[0] + bbox2d[2]) / 2;
110 Eigen::Vector3f image_point_low_center(box_cent_x, bbox2d[3], 1);
111 Eigen::Vector3f point_in_camera =
112 static_cast<Eigen::Matrix<float, 3, 1, 0, 3, 1>
>(
113 camera_k_matrix.inverse() * image_point_low_center);
115 static_cast<float>(atan2(point_in_camera.x(), point_in_camera.z()));
117 theta_ray +
static_cast<float>(obj->camera_supplement.alpha);
121 if (rotation_y < -
PI) {
122 rotation_y += 2 *
PI;
123 }
else if (rotation_y >=
PI) {
124 rotation_y -= 2 *
PI;
128 memcpy(obj_postprocessor_options.
bbox, bbox2d,
sizeof(
float) * 4);
132 obj_postprocessor_options.
line_segs.push_back(line_seg);
133 memcpy(obj_postprocessor_options.
hwl, dimension_hwl,
sizeof(
float) * 3);
134 obj_postprocessor_options.
ry = rotation_y;
137 memcpy(obj_postprocessor_options.
plane, query_plane,
sizeof(
float) * 4);
140 object_center[1] += dimension_hwl[0] / 2;
141 postprocessor_->PostProcessObjWithGround(
142 obj_postprocessor_options, object_center, dimension_hwl, &rotation_y);
143 object_center[1] -= dimension_hwl[0] / 2;
145 float z_diff_camera =
146 object_center[2] - obj->camera_supplement.local_center(2);
149 obj->camera_supplement.local_center(0) = object_center[0];
150 obj->camera_supplement.local_center(1) = object_center[1];
151 obj->camera_supplement.local_center(2) = object_center[2];
153 obj->center(0) =
static_cast<double>(object_center[0]);
154 obj->center(1) =
static_cast<double>(object_center[1]);
155 obj->center(2) =
static_cast<double>(object_center[2]);
158 AINFO <<
"diff on camera z: " << z_diff_camera;
159 AINFO <<
"Obj center from postprocessor: " << obj->center.transpose();
#define REGISTER_OBSTACLE_POSTPROCESSOR(name)
bool Process(const PostprocessorOptions &options, onboard::CameraFrame *frame) override
post refine location of 3D obstacles
bool Init(const PostprocessorInitOptions &options=PostprocessorInitOptions()) override
: set location refiner param
std::vector< LineSegment2D< float > > line_segs
std::shared_ptr< BaseCalibrationService > calibration_service