Black images with Qt5 and OpenGL

Hi,

I am unable to display images captured from a camera using a combination of Qt5 and OpenGL.
The image is displayed black although it is valid. This does not happen on TX2.

I tried two such cases:

  1. qv4l2 application
  2. custom application that uses an OpenCV build with Qt5 and OpenGL enabled to display images

When OpenCV is built with Qt5 and without OpenGL the image is displayed normally.

These applications work on TX2. Is this a known issue on Xavier? Any info would be appreciated.

Hi,
Do you do raw capture like
[url]https://devtalk.nvidia.com/default/topic/1046774/jetson-agx-xavier/tegra_multimedia_api-save-raw-data/post/5311967/#5311967[/url]

Update:

The difference is not between TX2 and Xavier but between L4T 28.2 and L4T 32.2.

The issue seems to be caused by the difference between Qt5 versions available on the two L4Ts. The L4T 28.2 version is compiled with libGL and the L4T 32.2 version is compiled with libGLESv2. However, OpenCV can only be compiled with libGL. When OpenCV (with libGL) uses Qt5 (with libGLESv2) to display images, the image is displayed black. The content of OpenCV Mat is correct (I can write it to PNG for example). The issue only occurs when displaying images (utilizing OpenGL).

OpenCV version is 3.3.1.

What I also tried:

  • deploying the Qt5 version from L4T 28.2 to L4T 32.2 - this works, confirming that Qt5 is the source of the issue. However, it is not very practical to deploy the whole Qt5 because of this issue
  • building OpenCV with GTK backend and OpenGL - this also works, but resizes the image to screen size (use case requires displaying high-res images without resizing)

Is there any info on why the deployed Qt5 library has changed? Is there any other fix or workaround for this issue?

Hi,
Please share steps so that we can run and compare r28.2 and r32.2.1.

Hi, a minimal working example is attached to this post. It can be extracted and executed on both r28.2 and r32.2. It includes a minimal OpenCV build with Qt and OpenGL support. It also includes the example source file and a simple build script.

The example displays a blue image on r28.2 (correct behaviour). On r32.2 the image is black.

I’ve also provided a list of dynamically linked libraries for both L4T versions.
minimal_working_example.tar.gz (9.52 MB)
ldd_example_l4t_28_2.txt (2.93 KB)
ldd_example_l4t_32_2.txt (2.8 KB)


Hi,
Please check if you apply the patch for building OpenCV with OpenGL enabled:
[url]https://devtalk.nvidia.com/default/topic/1055949/jetson-agx-xavier/opencv-with-gl-support-at-xavier/post/5353514/#5353514[/url]

Maybe this step is missed.

We are building OpenCV without CUDA support (use case requires a multiplatform build), so the file cuda_gl_interop.h is not used in the build.

We also tried

sudo ln -sf /usr/lib/aarch64-linux-gnu/libGL.so.1.0.0 libGL.so

both before and after the build. The issue still persists.

The workaround we ended up using is building OpenCV with Qt4 instead of Qt5 (WITH_QT=4 CMake option). Qt4 version provided with L4T 32.2 depends on libGL and not on libGLESv2 like the provided Qt5. The issue does not occur when OpenCV is built with Qt4 and OpenGL support.

Good to know that you have a solution and thanks for the sharing.