CARLA
 
载入中...
搜索中...
未找到
NormalsImageSerializer.h
浏览该文件的文档.
1//
2// Created by flo on 09.11.20.
3//
4
5#pragma once
6
7#include "carla/Memory.h"
9
10#include <cstdint>
11#include <cstring>
12
13namespace carla {
14 namespace sensor {
15
16 class SensorData;
17
18 namespace s11n {
19
20 /// Serializes image buffers generated by camera sensors.
22 public:
23
24#pragma pack(push, 1)
25 struct ImageHeader {
26 uint32_t width;
27 uint32_t height;
28 float fov_angle;
29 };
30#pragma pack(pop)
31
32 constexpr static auto header_offset = sizeof(ImageHeader);
33
34 static const ImageHeader &DeserializeHeader(const RawData &data) {
35 return *reinterpret_cast<const ImageHeader *>(data.begin());
36 }
37
38 template <typename Sensor>
39 static Buffer Serialize(const Sensor &sensor, Buffer &&bitmap);
40
42 };
43
44 template <typename Sensor>
45 inline Buffer NormalsImageSerializer::Serialize(const Sensor &sensor, Buffer &&bitmap) {
46 DEBUG_ASSERT(bitmap.size() > sizeof(ImageHeader));
47 ImageHeader header = {
48 sensor.GetImageWidth(),
49 sensor.GetImageHeight(),
50 sensor.GetFOVAngle()
51 };
52 std::memcpy(bitmap.data(), reinterpret_cast<const void *>(&header), sizeof(header));
53 return std::move(bitmap);
54 }
55
56 } // namespace s11n
57 } // namespace sensor
58} // namespace carla
#define DEBUG_ASSERT(predicate)
Definition Debug.h:66
A piece of raw data.
Wrapper around the raw data generated by a sensor plus some useful meta-information.
Definition RawData.h:21
auto begin() noexcept
Begin iterator to the data generated by the sensor.
Definition RawData.h:52
Serializes image buffers generated by camera sensors.
static const ImageHeader & DeserializeHeader(const RawData &data)
static SharedPtr< SensorData > Deserialize(RawData &&data)
static Buffer Serialize(const Sensor &sensor, Buffer &&bitmap)
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
Definition Memory.h:20