Send video to GTK window and not deepstream-test1-app.c standard output window

• Hardware Platform (Jetson AGX Orin Developer Kit)
• DeepStream Version - 6.2.0
• JetPack Version - 5.1.1-b56
• TensorRT Version - 8.5
• NVIDIA GPU Driver Version (valid for GPU only) - don’t know how to find this
• Issue Type( New requirement)
• How to reproduce the issue ? (./deepstream-test1-app dstest1_config.yml 2>err.txt)
• Requirement details( Direct video to a GTK window)
• Camera - Attached HD Pro Webcam C920
• Monitor - Attached MSI

Makefile changes:
CUDA_VER=11.4
PKGS:= gstreamer-1.0 gstreamer-video-1.0 gtk±3.0 glib-2.0
Code compiles without issue.

I modified deepstream-test1-app.c with:
//GTK - NEW
include <gst/video/videooverlay.h>
include <gtk/gtkx.h>

// GTK - NEW
GdkWindow *video_window_xwindow;
GtkWidget *window, *video_window;
gulong embed_xid;

// Standard GTK initialization - GTK New
gtk_init(&argc, &argv);

// GTK - NEW
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), “delete-event”, G_CALLBACK (gtk_window_close), (gpointer) pipeline);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
gtk_window_set_title (GTK_WINDOW (window), “GstVideoOverlay Gtk+ demo”);
video_window = gtk_drawing_area_new();
gtk_container_add (GTK_CONTAINER (window), video_window);
gtk_container_set_border_width (GTK_CONTAINER (window), 2);
gtk_widget_show_all (window);
video_window_xwindow = gtk_widget_get_window (video_window);
embed_xid = GDK_WINDOW_XID (video_window_xwindow);
// When the next line is commented out the new window displays and is black.
// gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), embed_xid);
// When the next line is included I get a Segmentation fault (core dump)
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), embed_xid);

