18#include "modules/perception/traffic_light_detection/proto/traffic_light_detection_component.pb.h"
27namespace trafficlight {
32 AERROR <<
"TrafficLightDetectComponent InitConfig failed.";
37 AERROR <<
"TrafficLightDetectComponent InitAlgorithmPlugin failed.";
45 const std::shared_ptr<TrafficDetectMessage>& message) {
47 auto time_imags = std::to_string(message->timestamp_);
48 AINFO <<
"Enter detection component, message timestamp: " << time_imags;
50 bool status = InternalProc(message);
52 writer_->Write(message);
53 AINFO <<
"Send trafficlight detect output message.";
58int TrafficLightDetectComponent::InitConfig() {
61 AINFO <<
"load trafficlights detection component proto param failed";
66 tl_detector_name_ = plugin_param.name();
67 config_path_ = plugin_param.config_path();
68 config_file_ = plugin_param.config_file();
70 gpu_id_ = traffic_light_param.
gpu_id();
71 AINFO <<
"tl_detector_name: " << tl_detector_name_
72 <<
" config_path: " << config_path_ <<
" config_file: " << config_file_
73 <<
" gpu_id: " << gpu_id_;
75 writer_ =
node_->CreateWriter<TrafficDetectMessage>(
81bool TrafficLightDetectComponent::InitAlgorithmPlugin() {
82 trafficlight::BaseTrafficLightDetector* detector =
83 trafficlight::BaseTrafficLightDetectorRegisterer::GetInstanceByName(
85 CHECK_NOTNULL(detector);
86 detector_.reset(detector);
87 ACHECK(detector_ !=
nullptr);
88 detector_init_options_.
gpu_id = gpu_id_;
92 if (!detector_->Init(detector_init_options_)) {
93 AERROR <<
"Trafficlight detector init failed";
100bool TrafficLightDetectComponent::InternalProc(
101 const std::shared_ptr<TrafficDetectMessage const>& message) {
103 bool status = detector_->Detect(message->traffic_light_frame_.get());
bool GetProtoConfig(T *config) const
std::shared_ptr< Node > node_
bool Proc(const std::shared_ptr< TrafficDetectMessage > &message) override
Trigger the detection process based on the traffic detect message.
bool Init() override
Initialize configuration files, algorithm plug-ins.
#define PERF_FUNCTION(...)
optional string detection_output_channel_name
optional perception::PluginParam plugin_param