RawBuffer Struct Referencefinal

Zero-copy wrapper for native camera capture buffers. More...

Functions

 RawBuffer ()
 Default constructor. More...
 
 ~RawBuffer ()
 Destructor - automatically releases the buffer. More...
 
 RawBuffer (RawBuffer &&other) noexcept
 
RawBufferoperator= (RawBuffer &&other) noexcept
 
 RawBuffer (const RawBuffer &)=delete
 
RawBufferoperator= (const RawBuffer &)=delete
 
RAW_BUFFER_TYPE getType () const
 Get the type of the raw buffer. More...
 
void * getRawBuffer () const
 Get the left camera NvBufSurface pointer. More...
 
void * getRawBufferRight () const
 Get the right camera NvBufSurface pointer. More...
 
uint64_t getTimestamp () const
 Get the timestamp of the buffer. More...
 
unsigned int getWidth () const
 Get the width of the image. More...
 
unsigned int getHeight () const
 Get the height of the image. More...
 
bool isValid () const
 Check if the buffer is valid and contains data. More...
 
void release ()
 Manually release the buffer reference. More...
 

Detailed Description

Zero-copy wrapper for native camera capture buffers.

This structure provides access to the raw NvBufSurface buffer without copying data. The buffer is automatically released when the RawBuffer goes out of scope or when release() is called, allowing the camera pipeline to reuse the buffer for the next capture.

Warning
Enabled by defining SL_ENABLE_ADVANCED_CAPTURE_API before including this header. Improper use can crash the Argus stack or destabilize the system. The RawBuffer does not free the underlying memory; it only releases the reference so that the capture system can reuse it.
DO NOT manually destroy the NvBufSurface (e.g., do not call NvBufSurfaceDestroy, NvBufSurfaceUnMap, etc.). The buffers are owned and managed by the SDK. Manual destruction will cause crashes or undefined behavior.
Note
Currently only supports NVBUFSURFACE type (Argus native buffers).
#define SL_ENABLE_ADVANCED_CAPTURE_API
#include <sl/Camera.hpp>
Camera zed;
InitParameters init_params;
zed.open(init_params);
while (true) {
if (zed.grab() == ERROR_CODE::SUCCESS) {
RawBuffer raw;
if (zed.retrieveImage(raw) == ERROR_CODE::SUCCESS) {
// Get NvBufSurface pointer directly
void* nvbufLeft = raw.getRawBuffer(); // Returns left NvBufSurface
void* nvbufRight = raw.getRawBufferRight(); // Returns right NvBufSurface
// Cast to NvBufSurface* and use with Argus/NVMM APIs
// auto* surf = static_cast<NvBufSurface*>(nvbufLeft);
// raw is automatically released when going out of scope
}
}
}
friend class Camera
Definition: Camera.hpp:1496
RawBuffer()
Default constructor.

Constructor and Destructor

◆ RawBuffer() [1/3]

RawBuffer ( )

Default constructor.

◆ ~RawBuffer()

~RawBuffer ( )

Destructor - automatically releases the buffer.

◆ RawBuffer() [2/3]

RawBuffer ( RawBuffer &&  other)
noexcept

◆ RawBuffer() [3/3]

RawBuffer ( const RawBuffer )
delete

Functions

◆ operator=() [1/2]

RawBuffer& operator= ( RawBuffer &&  other)
noexcept

◆ operator=() [2/2]

RawBuffer& operator= ( const RawBuffer )
delete

◆ getType()

RAW_BUFFER_TYPE getType ( ) const

Get the type of the raw buffer.

Returns
The buffer type (currently only NVBUFSURFACE is supported).

◆ getRawBuffer()

void* getRawBuffer ( ) const

Get the left camera NvBufSurface pointer.

Returns
Pointer to the left NvBufSurface, or nullptr if not valid.
Note
Cast to NvBufSurface* to use with Argus/NVMM APIs.
Warning
DO NOT destroy this buffer (e.g., do not call NvBufSurfaceDestroy). The buffer is owned by the SDK.

◆ getRawBufferRight()

void* getRawBufferRight ( ) const

Get the right camera NvBufSurface pointer.

Returns
Pointer to the right NvBufSurface, or nullptr if not valid.
Note
Cast to NvBufSurface* to use with Argus/NVMM APIs.
Warning
DO NOT destroy this buffer (e.g., do not call NvBufSurfaceDestroy). The buffer is owned by the SDK.

◆ getTimestamp()

uint64_t getTimestamp ( ) const

Get the timestamp of the buffer.

Returns
Timestamp in nanoseconds.

◆ getWidth()

unsigned int getWidth ( ) const

Get the width of the image.

Returns
Width in pixels.

◆ getHeight()

unsigned int getHeight ( ) const

Get the height of the image.

Returns
Height in pixels.

◆ isValid()

bool isValid ( ) const

Check if the buffer is valid and contains data.

Returns
true if the buffer is valid.

◆ release()

void release ( )

Manually release the buffer reference.

This allows the capture system to reuse the buffer. After calling this, the buffer is no longer valid.

Note
The buffer is automatically released when RawBuffer is destroyed.