get_segmentation_masks

pyds.get_segmentation_masks(data: capsule) array

This function returns the inferred masks in Numpy format in the height X width shape, these height and width are obtained from the NvDsInferSegmentationMeta.

Parameters

data – An object of type NvDsInferSegmentationMeta

get_optical_flow_vectors

pyds.get_optical_flow_vectors(data: capsule) numpy.ndarray[float32]
Parameters

of_meta – An object of type NvDsOpticalFlowMeta

Returns

Interleaved x, y directed optical flow vectors for a block of pixels in numpy format with shape (rows,cols,2), where rows and cols are the Optical flow outputs. These rows and cols are not equivalent to input resolution.

get_nvds_buf_surface

pyds.get_nvds_buf_surface(gst_buffer: int, batchID: int) array

This function returns the frame in NumPy format. Only RGBA format is supported. For x86_64, only unified memory is supported. For Jetson, the buffer is mapped to CPU memory. Changes to the frame image will be preserved and seen in downstream elements, with the following restrictions. 1. No change to image color format or resolution 2. No transpose operation on the array.

Parameters
  • gst_buffer – address of the Gstbuffer which contains NvBufSurface

  • batchID – batch_id of the frame to be processed. This indicates the frame’s index within NvBufSurface

nvds_acquire_meta_lock

pyds.nvds_acquire_meta_lock(batch_meta: pyds.NvDsBatchMeta) None

Acquire the lock before updating metadata.

Parameters

batch_meta – An object of type NvDsBatchMeta

nvds_release_meta_lock

pyds.nvds_release_meta_lock(batch_meta: pyds.NvDsBatchMeta) None

Release lock after updating metadata.

Parameters

batch_meta – An object of type NvDsBatchMeta

nvds_create_batch_meta

pyds.nvds_create_batch_meta(max_batch_size: int) pyds.NvDsBatchMeta

Creates a NvDsBatchMeta of given batch size.

Parameters

max_batch_size – maximum number of frames those can be present in the batch

Returns

Allocated NvDsBatchMeta object

nvds_destroy_batch_meta

pyds.nvds_destroy_batch_meta(batch_meta: pyds.NvDsBatchMeta) int

Deletes/Releases given NvDsBatchMeta batch_meta object.

Parameters

batch_meta – An object of type NvDsBatchMeta to be deleted/destroyed after use

nvds_acquire_frame_meta_from_pool

pyds.nvds_acquire_frame_meta_from_pool(batch_meta: pyds.NvDsBatchMeta) pyds.NvDsFrameMeta

Acquires NvDsFrameMeta from frame_meta pool. User must acquire the frame_meta from frame_meta pool to fill frame metadata.

Parameters

batch_meta – An object of type NvDsBatchMeta from which NvDsFrameMeta will be acquired

Returns

Acquired NvDsFrameMeta object from frame meta pool

nvds_add_frame_meta_to_batch

pyds.nvds_add_frame_meta_to_batch(batch_meta: pyds.NvDsBatchMeta, frame_meta: pyds.NvDsFrameMeta) None

After acquiring and filling frame metadata, user must add it to the batch metadata with this API.

Parameters

nvds_remove_frame_meta_from_batch

pyds.nvds_remove_frame_meta_from_batch(batch_meta: pyds.NvDsBatchMeta, frame_meta: pyds.NvDsFrameMeta) None

Removes given frame meta from the batch metadata.

Parameters
  • batch_meta – An object of type NvDsBatchMeta from which frame_meta is to be removed.

  • frame_meta – A object of type NvDsFrameMeta to be removed from batch_meta.

nvds_acquire_obj_meta_from_pool

pyds.nvds_acquire_obj_meta_from_pool(batch_meta: pyds.NvDsBatchMeta) pyds.NvDsObjectMeta

Acquires NvDsObjectMeta from the object meta pool. User must acquire the object meta from the object meta pool to fill object metadata.

Parameters

batch_meta – An object of type NvDsBatchMeta from which NvDsObjectMeta will be acquired

Returns

