19#include "modules/perception/camera_tracking/proto/camera_tracking_component.pb.h"
36 AINFO <<
"Camera Tracking Component config: "
37 << camera_tracking_component_config.DebugString();
42 sensor_manager_ = algorithm::SensorManager::Instance();
45 std::string tracker_name = plugin_param.
name();
46 camera_obstacle_tracker_.reset(
47 BaseObstacleTrackerRegisterer::GetInstanceByName(tracker_name));
48 if (
nullptr == camera_obstacle_tracker_) {
49 AERROR <<
"Failed to get camera obstacle tracker instance.";
60 tracker_init_options.
gpu_id = camera_tracking_component_config.
gpu_id();
61 if (!camera_obstacle_tracker_->Init(tracker_init_options)) {
62 AERROR <<
"Failed to init camera obstacle tracker.";
69 const std::shared_ptr<onboard::CameraFrame>& message) {
71 AINFO << std::setprecision(16)
72 <<
"Enter Tracking component, message timestamp: " << message->timestamp
75 auto out_message = std::make_shared<onboard::SensorFrameMessage>();
76 bool status = InternalProc(message, out_message);
79 writer_->Write(out_message);
80 AINFO <<
"Send camera tracking output message.";
85bool CameraTrackingComponent::InternalProc(
86 const std::shared_ptr<const onboard::CameraFrame>& in_message,
87 std::shared_ptr<onboard::SensorFrameMessage> out_message) {
88 out_message->timestamp_ = in_message->timestamp;
89 std::shared_ptr<CameraTrackingFrame> tracking_frame;
91 tracking_frame->frame_id = in_message->frame_id;
92 tracking_frame->timestamp = in_message->timestamp;
93 tracking_frame->data_provider = in_message->data_provider;
94 tracking_frame->detected_objects = in_message->detected_objects;
95 tracking_frame->feature_blob = in_message->feature_blob;
97 tracking_frame->project_matrix.setIdentity();
98 tracking_frame->camera2world_pose = in_message->camera2world_pose;
102 bool res = camera_obstacle_tracker_->
Process(tracking_frame);
106 out_message->error_code_ =
108 AERROR <<
"Camera tracking process error!";
113 std::string camera_name = in_message->data_provider->sensor_name();
114 if (!(sensor_manager_->
GetSensorInfo(camera_name, &sensor_info))) {
115 AERROR <<
"Failed to get sensor info, sensor name: " << camera_name;
119 auto& frame = out_message->frame_;
120 frame = base::FramePool::Instance().Get();
123 frame->sensor_info = sensor_info;
124 frame->timestamp = in_message->timestamp;
125 frame->objects = tracking_frame->tracked_objects;
127 frame->sensor2world_pose = tracking_frame->camera2world_pose;
a singleton clock that can be used to get the current timestamp.
static double NowInSeconds()
gets the current time in second.
bool GetProtoConfig(T *config) const
std::shared_ptr< Node > node_
bool Process(const std::shared_ptr< onboard::CameraFrame > &msg0, const std::shared_ptr< NullType > &msg1, const std::shared_ptr< NullType > &msg2, const std::shared_ptr< NullType > &msg3)
bool GetSensorInfo(const std::string &name, apollo::perception::base::SensorInfo *sensor_info) const
A wrapper around SyncedMemory holders serving as the basic computational unit for images,...
bool Proc(const std::shared_ptr< onboard::CameraFrame > &message) override
@ PERCEPTION_ERROR_PROCESS
#define PERF_FUNCTION(...)
optional string config_file
optional string config_path
optional int32 image_height
optional int32 image_width
optional string output_channel_name
optional perception::PluginParam plugin_param