hi:
Thank you for your help. I can already get the live stream camera via rtsp.
Now, I want to know how to get the decoded frame data in order to do my license plate recognition and subsequent car lamp detection algorithms.
There is still a problem, the vehicle tracking in deepstream-app, I can by what method, get a video of the time from the time the vehicle enters the scene to the scene, to save it to the local.
I look forward to your reply.
Hi,
Here is a similar query and there is no existing implementation in DS4.0.
You may check if you can follow NvCJR’s suggestion to implement it.
hi DaneLLL :
I want to use the osd_sink_pad_buffer_probe function in deepstream-test1 to save the decoded image. My code is as follows. Now, I don’t know which is the decoded frame structure. The saved image is incorrect. Can you give me some suggestions? Thank you very much.
static GstPadProbeReturn
osd_sink_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info,
gpointer u_data)
{
GstBuffer *buf = (GstBuffer *) info->data;
guint num_rects = 0;
NvDsObjectMeta *obj_meta = NULL;
guint vehicle_count = 0;
guint person_count = 0;
NvDsMetaList * l_frame = NULL;
NvDsMetaList * l_obj = NULL;
NvDsDisplayMeta *display_meta = NULL;
NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next) {
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
int offset = 0;
for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;
l_obj = l_obj->next) {
obj_meta = (NvDsObjectMeta *) (l_obj->data);
#if 1
char filename[200];
char* sFileDirPath="/usr/local/sys.txt";
sprintf(filename,"%s/%d.jpg",sFileDirPath,frame_number);
int ret;
int tick = 0;
int fd = -1;
fd = open(filename, O_CREAT|O_TRUNC|O_RDWR, 0666);
if (fd < 0)
{
printf("share::writeFile open file %s, error %s\n", filename, strerror(errno));
return -1;
}
ret = BlockWrite(fd, frame_meta, sizeof(frame_meta));
if (ret < 0)
{
printf("share::writeFile open file error %s\n", strerror(errno));
close(fd);
if (errno == ENOSPC){
// goto NO_SPACE_EXIT;
}
return -1;
}
close(fd);
#endif
if (obj_meta->class_id == PGIE_CLASS_ID_VEHICLE) {
vehicle_count++;
num_rects++;
}
if (obj_meta->class_id == PGIE_CLASS_ID_PERSON) {
person_count++;
num_rects++;
}
}
display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
NvOSD_TextParams *txt_params = &display_meta->text_params[0];
display_meta->num_labels = 1;
txt_params->display_text = g_malloc0 (MAX_DISPLAY_LEN);
offset = snprintf(txt_params->display_text, MAX_DISPLAY_LEN, "Person = %d ", person_count);
offset = snprintf(txt_params->display_text + offset , MAX_DISPLAY_LEN, "Vehicle = %d ", vehicle_count);
/* Now set the offsets where the string should appear */
txt_params->x_offset = 10;
txt_params->y_offset = 12;
/* Font , font-color and font-size */
txt_params->font_params.font_name = "Serif";
txt_params->font_params.font_size = 10;
txt_params->font_params.font_color.red = 1.0;
txt_params->font_params.font_color.green = 1.0;
txt_params->font_params.font_color.blue = 1.0;
txt_params->font_params.font_color.alpha = 1.0;
/* Text background color */
txt_params->set_bg_clr = 1;
txt_params->text_bg_clr.red = 0.0;
txt_params->text_bg_clr.green = 0.0;
txt_params->text_bg_clr.blue = 0.0;
txt_params->text_bg_clr.alpha = 1.0;
nvds_add_display_meta_to_frame(frame_meta, display_meta);
}
g_print ("Frame Number = %d Number of objects = %d "
"Vehicle Count = %d Person Count = %d\n",
frame_number, num_rects, vehicle_count, person_count);
frame_number++;
return GST_PAD_PROBE_OK;
}
int BlockWrite(int fd, char *src, int size)
{
int k = 0, l_wriSize = 0;
int l_connFd = fd;
int l_size = size;
while(1)
{
k = write(l_connFd, src + l_wriSize, l_size - l_wriSize);
if (k <= 0)
{
printf("blockWrite:: failed fd %d, %s\n", fd, strerror(errno));
return -1;
}
l_wriSize += k;
if (l_wriSize == l_size)
{
return 0;
}
}
}
Hi,
Please refer to 2, 5 in faq