Acquired NvDsObjectMeta object from object meta pool

nvds_remove_obj_meta_from_frame

pyds.nvds_remove_obj_meta_from_frame(frame_meta: pyds.NvDsFrameMeta, obj_meta: pyds.NvDsObjectMeta) None

Removes given object meta from the frame metadata.

Parameters
  • frame_meta – An object of type NvDsFrameMeta from which obj_meta is to be removed.

  • obj_meta – An object of type NvDsObjectMeta to be removed from frame_meta.

nvds_acquire_classifier_meta_from_pool

pyds.nvds_acquire_classifier_meta_from_pool(batch_meta: pyds.NvDsBatchMeta) pyds.NvDsClassifierMeta

Acquires NvDsClassifierMeta from the classifier meta pool. User must acquire the classifier meta from the classifier meta pool to fill classifier metadata.

Parameters

batch_meta – An object of type NvDsBatchMeta from which NvDsClassifierMeta will be acquired

Returns

Acquired NvDsClassifierMeta object from classifier meta pool

nvds_add_classifier_meta_to_object

pyds.nvds_add_classifier_meta_to_object(obj_meta: pyds.NvDsObjectMeta, classifier_meta: pyds.NvDsClassifierMeta) None

After acquiring and filling classifier metadata user must add it to the object metadata with this API.

Parameters

nvds_remove_classifier_meta_from_obj

pyds.nvds_remove_classifier_meta_from_obj(obj_meta: pyds.NvDsObjectMeta, classifier_meta: pyds.NvDsClassifierMeta) None

Removes given classifier meta from object metadata.

Parameters
  • obj_meta – An object of type NvDsObjectMeta from which classifier_meta is to be removed.

  • classifier_meta – An object of type NvDsClassifierMeta to be removed from obj_meta.

nvds_acquire_display_meta_from_pool

pyds.nvds_acquire_display_meta_from_pool(batch_meta: pyds.NvDsBatchMeta) pyds.NvDsDisplayMeta

Acquires NvDsDisplayMeta from the display meta pool. User must acquire the display meta from the display meta pool to fill display metadata.

Parameters

batch_meta – An object of type NvDsBatchMeta from which NvDsDisplayMeta will be acquired.

Returns

Acquired NvDsDisplayMeta object from display meta pool

nvds_add_display_meta_to_frame

pyds.nvds_add_display_meta_to_frame(frame_meta: pyds.NvDsFrameMeta, display_meta: pyds.NvDsDisplayMeta) None

After acquiring and filling classifier metadata user must add it to the frame metadata with this API.

Parameters

nvds_remove_display_meta_from_frame

pyds.nvds_remove_display_meta_from_frame(frame_meta: pyds.NvDsFrameMeta, display_meta: pyds.NvDsDisplayMeta) None

Removes given display meta from frame metadata.

Parameters
  • frame_meta – An object of type NvDsFrameMeta from which display_meta is to be removed.

  • display_meta – An object of type NvDsDisplayMeta to be removed from frame_meta.

nvds_acquire_label_info_meta_from_pool

pyds.nvds_acquire_label_info_meta_from_pool(batch_meta: pyds.NvDsBatchMeta) pyds.NvDsLabelInfo

Acquires NvDsLabelInfo from the labelinfo meta pool of given NvDsBatchMeta. User must acquire the labelinfo meta from the labelinfo meta pool to fill labelinfo metadata.

Parameters

batch_meta – An object of type NvDsBatchMeta from which NvDsLabelInfo will be acquired

Returns

An object of type NvDsLabelInfo object from label info meta pool

nvds_add_label_info_meta_to_classifier

pyds.nvds_add_label_info_meta_to_classifier(classifier_meta: pyds.NvDsClassifierMeta, label_info_meta: pyds.NvDsLabelInfo) None

After acquiring and filling labelinfo metadata user must add it to the classifier metadata with this API.

Parameters

nvds_remove_label_info_meta_from_classifier

