serialization_test.cpp
Go to the documentation of this file.
1 #include <catch2/catch_all.hpp>
2 
3 // Include depthai library
4 #include <depthai/depthai.hpp>
5 
6 TEST_CASE("Roundtrip") {
8  auto stereo = p.create<dai::node::StereoDepth>();
9 
10  // Create ground truth properties
11  stereo->setInputResolution(0xa0a0a0a0, 0xa0a0a0a0);
12  stereo->setOutputSize(0x55555555, 0x55555555);
13  stereo->setExtendedDisparity(true);
14  stereo->properties.numFramesPool = 42;
15 
16  // Round trip
17  {
18  auto ser = dai::utility::serialize(stereo->properties);
20  dai::utility::deserialize(ser, des);
21  for(uint8_t b : ser) {
22  printf("%02X ", b);
23  }
24  printf("\n");
25 
26  REQUIRE(des.width.value() == (int)0xa0a0a0a0);
27  REQUIRE(des.height.value() == (int)0xa0a0a0a0);
28  REQUIRE(des.outWidth.value() == (int)0x55555555);
29  REQUIRE(des.outHeight.value() == (int)0x55555555);
30  REQUIRE(des.numFramesPool == 42);
31  }
32 
33  // Round trip through pipeline
34  {
35  auto ser = p.getPipelineSchema().nodes[0].properties;
37  dai::utility::deserialize(ser, des);
38  for(uint8_t b : ser) {
39  printf("%02X ", b);
40  }
41  printf("\n");
42 
43  REQUIRE(des.width.value() == (int)0xa0a0a0a0);
44  REQUIRE(des.height.value() == (int)0xa0a0a0a0);
45  REQUIRE(des.outWidth.value() == (int)0x55555555);
46  REQUIRE(des.outHeight.value() == (int)0x55555555);
47  REQUIRE(des.numFramesPool == 42);
48  }
49 }
tl::optional::value
TL_OPTIONAL_11_CONSTEXPR T & value() &
Returns the contained value if there is one, otherwise throws bad_optional_access.
Definition: 3rdparty/tl/optional.hpp:1289
dai::Pipeline
Represents the pipeline, set of nodes and connections between them.
Definition: Pipeline.hpp:100
dai::node::StereoDepth
StereoDepth node. Compute stereo disparity and depth from left-right image pair.
Definition: StereoDepth.hpp:15
dai::StereoDepthProperties::height
tl::optional< std::int32_t > height
Definition: StereoDepthProperties.hpp:72
dai::StereoDepthProperties::width
tl::optional< std::int32_t > width
Definition: StereoDepthProperties.hpp:68
dai::utility::serialize
bool serialize(const T &obj, std::vector< std::uint8_t > &data)
Definition: Serialization.hpp:38
dai::StereoDepthProperties
Definition: StereoDepthProperties.hpp:14
dai::PipelineSchema::nodes
std::unordered_map< int64_t, NodeObjInfo > nodes
Definition: PipelineSchema.hpp:16
dai::utility::deserialize
bool deserialize(const std::uint8_t *data, std::size_t size, T &obj)
Definition: Serialization.hpp:44
depthai.hpp
TEST_CASE
TEST_CASE("Roundtrip")
Definition: serialization_test.cpp:6
dai::Pipeline::create
std::shared_ptr< N > create()
Definition: Pipeline.hpp:145
dai::StereoDepthProperties::outHeight
tl::optional< std::int32_t > outHeight
Definition: StereoDepthProperties.hpp:80
dai::Pipeline::getPipelineSchema
PipelineSchema getPipelineSchema(SerializationType type=DEFAULT_SERIALIZATION_TYPE) const
Definition: Pipeline.cpp:54
dai::node::StereoDepth::setInputResolution
void setInputResolution(int width, int height)
Definition: StereoDepth.cpp:88
dai::StereoDepthProperties::numFramesPool
int numFramesPool
Num frames in output pool.
Definition: StereoDepthProperties.hpp:102
dai::StereoDepthProperties::outWidth
tl::optional< std::int32_t > outWidth
Definition: StereoDepthProperties.hpp:76


depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:19