configure_source_for_ntp_sync¶
- pyds.configure_source_for_ntp_sync(src_elem: int) None¶
Configure the source to generate NTP sync values for RTSP sources.
These values are used by the DeepStream GStreamer element NvStreamMux to calculate the NTP time of the frames at the source.
This functionality is dependent on the RTSP sending the RTCP Sender Reports. source.
This function only works for RTSP sources i.e. GStreamer elements “rtspsrc” or “uridecodebin” with an RTSP uri.
- Parameters:
src_elem – GStreamer source element to be configured.
alloc_custom_struct¶
- pyds.alloc_custom_struct(arg0: pyds.NvDsUserMeta) pyds.CustomDataStruct¶
Allocate an
CustomDataStruct.- Returns:
Allocated
CustomDataStruct
gst_element_send_nvevent_new_stream_reset¶
- pyds.gst_element_send_nvevent_new_stream_reset(arg0: int, arg1: int) int¶
Sends a “custom reset” event on the given element for the specified source. This nvevent_new_stream_reset event is propogated downstream.
This function, along with other reset events, can be used to reset the source in case RTSP reconnection is required.
- Parameters:
gst_element – element for to which the generated event needs to be sent.
source_id – source id for which this event needs to be generated
- Returns:
True for success.
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.
For Jetson, a matching call to
unmap_nvds_buf_surface()must be made.- 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
- Returns:
NumPy array containing the frame image buffer.
get_nvds_buf_surface_gpu¶
- pyds.get_nvds_buf_surface_gpu(gst_buffer: int, batchID: int) tuple¶
This function returns the dtype, shape of the array, strides, pointer to the GPU buffer, and size of the allocated memory for the buffer. Only x86 and RGBA format is supported. This information can be used to create a CuPy array (see deepstream-imagedata-multistream-cupy). 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
- Returns:
dtype, shape, strides, pointer to buffer, size of allocated memory of the GPU buffer
unmap_nvds_buf_surface¶
- pyds.unmap_nvds_buf_surface(gst_buffer: int, batchID: int) None¶
This function unmaps the NvBufSurface of the given Gst buffer and batch id, if previously mapped. For Jetson, a matching call to this function must be made for every call to
get_nvds_buf_surface().The array can no longer be accessed after this call, as the memory is released.
- 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
NvDsBatchMetaof given batch size.- Parameters:
max_batch_size – maximum number of frames those can be present in the batch
- Returns:
Allocated
NvDsBatchMetaobject
nvds_destroy_batch_meta¶
- pyds.nvds_destroy_batch_meta(batch_meta: pyds.NvDsBatchMeta) int¶
Deletes/Releases given
NvDsBatchMetabatch_meta object.- Parameters:
batch_meta – An object of type
NvDsBatchMetato 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
NvDsFrameMetafrom frame_meta pool. User must acquire the frame_meta from frame_meta pool to fill frame metadata.- Parameters:
batch_meta – An object of type
NvDsBatchMetafrom whichNvDsFrameMetawill be acquired- Returns:
Acquired
NvDsFrameMetaobject 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:
batch_meta – An object of type
NvDsBatchMetato which frame_meta will be attached.frame_meta – An object of type
NvDsFrameMetaacquired from frame_meta_pool present inNvDsBatchMeta
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
NvDsBatchMetafrom which frame_meta is to be removed.frame_meta – A object of type
NvDsFrameMetato 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
NvDsObjectMetafrom 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
NvDsBatchMetafrom whichNvDsObjectMetawill be acquired- Returns:
Acquired
NvDsObjectMetaobject 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
NvDsFrameMetafrom which obj_meta is to be removed.obj_meta – An object of type
NvDsObjectMetato 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
NvDsClassifierMetafrom 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
NvDsBatchMetafrom whichNvDsClassifierMetawill be acquired- Returns:
Acquired
NvDsClassifierMetaobject 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:
obj_meta – An object of type
NvDsObjectMetato which classifier_meta will be attached.classifier_meta – An object of type
NvDsClassifierMetaacquired from classifier_meta_pool present inNvDsBatchMeta.
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
NvDsObjectMetafrom which classifier_meta is to be removed.classifier_meta – An object of type
NvDsClassifierMetato 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
NvDsBatchMetafrom whichNvDsDisplayMetawill be acquired.- Returns:
Acquired
NvDsDisplayMetaobject 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:
frame_meta – An object of type
NvDsFrameMetato which display_meta will be attached.display_meta – An object of type
NvDsDisplayMetaacquired from display_meta_pool present inNvDsBatchMeta.
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
NvDsFrameMetafrom which display_meta is to be removed.display_meta – An object of type
NvDsDisplayMetato 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
NvDsLabelInfofrom the labelinfo meta pool of givenNvDsBatchMeta. User must acquire the labelinfo meta from the labelinfo meta pool to fill labelinfo metadata.- Parameters:
batch_meta – An object of type
NvDsBatchMetafrom whichNvDsLabelInfowill be acquired- Returns:
An object of type
NvDsLabelInfoobject 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:
classifier_meta – An object of type
NvDsClassifierMetato which label_info_meta will be attached.label_info_meta – An object of type
NvDsLabelInfoacquired from label_info_meta_pool present inNvDsBatchMeta.
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
NvDsClassifierMetafrom which label_info_meta is to be removed.label_info_meta – An object of type
NvDsLabelInfoto 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:
batch_meta – An object of type
NvDsBatchMetato which user_meta will be attached.user_meta – An object of type
NvDsUserMetaacquired from user_meta_pool present inNvDsBatchMeta.
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:
frame_meta – An object of type
NvDsFrameMetato which user_meta will be attached.user_meta – An object of type
NvDsUserMetaacquired from user_meta_pool present inNvDsBatchMeta.
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:
obj_meta – An object of type
NvDsObjectMetato which user_meta will be attached.user_meta – An object of type
NvDsUserMetaacquired from user_meta_pool presentNvDsBatchMeta.
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
NvDsBatchMetafrom whichNvDsUserMetawill 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
NvDsBatchMetafrom which user_meta is to be removed.user_meta – An object of type
NvDsUserMetato be removed from batch_meta.
- Returns:
Acquired
NvDsUserMetaobject 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
NvDsFrameMetafrom which user_meta is to be removed.user_meta – An object of type
NvDsUserMetato 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
NvDsObjectMetafrom which user_meta s to be removed.user_meta – An object of type
NvDsUserMetato 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
NvDsBatchMetauser_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
NvDsBatchMetauser_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
NvDsFrameMetaobject of the frame at index.- Parameters:
frame_meta_list – A list of objects of type
NvDsFrameMetaindex – index at which
NvDsFrameMetaobject needs to be accessed.
- Returns:
An object of type
NvDsFrameMetafrom 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
NvDsFrameMetafrom whichNvDsObjectMetaListneeds to be clearedmeta_list – An object of type
NvDsObjectMetaListwhich 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
NvDsFrameMetafrom whichNvDisplayMetaListneeds to be clearedmeta_list – An object of type
NvDisplayMetaListwhich 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
NvDsBatchMetafrom whichNvDsUserMetaListneeds to be clearedmeta_list – An object of type
NvDsUserMetaListwhich 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
NvDsFrameMetafrom whichNvDsUserMetaListneeds to be clearedmeta_list – An object of type
NvDsUserMetaListwhich 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
NvDsObjectMetafrom whichNvDsUserMetaListneeds to be clearedmeta_list – An object of type
NvDsUserMetaListwhich 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
NvDsBatchMetameta_list – An object of type
NvDsMetaListwhich needs to be clearedmeta_pool – An object of type
NvDsMetaPoolto 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
NvDsUserMetaListdst_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
NvDsUserMetaListdst_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
NvDisplayMetaListdst_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
NvDsFrameMetaListdst_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
NvDsObjectMetaListdst_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
NvDsMetato the GstBuffer and sets the meta_data member ofNvDsMeta.- 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
NvDsMetaobject; or NONE in case failure
gst_buffer_get_nvds_batch_meta¶
- pyds.gst_buffer_get_nvds_batch_meta(buffer: int) pyds.NvDsBatchMeta¶
Gets the
NvDsBatchMetaadded to the GstBuffer.- Parameters:
buffer – GstBuffer from which to retrieve the
NvDsBatchMeta- Returns:
NvDsBatchMetaobject 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
NvDsUserMetaobject.- Parameters:
meta –
NvDsUserMetaof which to set copy functionfunc – User-written copy function
user_releasefunc¶
- pyds.user_releasefunc(meta: pyds.NvDsUserMeta, func: Callable[[capsule, capsule], None]) None¶
Set release callback function of given
NvDsUserMetaobject.- Parameters:
meta –
NvDsUserMetaof which to set release functionfunc – 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(arg0: pyds.NvDsUserMeta) pyds.NvDsEventMsgMeta¶
Allocate an
NvDsEventMsgMeta.- Parameters:
user_meta – An object of type
NvDsUserMetaacquired from user_meta_pool present inNvDsBatchMeta- 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
NvBufSurfaceCreateParamsstructure.
- 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
NvBufSurfaceto 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
NvBufSurfaceMappedAddrfield ofNvBufSurfaceParamswith 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
NvBufSurfacestructure.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
NvBufSurfacestructure.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
NvBufSurfacemust have same buffer and batch size.- Parameters:
srcSurf – pointer to source
NvBufSurfacestructure.dstSurf – pointer to destination
NvBufSurfacestructure.
- 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
NvBufSurfacestructure.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
NvBufSurfacestructure.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
NvBufSurfacefrom 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
NvBufSurfacewith provided value.This function can also be used to reset the buffer(s) in the batch.
- Parameters:
surf – pointer to
NvBufSurfacestructure.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
NvBufSurfacebuffer(s).Only memory type NVBUF_MEM_SURFACE_ARRAY is supported. This function will set eglImage pointer of
NvBufSurfaceMappedAddrfield ofNvBufSurfaceParamswith 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.
nvds_measure_buffer_latency¶
- pyds.nvds_measure_buffer_latency(gst_buffer: int) int¶
Measures the latency of all frames present in the current batch.
- arg buffer:
GstBuffer from which to retrieve the
NvDsBatchMeta- returns:
:sources number in batch.
Example usage:
#enable pipeline latency measurementexport NVDS_ENABLE_LATENCY_MEASUREMENT=1 #enable compoment latency measurement export NVDS_ENABLE_COMPONENT_LATENCY_MEASUREMENT=1
#add this code in plugin probe function. num_sources_in_batch = pyds.nvds_measure_buffer_latency(hash(gst_buffer));