Jetson Inference Fullscreen mode

Hello!
I am working on xavier nx.
I found topic about fullscreen mode, but it doesn’t work:

I add code from link and change it but not work.
What’s wrong?
Thank for your help!

Hi,

Please check if jetson.utils.glDisplay(.) can meet your reqirement.
For example:

...
display = jetson.utils.glDisplay()

while display.IsOpen():
        ...
        display.RenderOnce(img, 1920, 1080)

Thanks.

Thanks, but i need only picture without titlebar

Hi @Polzovatel2351, I haven’t tried fullscreen mode so I can’t tell for sure, but can you also try commenting out these lines:

https://github.com/dusty-nv/jetson-utils/blob/6f0c5b74b59e08f8205d95f19c42d9b20aa79112/display/glDisplay.cpp#L649

/*if( !mResizedToFeed || ((GetWidth() < width || GetHeight() < height) && (width < mScreenWidth && height < mScreenHeight)) )
{
     SetSize(width, height);
     mResizedToFeed = true;
}*/

My initial guess is that these lines (which resize the window once to match the size of the video stream being rendered) is resetting the fullscreen mode, but I don’t know that for sure. Also run the following after making any C++ code changes in the project:

cd jetson-inference/build
cmake ../
make
sudo make install

Hi @dusty_nv, thanks!
I tried it, but it not work. Nothing changes.

OK, I was able to get this working the same way, and then added functions to glDisplay in commit #aae77a for toggling fullscreen mode:

So if you reclone/rebuild/reinstall the repo, you should be able to use these functions now. For example, here is a modified video-viewer.cpp that toggles fullscreen mode every 100 frames:

#include "videoSource.h"
#include "videoOutput.h"
#include "glDisplay.h"

#include "logging.h"
#include "commandLine.h"

#include <signal.h>


bool signal_recieved = false;

void sig_handler(int signo)
{
	if( signo == SIGINT )
	{
		LogInfo("received SIGINT\n");
		signal_recieved = true;
	}
}

int usage()
{
	printf("usage: video-viewer [--help] input_URI [output_URI]\n\n");
	printf("View/output a video or image stream.\n");
	printf("See below for additional arguments that may not be shown above.\n\n");
	printf("positional arguments:\n");
	printf("    input_URI       resource URI of input stream  (see videoSource below)\n");
	printf("    output_URI      resource URI of output stream (see videoOutput below)\n\n");

	printf("%s", videoSource::Usage());
	printf("%s", videoOutput::Usage());
	printf("%s", Log::Usage());

	return 0;
}

int main( int argc, char** argv )
{
	/*
	 * parse command line
	 */
	commandLine cmdLine(argc, argv);

	if( cmdLine.GetFlag("help") )
		return usage();


	/*
	 * attach signal handler
	 */	
	if( signal(SIGINT, sig_handler) == SIG_ERR )
		LogError("can't catch SIGINT\n");


	/*
	 * create input video stream
	 */
	videoSource* inputStream = videoSource::Create(cmdLine, ARG_POSITION(0));

	if( !inputStream )
	{
		LogError("video-viewer:  failed to create input stream\n");
		return 0;
	}


	/*
	 * create output video stream
	 */
	videoOutput* outputStream = videoOutput::Create(cmdLine, ARG_POSITION(1));
	
	if( !outputStream )
		LogError("video-viewer:  failed to create output stream\n");
	
	
	/*
	 * capture/display loop
	 */
	uint32_t numFrames = 0;

	while( !signal_recieved )
	{
		uchar3* nextFrame = NULL;

		if( !inputStream->Capture(&nextFrame, 1000) )
		{
			LogError("video-viewer:  failed to capture video frame\n");

			if( !inputStream->IsStreaming() )
				signal_recieved = true;

			continue;
		}

		LogInfo("video-viewer:  captured %u frames (%u x %u)\n", ++numFrames, inputStream->GetWidth(), inputStream->GetHeight());

		if( outputStream != NULL )
		{
			if( outputStream->IsType<glDisplay>() )
			{
				glDisplay* display = (glDisplay*)outputStream;
				
				if( numFrames % 100 == 0 ) // toggle fullscreen every 100 frames
				{
					const bool fullscreen = display->IsFullscreen();
					LogInfo("changing display window to %s mode\n", fullscreen ? "non-fullscreen" : "fullscreen");
					display->SetFullscreen(!fullscreen);
				}
				
				LogInfo("display window is %s fullscreen\n", display->IsFullscreen() ? "" : "not");
			}
			
			outputStream->Render(nextFrame, inputStream->GetWidth(), inputStream->GetHeight());

			// update status bar
			char str[256];
			sprintf(str, "Video Viewer (%ux%u) | %.1f FPS", inputStream->GetWidth(), inputStream->GetHeight(), outputStream->GetFrameRate());
			outputStream->SetStatus(str);	

			// check if the user quit
			if( !outputStream->IsStreaming() )
				signal_recieved = true;
		}
	}


	/*
	 * destroy resources
	 */
	printf("video-viewer:  shutting down...\n");
	
	SAFE_DELETE(inputStream);
	SAFE_DELETE(outputStream);

	printf("video-viewer:  shutdown complete\n");
}

Big thanks for this!
But i have troubles with uses in python.
I download, build and install new repo. But python gives me this

My code:

import jetson.inference
import jetson.utils

camera = jetson.utils.gstCamera(1920, 1080, “/dev/video0”)
display = jetson.utils.glDisplay()
display.SetFullscreen(True)

while display.IsOpen():

img, width, height = camera.CaptureRGBA()
display.RenderOnce(img, width, height)

I didn’t add the Python bindings for this yet. I’m not sure about it because jetson.utils.glDisplay() is deprecated in favor of jetson.utils.videoSource()

However if you want, you can add the binding to this file: jetson-utils/PyGL.cpp at aae77a0a97b25d7e3a9adb1e1c36947564958f68 · dusty-nv/jetson-utils · GitHub

Then re-run make and sudo make install

Okay, thanks!

It occurred to me that an alternative to making the Python binding, is to just add a call to SetFullscreen(true) at this line of code in glDisplay.cpp

https://github.com/dusty-nv/jetson-utils/blob/aae77a0a97b25d7e3a9adb1e1c36947564958f68/display/glDisplay.cpp#L322

Then it should always be fullscreen.

I try it and nothing changes

Did you re-run make and sudo make install from your jetson-inference/build directory?

Yes

Hmm ok, kinda strange as that works here. Regardless, I just added Python bindings to glDisplay in commit 480865 for the following functions:

  • glDisplay.IsMaximized() -> bool
  • glDisplay.IsFullscreen() -> bool
  • glDisplay.SetMaximized(bool)
  • glDisplay.SetFullscreen(bool)

So if you pull the latest code, recompile, and re-install, then you should be able to call these functions from Python. For a working example, see gl-display-test.py

It work, big thanks!!!

Is it normal to have a black bar at the top of the screen?

If you are using glDisplay.RenderOnce(), yes it is normal because the default y-coordinate is 30px (this is normally so that the image isn’t obscured by the window’s title bar). There is also a default 5px border on the left (x-coordinate)

To change it, you can use display.RenderOnce(img, width, height, x=0, y=0) instead

Thanks!

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