Please read the sample code and API description. The following code can work properly.
diff --git a/sources/apps/sample_apps/deepstream-test5/deepstream_test5_app_main.c b/sources/apps/sample_apps/deepstream-test5/deepstream_test5_app_main.c
index 07f308b..5f17c0e 100644
--- a/sources/apps/sample_apps/deepstream-test5/deepstream_test5_app_main.c
+++ b/sources/apps/sample_apps/deepstream-test5/deepstream_test5_app_main.c
@@ -41,6 +41,8 @@
#include "nvdsmeta_schema.h"
#include "deepstream_test5_app.h"
+#include "nvbufsurface.h"
+#include "nvds_obj_encode.h"
#define MAX_DISPLAY_LEN (64)
#define MAX_TIME_STAMP_LEN (64)
@@ -52,6 +54,8 @@
#define IS_YAML(file) (g_str_has_suffix(file, ".yml") || g_str_has_suffix(file, ".yaml"))
+static NvDsObjEncCtxHandle obj_ctx_handle;
+
/** @{
* Macro's below and corresponding code-blocks are used to demonstrate
* nvmsgconv + Broker Metadata manipulation possibility
@@ -593,6 +597,14 @@ bbox_generated_probe_after_analytics (AppCtx * appCtx, GstBuffer * buf,
GstClockTime buffer_pts = 0;
guint32 stream_id = 0;
+ GstMapInfo inmap = GST_MAP_INFO_INIT;
+ if (!gst_buffer_map (buf, &inmap, GST_MAP_READ)) {
+ GST_ERROR ("input buffer mapinfo failed");
+ return;
+ }
+ NvBufSurface *ip_surf = (NvBufSurface *) inmap.data;
+ gst_buffer_unmap (buf, &inmap);
+
for (NvDsMetaList * l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next) {
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) l_frame->data;
@@ -612,6 +624,20 @@ bbox_generated_probe_after_analytics (AppCtx * appCtx, GstBuffer * buf,
src_stream->last_ntp_time = buf_ntp_time;
}
+ NvDsObjEncUsrArgs objData = { 0 };
+ /* To be set by user */
+ objData.saveImg = TRUE;
+ objData.attachUsrMeta = FALSE;
+ /* Set if Image scaling Required */
+ objData.scaleImg = FALSE;
+ objData.scaledWidth = 0;
+ objData.scaledHeight = 0;
+ /* Quality */
+ objData.quality = 80;
+ objData.isFrame = TRUE;
+ /*Main Function Call */
+ nvds_obj_enc_process (obj_ctx_handle, &objData, ip_surf, NULL, frame_meta);
+
GList *l;
for (l = frame_meta->obj_meta_list; l != NULL; l = l->next) {
/* Now using above information we need to form a text that should
@@ -689,6 +715,7 @@ bbox_generated_probe_after_analytics (AppCtx * appCtx, GstBuffer * buf,
}
testAppCtx->streams[stream_id].frameCount++;
}
+ nvds_obj_enc_finish (obj_ctx_handle);
}
/** @{ imported from deepstream-app as is */
@@ -1535,6 +1562,12 @@ main (int argc, char *argv[])
main_loop = g_main_loop_new (NULL, FALSE);
+ obj_ctx_handle = nvds_obj_enc_create_context (0);
+ if (!obj_ctx_handle) {
+ g_print ("Unable to create context\n");
+ return -1;
+ }
+
_intr_setup ();
g_timeout_add (400, check_for_interrupt, NULL);
@@ -1674,6 +1707,7 @@ main (int argc, char *argv[])
done:
g_print ("Quitting\n");
+ nvds_obj_enc_destroy_context (obj_ctx_handle);
for (i = 0; i < num_instances; i++) {
if (appCtx[i] == NULL)
continue;
diff --git a/sources/apps/sample_apps/deepstream-test5/Makefile b/sources/apps/sample_apps/deepstream-test5/Makefile
index 8aa904c..3d75b51 100644
--- a/sources/apps/sample_apps/deepstream-test5/Makefile
+++ b/sources/apps/sample_apps/deepstream-test5/Makefile
@@ -48,7 +48,7 @@ CFLAGS+= -I../../apps-common/includes \
LIBS:= -L/usr/local/cuda-$(CUDA_VER)/lib64/ -lcudart
-LIBS+= -L$(LIB_INSTALL_DIR) -lnvdsgst_meta -lnvds_meta -lnvdsgst_helper -lnvdsgst_customhelper -lnvdsgst_smartrecord -lnvds_utils -lnvds_msgbroker -lm \
+LIBS+= -L$(LIB_INSTALL_DIR) -lnvdsgst_meta -lnvds_meta -lnvdsgst_helper -lnvdsgst_customhelper -lnvdsgst_smartrecord -lnvds_utils -lnvds_msgbroker -lm -lnvds_batch_jpegenc \
-lyaml-cpp -lcuda -lgstrtspserver-1.0 -ldl -Wl,-rpath,$(LIB_INSTALL_DIR)
CFLAGS+= $(shell pkg-config --cflags $(PKGS))