Deepstream-segmentation-test with USB Camera

• Hardware Platform: Jetson Xavier NX
• DeepStream Version: 5.0
• JetPack Version: 4.4.1
• Issue Type: questions

I’m trying to run deepstream-segmentation-test with USB Camera. I use jetpack 4.4.1 and Docker image (nvcr.io/nvidia/deepstream-l4t:5.0.1-20.09-samples) and use Jetson Xavier NX.

I have modified the code and am able to recognize the USB Camera (MJPEG) and import the video, but the video stops right after startup.

My modified code is as follows(deepstream_segmentation_app.c)

	static GstElement *
	create_source_bin (guint index, gchar * uri)
	{ 
	  GstElement *bin = NULL;
	  GstCaps *caps = NULL;
	  gchar bin_name[16] = { };

	  g_snprintf (bin_name, 15, "source-bin-%02d", index);
	  bin = gst_bin_new (bin_name);

	  GstElement *source, *decoder;
	  g_print ("Now loading:");
	  g_print (" %s,", uri);

	  source = gst_element_factory_make ("v4l2src", "src_elem");
	  g_object_set (G_OBJECT (source), "device", uri, NULL);

	  GstElement *cap_filter = gst_element_factory_make ("capsfilter", "src_cap_filter");
	  decoder = gst_element_factory_make ("nvv4l2decoder", "nvv4l2-decoder");
	  caps = gst_caps_new_simple ("image/jpeg",
	              "width", G_TYPE_INT, 1920, 
	              "height", G_TYPE_INT,1080, 
	              NULL);
	  g_object_set (G_OBJECT (cap_filter), "caps", caps, NULL);
	  g_object_set (G_OBJECT (source), "io-mode", 2, NULL);
	  g_object_set (G_OBJECT (decoder), "mjpeg", 1, NULL);
	  
	  gst_bin_add_many (GST_BIN (bin), source, cap_filter, decoder, NULL);
	  
	  gst_element_link_many (source, cap_filter, decoder, NULL);

	  if (!gst_element_add_pad (bin, gst_ghost_pad_new_no_target ("src",
	              GST_PAD_SRC))) {
	    g_printerr ("Failed to add ghost pad in source bin\n");
	    return NULL;
	  }

	  GstPad *srcpad = gst_element_get_static_pad (decoder, "src");
	  if (!srcpad) {
	    g_printerr ("Failed to get src pad of source bin. Exiting.\n");
	    return NULL;
	  }

	  GstPad *bin_ghost_pad = gst_element_get_static_pad (bin, "src");
	  if (!gst_ghost_pad_set_target (GST_GHOST_PAD (bin_ghost_pad),
	        srcpad)) {
	    g_printerr ("Failed to link decoder src pad to source bin ghost pad\n");
	  }

	  return bin;
	}

The results of running V4l2-ctl are as follows(Use OV4689)

v4l2-ctl -d /dev/video0 --list-formats-ext
	ioctl: VIDIOC_ENUM_FMT
		Index       : 0
		Type        : Video Capture
		Pixel Format: 'MJPG' (compressed)
		Name        : Motion-JPEG
			Size: Discrete 640x360
				Interval: Discrete 0.004s (260.004 fps)
			Size: Discrete 1280x720
				Interval: Discrete 0.008s (120.000 fps)
			Size: Discrete 1920x1080
				Interval: Discrete 0.017s (60.000 fps)

The screen came up only the first time, but after that, it locked up and would not update the video.

I change another camera(MJPEG), and I try another Gstreamer pipeline, images are not being updated at all.

The execution is as follows

./deepstream-segmentation-app dstest_segmentation_config_semantic.txt /dev/video0

Execution result. It is running normally.

INFO: [Implicit Engine Info]: layers num: 2
	0   INPUT  kFLOAT data            3x512x512       
	1   OUTPUT kFLOAT final_conv/BiasAdd 4x512x512       

	0:00:29.761102557   964   0x55c5fa9e30 INFO                 nvinfer gstnvinfer_impl.cpp:313:notifyLoadModelStatus:<primary-nvinference-engine> [UID 1]: Load new model:dstest_segmentation_config_semantic.txt sucessfully
	Running...
	NvMMLiteOpen : Block : BlockType = 277 
	NVMEDIA: Reading vendor.tegra.display-size : status: 6 
	NvMMLiteBlockCreate : Block : BlockType = 277 
	in videoconvert caps = video/x-raw(memory:NVMM), format=(string)RGBA, framerate=(fraction)60/1, width=(int)512, height=(int)512

I made and tried Pipeline for YUYC and Sample for CSI Camera, but I could not update the video.

If you can give me some hints, that would be great.

Sorry for the late reply, may I know if this is still an issue to support?

Thanks

Hi,
Please check if the camera works in gst-launch-1.0 command:

gst-launch-1.0 v4l2src ! image/jpeg,width=1920,height=1080,framerate=60/1 ! nvv4l2decoder mjpeg=1 ! nvegltransform ! nveglglessink