debug:
$ export GST_DEBUG=“nv3dsink:9”
$ ./deepstream-test1-app dstest1_config.yml 2>err.txt
Added elements to bin
Segmentation fault (core dumped)
root@development-orin:/opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-test1# cat err.txt
0:00:00.200805696 4460 0xaaaaccd78cf0 TRACE nv3dsink gstnv3dsink.c:565:gst_nv3dsink_init:GstNv3dSink@0xaaaacd9cb580 init
0:00:00.203958602 4460 0xaaaaccd78cf0 DEBUG nv3dsink gstnv3dsink.c:340:gst_nv3dsink_get_caps: returning caps: video/x-raw, format=(string){ RGBA, BGRA, ARGB, ABGR, RGBx, BGRx, xRGB, xBGR, AYUV, Y444, I420, YV12, NV12, NV21, Y42B, Y41B, RGB, BGR, RGB16 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw(memory:NVMM), format=(string){ RGBA, BGRA, ARGB, ABGR, RGBx, BGRx, xRGB, xBGR, AYUV, Y444, I420, YV12, NV12, NV21, Y42B, Y41B, RGB, BGR, RGB16 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
0:00:00.204055340 4460 0xaaaaccd78cf0 DEBUG nv3dsink gstnv3dsink.c:340:gst_nv3dsink_get_caps: returning caps: video/x-raw, format=(string){ RGBA, BGRA, ARGB, ABGR, RGBx, BGRx, xRGB, xBGR, AYUV, Y444, I420, YV12, NV12, NV21, Y42B, Y41B, RGB, BGR, RGB16 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw(memory:NVMM), format=(string){ RGBA, BGRA, ARGB, ABGR, RGBx, BGRx, xRGB, xBGR, AYUV, Y444, I420, YV12, NV12, NV21, Y42B, Y41B, RGB, BGR, RGB16 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
0:00:00.206477484 4460 0xaaaaccd78cf0 DEBUG nv3dsink gstnv3dsink.c:96:gst_nv3dsink_set_window_handle: set_window_handle 50331655
$

Is there a way to stop the output to the Standard window and send to a new GTK window?

I have been able to do this with similar coding:
int main (int argc, char **argv)
{
GdkWindow *video_window_xwindow;
GtkWidget *window, *video_window;
gulong embed_xid;
GstStateChangeReturn sret;

gst_init (&argc, &argv);
gtk_init (&argc, &argv);

GstElement *pipeline,*videosrc,*filter,*vidconv,*transform,*sink;

pipeline = gst_pipeline_new (“xvoverlay”);
videosrc = gst_element_factory_make (“v4l2src”, NULL); g_assert(videosrc);
filter = gst_element_factory_make (“capsfilter”,NULL); g_assert(filter);

//Set CAPS
g_object_set (G_OBJECT (videosrc), “device”, “/dev/video0”, NULL);
GstCaps * vidxcaps = gst_caps_from_string(“video/x-raw,format=YUY2,width=640,height=480,framerate=30/1”);
g_object_set (filter, “caps”, vidxcaps, NULL);

/* Create remaining elements */

vidconv = gst_element_factory_make (“nvvidconv”, NULL); g_assert(vidconv);
transform = gst_element_factory_make (“nvegltransform”, NULL); g_assert(transform);
sink = gst_element_factory_make (“nveglglessink”, NULL); g_assert(sink);

//ADD
gst_bin_add_many (GST_BIN (pipeline), videosrc, filter, vidconv, transform, sink, NULL);

//LINK
g_assert(gst_element_link (videosrc, filter));
g_assert(gst_element_link (filter, vidconv)); // <<<<<< Filter placed between
g_assert(gst_element_link (vidconv, transform));
g_assert(gst_element_link (transform, sink));

/* prepare the ui */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

g_signal_connect (G_OBJECT (window), “delete-event”, G_CALLBACK (gtk_window_close), (gpointer) pipeline);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
gtk_window_set_title (GTK_WINDOW (window), “GstVideoOverlay Gtk+ demo”);

video_window = gtk_drawing_area_new ();
gtk_container_add (GTK_CONTAINER (window), video_window);
gtk_container_set_border_width (GTK_CONTAINER (window), 2);
gtk_widget_show_all (window);

video_window_xwindow = gtk_widget_get_window (video_window);
embed_xid = GDK_WINDOW_XID (video_window_xwindow);
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), embed_xid);

/* run the pipeline */
sret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (sret == GST_STATE_CHANGE_FAILURE)
gst_element_set_state (pipeline, GST_STATE_NULL);
else
gtk_main ();

gst_object_unref (pipeline);
return 0;
}

This is the method of gtk±2.0, which is outdated.

Please refer this documetion about GstOverlay.

Here is a patch for deepstream-test1-app.c , I had tried, It’s can work normal.

out.patch (4.6 KB)

This is not a problem about DeepStream.

Perhaps more information can be obtained from the gstreamer or gtk forums

@junshengy Thanks for your effort. I thought this would work. Spoke to soon. I get an error:
root@development-orin:/opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-test1# ./deepstream-test1-app dstest1_config.yml
nvbufsurftransform:cuInit failed : 100
Segmentation fault (core dumped)

Since you were able to get it to function, I’m asking you for help instead of a GTK+ forum. Once I get it to work, any GTK+ questions I’ll communicate with them.

Did you have this issue, and how did you solve it? I’m thinking it may be an issue with
397 gtk_widget_set_double_buffered (video_window, FALSE); being deprecated.

Thanks for the help.

This error is related to the CUDA driver.

You can try to roll back the Jetpack version to 5.1 and reinstall CUDA.

Here is recommended version

You indicate to roll back to Jetpack version 5.1. I indicated I’m at 5.1.1-b56. Is this sufficient? If not,
what do I set in /etc/apt/sources.list.d/nvidia-l4t-apt-source.list so that I will install 5.1 GA?
I currently have:
deb https://repo.download.nvidia.com/jetson/common r35.3 main
deb https://repo.download.nvidia.com/jetson/t234 r35.3 main

If Jetpack is reinstalled, doesn’t that handle the CUDA reinstall?

As I reinstall I seem to cause more issues for myself. I think I am handling the installs of Jetpack, CUDA, and Deepstream correctly. However, reinstalling several times seems to be causing issues.

I had been using $ deepstream-app --version-all to check the CUDA version successfully. But now I get this error:
steven@development-orin:~/Downloads$ deepstream-app --version-all
deepstream-app: error while loading shared libraries: libnvcudla.so: cannot open shared object file: No such file or directory.

To cut to the chase, Is there a way to remove all Jetpack files cleanly so I can do a complete newish install?
Then I could install CUDA if needed. Or from the error do you suspect another solution?

You can try this command

sudo apt update
sudo apt dist-upgrade
sudo reboot
sudo apt install nvidia-jetpack

Or

NVIDIA SDK Manager a useful gui tools.

I have executed the 4 install commands several times. I repeated below for your review. The error
remains. I am attempting to use SDK manager to re-install Jetpack but have issues. I opened
another issue to research ssues I am having installing the SDK Manager on a Jetson Nano - Here.

@junshengy
I was not able to install SDK Manager on my Jetson Nano. A requirement is host must be x86_64, Nano
is ARM. I will need to purchase a x86_64 w/ Ubuntu 22.04 to do this. Since I could not resolve after
the suggested manual reinstall of the Jetpack. I’m stuck.

steven@development-orin:~$ sudo apt update
[sudo] password for steven:
Get:1 file:/var/cuda-tegra-repo-ubuntu2004-12-2-local InRelease [1,572 B]
Get:2 file:/var/cuda-repo-ubuntu2004-11-4-local InRelease
.
.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
steven@development-orin:~$ sudo apt dist-upgrade
Reading package lists… Done
.
.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
steven@development-orin:~$ sudo reboot
steven@development-orin:~$ sudo apt --reinstall install nvidia-jetpack
[sudo] password for steven:
Reading package lists… Done
Building dependency tree
Reading state information… Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 29.3 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 https://repo.download.nvidia.com/jetson/common r35.3/main arm64 nvidia-jetpack arm64 5.1.1-b56 [29.3 kB]
Fetched 29.3 kB in 6s (5,264 B/s)
(Reading database … 177356 files and directories currently installed.)
Preparing to unpack …/nvidia-jetpack_5.1.1-b56_arm64.deb …
Unpacking nvidia-jetpack (5.1.1-b56) over (5.1.1-b56) …
Setting up nvidia-jetpack (5.1.1-b56) …

steven@development-orin:~$ deepstream-app --version-all
deepstream-app: error while loading shared libraries: libnvcudla.so: cannot open shared object file: No such file or directory

You may try adding path to CUDA libs into environment variable LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

and retry

SDK Manager is a GUI-tool work on Linux PC. It can’t install to Jetson.

If the above doesn’t work for you,try to burn system again.

Here is the tutorial.

Then reinstall the JetPack SDK.If normal, it should be able to work.

Thanks

Didn’t help. Thanks for suggestion.

I took a look at the tutorial you suggested & I’m not wanting to flash to a microSD card. I heard there is no way to take the flash from the microSD card and move it to the ORIN’s SSD. So you are stuck with the microSD card.

I’m going to purchase an x86_64 Linux system to flash ARM systems.

If it failed with same error, then either cuda is not correctly installed, or either you don’t have symbolic link /usr/local/cuda working.
What gives:

/bin/ls -d /usr/local/cuda*

ls -l /usr/local/cuda/lib64/libcudla.so

ls -l /usr/local/cuda-11.4/lib64/libcudla.so

steven@development-orin:~$ /bin/ls -d /usr/local/cuda*
/usr/local/cuda /usr/local/cuda-11 /usr/local/cuda-11.4 /usr/local/cuda-12 /usr/local/cuda-12.2
steven@development-orin:~$ ls -l /usr/local/cuda/lib64/libcudla.so
lrwxrwxrwx 1 root root 13 Apr 30 20:19 /usr/local/cuda/lib64/libcudla.so → libcudla.so.1
steven@development-orin:~$ ls -l /usr/local/cuda-11.4/lib64/libcudla.so
lrwxrwxrwx 1 root root 13 Sep 13 2022 /usr/local/cuda-11.4/lib64/libcudla.so → libcudla.so.1

I created a Ubuntu 20.04 Bootable thumb drive and booted to Ubuntu from my ASROCK
x86_64.
I found a person who discovered how to fix the SDK Manager install unmet dependency issues Here

  1. $ sudo add-apt-repository universe

  2. $ sudo apt update

  3. download SDK Manager

  4. $ sudo apt install ./sdkmanager_1.9.3-10904_amd64.deb

  5. $ sdkmanager
    SDK Manger window appears. Have not used the Manager yet…

Will re-flash and proceed with re-installing deepstream.

Flashed ORIN from SDK Manager. Deepstream works now. I will continue now to test your program changes for GTK.

1 Like

Ran GTK modified code you provided. Works great. Thanks for the extra effort. has saved me a lot of time and energy and made the project go forward.

Additional items needed to make out.patch work:

  1. Need to install GTK3 for the header files
    $ sudo apt-get install libgtk-3-dev
  2. Modify Makefile to include packages
    PKGS:= gstreamer-1.0 gstreamer-video-1.0 gtk±3.0 glib-2.0
  3. comment out gtk_widget_set_double_buffered
    // gtk_widget_set_double_buffered (video_window, FALSE); ← Deprecated
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.