pyds.nvds_remove_label_info_meta_from_classifier(classifier_meta: pyds.NvDsClassifierMeta, label_info_meta: pyds.NvDsLabelInfo) None

Removes given labelinfo meta from the classifier metadata

Parameters
  • classifier_meta – An object of type NvDsClassifierMeta from which label_info_meta is to be removed.

  • label_info_meta – An object of type NvDsLabelInfo to be removed from classifier_meta.

nvds_add_user_meta_to_batch

pyds.nvds_add_user_meta_to_batch(batch_meta: pyds.NvDsBatchMeta, user_meta: pyds.NvDsUserMeta) None

After acquiring and filling user metadata user must add it to batch metadata if required at batch level with this API.

Parameters

nvds_add_user_meta_to_frame

pyds.nvds_add_user_meta_to_frame(frame_meta: pyds.NvDsFrameMeta, user_meta: pyds.NvDsUserMeta) None

After acquiring and filling user metadata user must add it to frame metadata if required at frame level with this API.

Parameters

nvds_add_user_meta_to_obj

pyds.nvds_add_user_meta_to_obj(obj_meta: pyds.NvDsObjectMeta, user_meta: pyds.NvDsUserMeta) None

After acquiring and filling user metadata user must add it to object metadata if required at object level with this API.

Parameters

nvds_acquire_user_meta_from_pool

pyds.nvds_acquire_user_meta_from_pool(batch_meta: pyds.NvDsBatchMeta) pyds.NvDsUserMeta

Acquires NvDsUserMeta from the user meta pool. User must acquire the user meta from the user meta pool to fill user metadata.

Parameters

batch_meta – An object of type NvDsBatchMeta from which NvDsUserMeta will be acquired

nvds_remove_user_meta_from_batch

pyds.nvds_remove_user_meta_from_batch(batch_meta: pyds.NvDsBatchMeta, user_meta: pyds.NvDsUserMeta) None

Removes given user metadata from the batch metadata.

Parameters
  • batch_meta – An object of type NvDsBatchMeta from which user_meta is to be removed.

  • user_meta – An object of type NvDsUserMeta to be removed from batch_meta.

Returns

Acquired NvDsUserMeta object from user meta pool

nvds_remove_user_meta_from_frame

pyds.nvds_remove_user_meta_from_frame(frame_meta: pyds.NvDsFrameMeta, user_meta: pyds.NvDsUserMeta) None

Removes given user metadata from the frame metadata.

Parameters
  • frame_meta – An object of type NvDsFrameMeta from which user_meta is to be removed.

  • user_meta – An object of type NvDsUserMeta to be removed from frame_meta.

nvds_remove_user_meta_from_object

pyds.nvds_remove_user_meta_from_object(obj_meta: pyds.NvDsObjectMeta, user_meta: pyds.NvDsUserMeta) None

Removes given user metadata from the object metadata.

Parameters
  • obj_meta – An object of type NvDsObjectMeta from which user_meta s to be removed.

  • user_meta – An object of type NvDsUserMeta to be removed from obj_meta.

nvds_get_current_metadata_info

pyds.nvds_get_current_metadata_info(batch_meta: pyds.NvDsBatchMeta) int

Debug function to get current metadata info.

Parameters

batch_meta – An object of type NvDsBatchMeta

nvds_batch_meta_copy_func

pyds.nvds_batch_meta_copy_func(data: capsule, user_meta: capsule) capsule

Copy function to copy batch_meta. It is called when meta_data needs to copied / transformed from one buffer to other. meta_data and user_data are passed as arguments.

Parameters
  • data – An object of type NvDsBatchMeta

  • user_data – An object of user specific data

Returns

An object that can be typecasted tot NvDsBatchMeta

nvds_batch_meta_release_func

pyds.nvds_batch_meta_release_func(data: capsule, user_data: capsule) None

batch_meta release function called when meta_data is going to be released.

Parameters
  • data – An object of type NvDsBatchMeta

  • user_data – An object of user specific data

nvds_get_nth_frame_meta

