Apollo 10.0
自动驾驶开放平台
apollo::localization::msf::LosslessMapMatrix类 参考

#include <lossless_map_matrix.h>

类 apollo::localization::msf::LosslessMapMatrix 继承关系图:
apollo::localization::msf::LosslessMapMatrix 的协作图:

Public 成员函数

 LosslessMapMatrix ()
 
 ~LosslessMapMatrix ()
 
 LosslessMapMatrix (const LosslessMapMatrix &matrix)
 
virtual void Init (const BaseMapConfig *config)
 Initialize the map matrix.
 
virtual void Reset (const BaseMapConfig *config)
 Reset map cells data.
 
void Init (unsigned int rows, unsigned int cols)
 
void Reset (unsigned int rows, unsigned int cols)
 
virtual unsigned int LoadBinary (unsigned char *buf)
 Load the map cell from a binary chunk.
 
virtual unsigned int CreateBinary (unsigned char *buf, unsigned int buf_size) const
 Create the binary.
 
virtual unsigned int GetBinarySize () const
 Get the binary size of the object.
 
virtual void GetIntensityImg (cv::Mat *intensity_img) const
 get intensity image of node.
 
const LosslessMapCellGetMapCell (unsigned int row, unsigned int col) const
 Get a map cell.
 
LosslessMapCellGetMapCell (unsigned int row, unsigned int col)
 Get a map cell.
 
LosslessMapCelloperator[] (int row)
 
const LosslessMapCelloperator[] (int row) const
 
- Public 成员函数 继承自 apollo::localization::msf::BaseMapMatrix
 BaseMapMatrix ()
 The default constructor.
 
virtual ~BaseMapMatrix ()
 The deconstructor.
 
 BaseMapMatrix (const BaseMapMatrix &cell)
 The copy constructor.
 

Protected 属性

unsigned int rows_
 The number of rows.
 
unsigned int cols_
 The number of columns.
 
LosslessMapCellmap_cells_
 The matrix data structure.
 

详细描述

在文件 lossless_map_matrix.h143 行定义.

构造及析构函数说明

◆ LosslessMapMatrix() [1/2]

apollo::localization::msf::LosslessMapMatrix::LosslessMapMatrix ( )

在文件 lossless_map_matrix.cc261 行定义.

261 {
262 rows_ = 0;
263 cols_ = 0;
264 map_cells_ = nullptr;
265}
unsigned int cols_
The number of columns.
LosslessMapCell * map_cells_
The matrix data structure.

◆ ~LosslessMapMatrix()

apollo::localization::msf::LosslessMapMatrix::~LosslessMapMatrix ( )

在文件 lossless_map_matrix.cc267 行定义.

267 {
268 if (map_cells_) {
269 delete[] map_cells_;
270 }
271 rows_ = 0;
272 cols_ = 0;
273}

◆ LosslessMapMatrix() [2/2]

apollo::localization::msf::LosslessMapMatrix::LosslessMapMatrix ( const LosslessMapMatrix matrix)

在文件 lossless_map_matrix.cc275 行定义.

276 : BaseMapMatrix(matrix) {
277 Init(matrix.rows_, matrix.cols_);
278 for (unsigned int y = 0; y < rows_; ++y) {
279 for (unsigned int x = 0; x < cols_; ++x) {
280 map_cells_[y * cols_ + x] = matrix[y][x];
281 }
282 }
283}
virtual void Init(const BaseMapConfig *config)
Initialize the map matrix.

成员函数说明

◆ CreateBinary()

unsigned int apollo::localization::msf::LosslessMapMatrix::CreateBinary ( unsigned char *  buf,
unsigned int  buf_size 
) const
virtual

Create the binary.

Serialization of the object.

参数
<buf,buf_size>The buffer and its size.
<return>The required or the used size of is returned.

实现了 apollo::localization::msf::BaseMapMatrix.

在文件 lossless_map_matrix.cc334 行定义.

335 {
336 unsigned int target_size = GetBinarySize();
337 if (buf_size >= target_size) {
338 unsigned int* p = reinterpret_cast<unsigned int*>(buf);
339 *p = rows_;
340 ++p;
341 *p = cols_;
342 ++p;
343 buf_size -= static_cast<unsigned int>(sizeof(unsigned int) * 2);
344 unsigned char* pp = reinterpret_cast<unsigned char*>(p);
345 for (unsigned int y = 0; y < rows_; ++y) {
346 for (unsigned int x = 0; x < cols_; ++x) {
347 const LosslessMapCell& cell = GetMapCell(y, x);
348 unsigned int processed_size = cell.CreateBinary(pp, buf_size);
349 DCHECK_GE(buf_size, processed_size);
350 buf_size -= processed_size;
351 pp += processed_size;
352 }
353 }
354 }
355 return target_size;
356}
const LosslessMapCell & GetMapCell(unsigned int row, unsigned int col) const
Get a map cell.
virtual unsigned int GetBinarySize() const
Get the binary size of the object.

◆ GetBinarySize()

unsigned int apollo::localization::msf::LosslessMapMatrix::GetBinarySize ( ) const
virtual

Get the binary size of the object.

实现了 apollo::localization::msf::BaseMapMatrix.

在文件 lossless_map_matrix.cc358 行定义.

358 {
359 // default binary size
360 unsigned int target_size =
361 static_cast<unsigned int>(sizeof(unsigned int) * 2); // rows and cols
362 for (unsigned int y = 0; y < rows_; ++y) {
363 for (unsigned int x = 0; x < cols_; ++x) {
364 const LosslessMapCell& cell = GetMapCell(y, x);
365 target_size += cell.GetBinarySize();
366 }
367 }
368 return target_size;
369}

