dora-image-view takes std/media/v1/Image, and dora's compatibility graph has no edge from std/core/v1/UInt8 to it, so wiring the two failed `dora validate` whatever the node actually sent. Its flat-buffer fallback would not have decoded these frames either: it reads width/height metadata, and this node only published shape. image and depth now go out as the Image struct, camera_info and point_cloud as Float32 arrays and camera_state as a string, all built against the Arrow C data interface in src/arrow so the node still links no Arrow C++. Shape, dtype and encoding metadata are dropped where the payload describes itself; intrinsics, frame_id and both timestamps are unchanged. tests/run.sh covers the packing without a camera or the SDK, round-tripping each array through pyarrow and rebuilding it under the sanitizers. Breaking: image_bgr is renamed to image and every payload changes shape. dataflow_plot.yml is replaced by dataflow_view.yml, which wires the viewer from a tag and repeats its contract in input_types so validate checks both sides of the wiring.
55 lines
1.7 KiB
C++
55 lines
1.7 KiB
C++
// Release has to free the whole tree: the array nodes, the schema nodes, and
|
|
// the storage their buffers point into. Nothing here asserts that directly -
|
|
// the sanitizers tests/run.sh builds this with are the assertion, and a node
|
|
// that leaks per frame is a node that dies on a long run.
|
|
|
|
#include "arrow/array.h"
|
|
|
|
#include <cassert>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace {
|
|
|
|
void release(arrow_c::Exported& exported) {
|
|
exported.array.release(&exported.array);
|
|
exported.schema.release(&exported.schema);
|
|
|
|
// A released struct marks itself, which is how a consumer knows not to
|
|
// release it twice.
|
|
assert(exported.array.release == nullptr);
|
|
assert(exported.schema.release == nullptr);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main() {
|
|
const std::vector<uint8_t> pixels(4 * 4 * 3, 7);
|
|
const std::vector<float> depth(4 * 4, 1500.0F);
|
|
const std::string state = "streaming";
|
|
|
|
for (int i = 0; i < 100; ++i) {
|
|
arrow_c::Exported image =
|
|
arrow_c::image(4, 4, "bgr8", pixels.data(), pixels.size());
|
|
assert(image.array.length == 1);
|
|
assert(image.array.n_children == 4);
|
|
release(image);
|
|
|
|
arrow_c::Exported depth_image =
|
|
arrow_c::image(4, 4, "32FC1", reinterpret_cast<const uint8_t*>(depth.data()),
|
|
depth.size() * sizeof(float));
|
|
release(depth_image);
|
|
|
|
arrow_c::Exported values = arrow_c::float32(depth.data(), depth.size());
|
|
assert(values.array.length == static_cast<int64_t>(depth.size()));
|
|
release(values);
|
|
|
|
arrow_c::Exported text = arrow_c::string(state.data(), state.size());
|
|
assert(text.array.length == 1);
|
|
release(text);
|
|
}
|
|
|
|
return 0;
|
|
}
|