pyds.nvds_get_nth_frame_meta(frame_meta_list: pyds.GList, index: int) pyds.NvDsFrameMeta

Retrieve the NvDsFrameMeta object of the frame at index.

Parameters
Returns

An object of type NvDsFrameMeta from frame_meta_list

nvds_clear_frame_meta_list

nvds_clear_obj_meta_list

pyds.nvds_clear_obj_meta_list(frame_meta: pyds.NvDsFrameMeta, meta_list: pyds.GList) None

Removes all the object metadata present in the frame metadata.

Parameters
  • frame_meta – An object of type NvDsFrameMeta from which NvDsObjectMetaList needs to be cleared

  • meta_list – An object of type NvDsObjectMetaList which needs to be cleared

nvds_clear_display_meta_list

pyds.nvds_clear_display_meta_list(frame_meta: pyds.NvDsFrameMeta, meta_list: pyds.GList) None

Removes all the display metadata present in the frame metadata.

Parameters
  • frame_meta – An object of type NvDsFrameMeta from which NvDisplayMetaList needs to be cleared

  • meta_list – An object of type NvDisplayMetaList which needs to be cleared

nvds_clear_batch_user_meta_list

pyds.nvds_clear_batch_user_meta_list(batch_meta: pyds.NvDsBatchMeta, meta_list: pyds.GList) None

Removes all the user metadata present in the batch metadata

Parameters
  • batch_meta – An object of type NvDsBatchMeta from which NvDsUserMetaList needs to be cleared

  • meta_list – An object of type NvDsUserMetaList which needs to be cleared

nvds_clear_frame_user_meta_list

pyds.nvds_clear_frame_user_meta_list(frame_meta: pyds.NvDsFrameMeta, meta_list: pyds.GList) None

Removes all the user metadata present in the frame metadata

Parameters
  • frame_meta – An object of type NvDsFrameMeta from which NvDsUserMetaList needs to be cleared

  • meta_list – An object of type NvDsUserMetaList which needs to be cleared

nvds_clear_obj_user_meta_list

pyds.nvds_clear_obj_user_meta_list(object_meta: pyds.NvDsObjectMeta, meta_list: pyds.GList) None

Removes all the user metadata present in the object metadata

Parameters
  • object_meta – An object of type NvDsObjectMeta from which NvDsUserMetaList needs to be cleared

  • meta_list – An object of type NvDsUserMetaList which needs to be cleared

nvds_clear_meta_list

pyds.nvds_clear_meta_list(batch_meta: pyds.NvDsBatchMeta, meta_list: pyds.GList, meta_pool: pyds.NvDsMetaPool) pyds.GList

Removes all the metadata elements present in the given metadata list

Parameters
  • batch_meta – An object of type NvDsBatchMeta

  • meta_list – An object of type NvDsMetaList which needs to be cleared

  • meta_pool – An object of type NvDsMetaPool to which list belongs to

Returns

An object of updated meta list

nvds_copy_batch_user_meta_list

pyds.nvds_copy_batch_user_meta_list(src_user_meta_list: pyds.GList, dst_batch_meta: pyds.NvDsBatchMeta) None

Deep copy of src_user_meta_list to user meta list present in the dst_batch_meta.

Parameters
  • src_user_meta_list – An obect of type NvDsUserMetaList

  • dst_batch_meta – An object of type NvDsBatchMeta

nvds_copy_frame_user_meta_list

pyds.nvds_copy_frame_user_meta_list(src_user_meta_list: pyds.GList, dst_frame_meta: pyds.NvDsFrameMeta) None

Deep copy of src_user_meta_list to user meta list present in the dst_frame_meta.

Parameters
  • src_user_meta_list – An object of type NvDsUserMetaList

  • dst_frame_meta – An object of type NvDsFrameMeta

nvds_copy_display_meta_list

pyds.nvds_copy_display_meta_list(src_display_meta: pyds.GList, dst_frame_meta: pyds.NvDsFrameMeta) None

Deep copy of src_display_meta_list to display meta list present in the dst_frame_meta.

Parameters
  • src_display_meta_list – An object of type NvDisplayMetaList

  • dst_frame_meta – An object of type NvDsFrameMeta

nvds_copy_frame_meta_list

pyds.nvds_copy_frame_meta_list(src_frame_meta_list: pyds.GList, dst_batch_meta: pyds.NvDsBatchMeta) None

Deep copy of src_frame_meta_list to frame meta list present in the dst_batch_meta.

Parameters
  • src_frame_meta_list – An object of type NvDsFrameMetaList

  • dst_batch_meta – An object of type NvDsBatchMeta

nvds_get_user_meta_type

pyds.nvds_get_user_meta_type(meta_descriptor: str) pyds.NvDsMetaType

Generates a unique user metadata type from the given string describing user specific metadata.

Parameters

meta_descriptor – A string object describing metadata.

The format of the string should be specified as below:

ORG_NAME.COMPONENT_NAME.METADATA_DESCRIPTION.

e.g. (NVIDIA.NVINFER.TENSOR_METADATA)

nvds_copy_obj_meta_list

pyds.nvds_copy_obj_meta_list(src_obj_meta_list: pyds.GList, dst_object_meta: pyds.NvDsFrameMeta) None

Deep copy of src_obj_meta_list to frame meta list present in the dst_frame_meta.

Parameters
  • src_obj_meta_list – An object of type NvDsObjectMetaList

  • dst_frame_meta – An object of type NvDsFrameMeta

nvds_get_user_meta_type

pyds.nvds_get_user_meta_type(meta_descriptor: str) pyds.NvDsMetaType

Generates a unique user metadata type from the given string describing user specific metadata.

Parameters

meta_descriptor – A string object describing metadata.

The format of the string should be specified as below:

ORG_NAME.COMPONENT_NAME.METADATA_DESCRIPTION.

e.g. (NVIDIA.NVINFER.TENSOR_METADATA)

gst_buffer_add_nvds_meta

pyds.gst_buffer_add_nvds_meta(buffer: _GstBuffer, meta_data: capsule, user_data: capsule, copy_func: void* (void*, void*), release_func: void (void*, void*)) _NvDsMeta

Adds GstMeta of type NvDsMeta to the GstBuffer and sets the meta_data member of NvDsMeta.

Parameters
  • buffer – GstBuffer to which the function adds metadata.

  • meta_data – The object to which the function sets the meta_data member of NvDsMeta.

  • user_data – A user specific data object

  • copy_func – The NvDsMetaCopyFunc function to be called when NvDsMeta is to be copied. The function is called with meta_data and user_data as parameters. NvDsMeta is to be destroyed. The function is called with meta_data and user_data as parameters.

Returns

An object to the attached NvDsMeta object; or NONE in case failure

gst_buffer_get_nvds_batch_meta

pyds.gst_buffer_get_nvds_batch_meta(buffer: int) pyds.NvDsBatchMeta

Gets the NvDsBatchMeta added to the GstBuffer.

Parameters

buffer – GstBuffer from which to retrieve the NvDsBatchMeta

Returns

NvDsBatchMeta object retrieved from the buffer

For example: batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))

user_copyfunc

pyds.user_copyfunc(meta: pyds.NvDsUserMeta, func: Callable[[capsule, capsule], capsule]) None

Set copy callback function of given NvDsUserMeta object.

Parameters
  • metaNvDsUserMeta of which to set copy function

  • func – User-written copy function

user_releasefunc

pyds.user_releasefunc(meta: pyds.NvDsUserMeta, func: Callable[[capsule, capsule], None]) None

Set release callback function of given NvDsUserMeta object.

Parameters
  • metaNvDsUserMeta of which to set release function

  • func – User-written release function

alloc_buffer

pyds.alloc_buffer(size: int) int

Allocate buffer of given size.

Parameters

size – Size of memory to be allocated

Returns

C address of allocated buffer

free_buffer

pyds.free_buffer(buffer: int) None

Frees memory of given buffer.

Parameters

buffer – C address of the buffer to be freed

free_gbuffer

pyds.free_gbuffer(buffer: capsule) None

Frees memory of given gbuffer.

Parameters

buffer – gpointer to the buffer to be freed

get_string

pyds.get_string(ptr: int) str

Cast given pointer to string.

Parameters

ptr – C address of the string

Returns

Reference to the string object

get_ptr

pyds.get_ptr(ptr: capsule) int

Gets the C address of given object.

Parameters

ptr – Object of which to retrieve C address “pointer”

Returns

C address of given data

alloc_nvds_vehicle_object

pyds.alloc_nvds_vehicle_object() pyds.NvDsVehicleObject

Allocate an NvDsVehicleObject.

Returns

Allocated NvDsVehicleObject

alloc_nvds_person_object

pyds.alloc_nvds_person_object() pyds.NvDsPersonObject

Allocate an NvDsPersonObject.

Returns

Allocated NvDsPersonObject

alloc_nvds_face_object

pyds.alloc_nvds_face_object() pyds.NvDsFaceObject

Allocate an NvDsFaceObject.

Returns

Allocated NvDsFaceObject

alloc_nvds_event_msg_meta

pyds.alloc_nvds_event_msg_meta() pyds.NvDsEventMsgMeta

Allocate an NvDsEventMsgMeta.

Returns

Allocated NvDsEventMsgMeta

alloc_nvds_event

pyds.alloc_nvds_event() pyds.NvDsEvent

Allocate an NvDsEvent.

Returns

Allocated NvDsEvent

generate_ts_rfc3339

pyds.generate_ts_rfc3339(buffer: int, size: int) None

Generate RFC3339 timestamp.

Parameters
  • buffer – Buffer into which timestamp content is copied

  • size – Maximum timestamp length

alloc_nvds_payload

pyds.alloc_nvds_payload() pyds.NvDsPayload

Allocate an NvDsPayload.

Returns

Allocated NvDsPayload

NvBufSurfaceCreate

pyds.NvBufSurfaceCreate(surf: NvBufSurface, batchSize: int, params: NvBufSurfaceCreateParams) int

Allocate batch of buffers.

Allocates memory for batchSize buffers and returns in surf object allocated NvBufSurface. params object should have allocation parameters of single object. If size field in params is set, buffer of that size will be allocated and all other parameters (w, h, color format etc.) will be ignored.

Use NvBufSurfaceDestroy() to free all the resources.

Parameters
  • surf – pointer to allocated batched buffers.

  • batchSize – batch size of buffers.

  • params – pointer to NvBufSurfaceCreateParams structure.

Returns

0 for success, -1 for failure.

NvBufSurfaceDestroy

pyds.NvBufSurfaceDestroy(surf: NvBufSurface) int

Free the batched buffers previously allocated through NvBufSurfaceCreate.

Parameters

surf – An object to NvBufSurface to free.

Returns

0 for success, -1 for failure.

NvBufSurfaceMap

pyds.NvBufSurfaceMap(surf: NvBufSurface, index: int, plane: int, type: NvBufSurfaceMemMapFlags) int

Map HW batched buffers to HOST CPU address space.

Valid for NVBUF_MEM_CUDA_UNIFIED type of memory for dGPU and NVBUF_MEM_SURFACE_ARRAY and NVBUF_MEM_HANDLE type of memory for Jetson.

This function will fill addr array of NvBufSurfaceMappedAddr field of NvBufSurfaceParams with the CPU mapped memory pointers.

The client must call NvBufSurfaceSyncForCpu() with the virtual address populated by this function before accessing the mapped memory in CPU.

After memory mapping is complete, mapped memory modification must be coordinated between the CPU and hardware device as follows:
  • CPU: If the CPU modifies any mapped memory, the client must call NvBufSurfaceSyncForDevice() before any hardware device accesses the memory.

  • Hardware device: If the mapped memory is modified by any hardware device, the client must call NvBufSurfaceSyncForCpu() before CPU accesses the memory.

Use NvBufSurfaceUnMap() to unmap buffer(s) and release any resource.