◆ GetIntensityImg()

void apollo::localization::msf::LosslessMapMatrix::GetIntensityImg ( cv::Mat *  intensity_img) const
virtual

get intensity image of node.

实现了 apollo::localization::msf::BaseMapMatrix.

在文件 lossless_map_matrix.cc371 行定义.

371 {
372 *intensity_img = cv::Mat(cv::Size(cols_, rows_), CV_8UC1);
373
374 for (uint32_t y = 0; y < rows_; ++y) {
375 for (uint32_t x = 0; x < cols_; ++x) {
376 intensity_img->at<unsigned char>(y, x) = GetMapCell(y, x).GetValue();
377 }
378 }
379}
void GetValue(std::vector< unsigned char > *values) const
Load the map cell from a binary chunk.

◆ GetMapCell() [1/2]

LosslessMapCell & apollo::localization::msf::LosslessMapMatrix::GetMapCell ( unsigned int  row,
unsigned int  col 
)
inline

Get a map cell.

在文件 lossless_map_matrix.h179 行定义.

179 {
180 DCHECK_LT(row, rows_);
181 DCHECK_LT(col, cols_);
182 return map_cells_[row * cols_ + col];
183 }

◆ GetMapCell() [2/2]

const LosslessMapCell & apollo::localization::msf::LosslessMapMatrix::GetMapCell ( unsigned int  row,
unsigned int  col 
) const
inline

Get a map cell.

在文件 lossless_map_matrix.h172 行定义.

173 {
174 DCHECK_LT(row, rows_);
175 DCHECK_LT(col, cols_);
176 return map_cells_[row * cols_ + col];
177 }

◆ Init() [1/2]

void apollo::localization::msf::LosslessMapMatrix::Init ( const BaseMapConfig config)
virtual

Initialize the map matrix.

实现了 apollo::localization::msf::BaseMapMatrix.

在文件 lossless_map_matrix.cc285 行定义.

285 {
286 unsigned int rows = config->map_node_size_y_;
287 unsigned int cols = config->map_node_size_x_;
288 if (rows_ == rows && cols_ == cols) {
289 return;
290 }
291 Init(rows, cols);
292}

◆ Init() [2/2]

void apollo::localization::msf::LosslessMapMatrix::Init ( unsigned int  rows,
unsigned int  cols 
)

在文件 lossless_map_matrix.cc298 行定义.

298 {
299 if (map_cells_) {
300 delete[] map_cells_;
301 map_cells_ = nullptr;
302 }
303 map_cells_ = new LosslessMapCell[rows * cols];
304 rows_ = rows;
305 cols_ = cols;
306}

◆ LoadBinary()

unsigned int apollo::localization::msf::LosslessMapMatrix::LoadBinary ( unsigned char *  buf)
virtual

Load the map cell from a binary chunk.

参数
<return>The size read (the real size of object).

实现了 apollo::localization::msf::BaseMapMatrix.

在文件 lossless_map_matrix.cc315 行定义.

315 {
316 unsigned int* p = reinterpret_cast<unsigned int*>(buf);
317 rows_ = *p;
318 ++p;
319 cols_ = *p;
320 ++p;
321 Init(rows_, cols_);
322
323 unsigned char* pp = reinterpret_cast<unsigned char*>(p);
324 for (unsigned int y = 0; y < rows_; ++y) {
325 for (unsigned int x = 0; x < cols_; ++x) {
326 LosslessMapCell& cell = GetMapCell(y, x);
327 unsigned int processed_size = cell.LoadBinary(pp);
328 pp += processed_size;
329 }
330 }
331 return GetBinarySize();
332}

◆ operator[]() [1/2]

LosslessMapCell * apollo::localization::msf::LosslessMapMatrix::operator[] ( int  row)
inline

在文件 lossless_map_matrix.h185 行定义.

185 {
186 return map_cells_ + row * cols_;
187 }

◆ operator[]() [2/2]

const LosslessMapCell * apollo::localization::msf::LosslessMapMatrix::operator[] ( int  row) const
inline

在文件 lossless_map_matrix.h188 行定义.

188 {
189 return map_cells_ + row * cols_;
190 }

◆ Reset() [1/2]

void apollo::localization::msf::LosslessMapMatrix::Reset ( const BaseMapConfig config)
virtual

Reset map cells data.

实现了 apollo::localization::msf::BaseMapMatrix.

在文件 lossless_map_matrix.cc294 行定义.

294 {
295 Reset(config->map_node_size_y_, config->map_node_size_x_);
296}
virtual void Reset(const BaseMapConfig *config)
Reset map cells data.

◆ Reset() [2/2]

void apollo::localization::msf::LosslessMapMatrix::Reset ( unsigned int  rows,
unsigned int  cols 
)

在文件 lossless_map_matrix.cc308 行定义.

308 {
309 unsigned int length = rows * cols;
310 for (unsigned int i = 0; i < length; ++i) {
311 map_cells_[i].Reset();
312 }
313}

类成员变量说明

◆ cols_

unsigned int apollo::localization::msf::LosslessMapMatrix::cols_
protected

The number of columns.

在文件 lossless_map_matrix.h196 行定义.

◆ map_cells_

LosslessMapCell* apollo::localization::msf::LosslessMapMatrix::map_cells_
protected

The matrix data structure.

在文件 lossless_map_matrix.h198 行定义.

◆ rows_

unsigned int apollo::localization::msf::LosslessMapMatrix::rows_
protected

The number of rows.

在文件 lossless_map_matrix.h194 行定义.


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