OptrisOptrisDocumentation

Documentation/OTC SDK/OTC SDK — C++ API referencev12.0

optris::sdk::ExternalBuffer

Describes an external buffer the SDK writes frame data into.

The consumer allocates the buffer (CPU, CUDA managed, DMA-BUF, etc.) and hands the SDK a pointer, and the SDK writes into it every frame.

This removes the copy on your side: the data arrives where your kernel already wants it, with no ThermalFrame to unpack and no second allocation to manage. It is not zero-copy end to end -- internally the frame is still built and then written out to your buffer.

On unified-memory systems (Jetson) a cudaMallocManaged pointer works directly. On discrete GPU systems the consumer would use a pinned host buffer or handle the upload themselves.

This example is CUDA, not plain C++: it needs nvcc and a Jetson. The SDK calls are the same everywhere; only the allocation and the kernel launch are CUDA.

// Jetson: allocate unified memory, SDK writes thermal float32
float *gpu_buf;
cudaMallocManaged(&gpu_buf, w * h * sizeof(float));

optris::sdk::ExternalBuffer ext;
ext.data = gpu_buf;
ext.size = w * h * sizeof(float);
ext.format = optris::sdk::ExternalPixelFormat::kThermalFloat32;
ext.on_written = [&](const optris::sdk::ExternalBuffer &buf) {
  // buf.data is ready; launch inference kernel
  RunModel<<<...>>>(reinterpret_cast<float *>(buf.data),
                    buf.width, buf.height);
};
// Throws if the buffer is too small for the format and geometry.
imager->Buffers().Add(ext);

Public attributes

data

void * data = nullptr

Pointer to the output buffer. Must remain valid while registered. The SDK writes frame data here every frame.

size

size_t size = 0

Size of the buffer in bytes. The SDK validates this against width * height * bytes_per_pixel before writing.

format

ExternalPixelFormat format = ExternalPixelFormat::kThermalFloat32

Pixel format the SDK should write.

width

uint32_t width = 0

Frame dimensions (filled by the SDK after registration).

height

uint32_t height = 0

on_written

std::function< void(const ExternalBuffer &)> on_written

Called on the processing thread after the SDK has written a new frame into the buffer. The pointer is valid for the duration of this call. If null, the consumer polls via Imager::AcquireFrame() or their own synchronization.

It fires only when the frame really was written. Every format but ExternalPixelFormat::kEnergyInt32 writes on every frame, so in practice this is per frame; an energy buffer on a source with no energy stage -- a recording -- is silent rather than being announced over contents the SDK deliberately left alone. A consumer must not treat the buffer as fresh without this call.