Parameters
  • surf – pointer to NvBufSurface structure.

  • index – index of buffer in the batch. -1 for all buffers in batch.

  • plane – index of plane in buffer. -1 for all planes in buffer.

  • type – flag for mapping type.

Returns

0 for success, -1 for failure.

NvBufSurfaceUnMap

pyds.NvBufSurfaceUnMap(surf: NvBufSurface, index: int, plane: int) int

Unmap the previously mapped buffer(s).

Parameters
  • surf – pointer to NvBufSurface structure.

  • index – index of buffer in the batch. -1 for all buffers in batch.

  • plane – index of plane in buffer. -1 for all planes in buffer.

Returns

0 for success, -1 for failure.

NvBufSurfaceCopy

pyds.NvBufSurfaceCopy(srcSurf: NvBufSurface, dstSurf: NvBufSurface) int

Copy the memory content of source batched buffer(s) to memory of destination batched buffer(s).

This function can be used to copy source buffer(s) of one memory type to destination buffer(s) of different memory type. e.g. CUDA Host to CUDA Device or malloced memory to CUDA device etc.

Both source and destination NvBufSurface must have same buffer and batch size.

Parameters
Returns

0 for success, -1 for failure.

NvBufSurfaceSyncForCpu

pyds.NvBufSurfaceSyncForCpu(surf: NvBufSurface, index: int, plane: int) int

Syncs the HW memory cache for the CPU.

Valid only for NVBUF_MEM_SURFACE_ARRAY and NVBUF_MEM_HANDLE memory types.

Parameters
  • surf – pointer to NvBufSurface structure.

  • index – index of buffer in the batch. -1 for all buffers in batch.

  • plane – index of plane in buffer. -1 for all planes in buffer.

Returns

0 for success, -1 for failure.

NvBufSurfaceSyncForDevice

pyds.NvBufSurfaceSyncForDevice(surf: NvBufSurface, index: int, plane: int) int

Syncs the HW memory cache for the device.

Valid only for NVBUF_MEM_SURFACE_ARRAY and NVBUF_MEM_HANDLE memory types.

Parameters
  • surf – pointer to NvBufSurface structure.

  • index – index of buffer in the batch. -1 for all buffers in batch.

  • plane – index of plane in buffer. -1 for all planes in buffer.

Returns

0 for success, -1 for failure.

NvBufSurfaceFromFd

pyds.NvBufSurfaceFromFd(dmabuf: int, buffer: capsule) int

Get the NvBufSurface from the dmabuf fd.

Parameters
  • dmabuf_fd – dmabuf fd of the buffer.

  • buffer – pointer to NvBufSurface .

Returns

0 for success, -1 for failure.

NvBufSurfaceMemSet

pyds.NvBufSurfaceMemSet(surf: NvBufSurface, index: int, plane: int, value: int) int

Fill each byte of buffer(s) in NvBufSurface with provided value.

This function can also be used to reset the buffer(s) in the batch.

Parameters
  • surf – pointer to NvBufSurface structure.

  • index – index of buffer in the batch. -1 for all buffers in batch.

  • plane – index of plane in buffer. -1 for all planes in buffer.

  • value – value to be set.

Returns

0 for success, -1 for failure.

NvBufSurfaceMapEglImage

pyds.NvBufSurfaceMapEglImage(surf: NvBufSurface, index: int) int

Creates an EGLImage from memory of NvBufSurface buffer(s).

Only memory type NVBUF_MEM_SURFACE_ARRAY is supported. This function will set eglImage pointer of NvBufSurfaceMappedAddr field of NvBufSurfaceParams with EGLImageKHR.

This function can be used in scenarios where CUDA operation on Jetson HW memory (NVBUF_MEM_SURFACE_ARRAY) is required. EGLImageKHR provided by this function can then be register with CUDA for further CUDA operations.

Parameters
  • surf – pointer to NvBufSurface structure.

  • index – index of buffer in the batch. -1 for all buffers in batch.

Returns

0 for success, -1 for failure.