Apollo 10.0
自动驾驶开放平台
apollo::image_decompress::ImageDecompressComponent类 参考final

#include <image_decompress.h>

类 apollo::image_decompress::ImageDecompressComponent 继承关系图:
apollo::image_decompress::ImageDecompressComponent 的协作图:

Public 成员函数

bool Init () override
 
bool Proc (const std::shared_ptr< apollo::drivers::CompressedImage > &image) override
 
- Public 成员函数 继承自 apollo::cyber::Component< apollo::drivers::CompressedImage >
 Component ()
 
 ~Component () override
 
bool Initialize (const ComponentConfig &config) override
 init the component by protobuf object.
 
bool Process (const std::shared_ptr< apollo::drivers::CompressedImage > &msg0, const std::shared_ptr< NullType > &msg1, const std::shared_ptr< NullType > &msg2, const std::shared_ptr< NullType > &msg3)
 
- Public 成员函数 继承自 apollo::cyber::ComponentBase
virtual ~ComponentBase ()
 
virtual bool Initialize (const TimerComponentConfig &config)
 
virtual void Shutdown ()
 
template<typename T >
bool GetProtoConfig (T *config) const
 

额外继承的成员函数

- Public 类型 继承自 apollo::cyber::ComponentBase
template<typename M >
using Reader = cyber::Reader< M >
 
- Protected 成员函数 继承自 apollo::cyber::ComponentBase
virtual void Clear ()
 
const std::string & ConfigFilePath () const
 
void LoadConfigFiles (const ComponentConfig &config)
 
void LoadConfigFiles (const TimerComponentConfig &config)
 
- Protected 属性 继承自 apollo::cyber::ComponentBase
std::atomic< bool > is_shutdown_ = {false}
 
std::shared_ptr< Nodenode_ = nullptr
 
std::string config_file_path_ = ""
 
std::vector< std::shared_ptr< ReaderBase > > readers_
 

详细描述

在文件 image_decompress.h28 行定义.

成员函数说明

◆ Init()

bool apollo::image_decompress::ImageDecompressComponent::Init ( )
overridevirtual

实现了 apollo::cyber::ComponentBase.

在文件 image_decompress.cc28 行定义.

28 {
29 if (!GetProtoConfig(&config_)) {
30 AERROR << "Parse config file failed: " << ConfigFilePath();
31 return false;
32 }
33 AINFO << "Decompress config: \n" << config_.DebugString();
34 writer_ = node_->CreateWriter<Image>(config_.channel_name());
35 return true;
36}
bool GetProtoConfig(T *config) const
const std::string & ConfigFilePath() const
std::shared_ptr< Node > node_
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42

◆ Proc()

bool apollo::image_decompress::ImageDecompressComponent::Proc ( const std::shared_ptr< apollo::drivers::CompressedImage > &  image)
override

在文件 image_decompress.cc38 行定义.

39 {
40 auto image = std::make_shared<Image>();
41 image->mutable_header()->CopyFrom(compressed_image->header());
42 if (compressed_image->has_measurement_time()) {
43 image->set_measurement_time(compressed_image->measurement_time());
44 } else {
45 image->set_measurement_time(compressed_image->header().timestamp_sec());
46 }
47 std::vector<uint8_t> compressed_raw_data(compressed_image->data().begin(),
48 compressed_image->data().end());
49 cv::Mat mat_image = cv::imdecode(compressed_raw_data, cv::IMREAD_COLOR);
50 cv::cvtColor(mat_image, mat_image, cv::COLOR_BGR2RGB);
51 image->set_width(mat_image.cols);
52 image->set_height(mat_image.rows);
53 // Now olny rgb
54 image->set_encoding("rgb8");
55 image->set_step(3 * image->width());
56
57 auto size = mat_image.step * mat_image.rows;
58 image->set_data(&(mat_image.data[0]), size);
59 writer_->Write(image);
60 return true;
61}

该类的文档由以下文件生成: