has anybody succeeded building it?
Reference: https://devtalk.nvidia.com/default/topic/1007290/jetson-tx2/building-opencv-with-opengl-support-/2/?offset=17#5353482
Hi,
You should also need the patch for CUDA10 on Xavier.
[url]https://devtalk.nvidia.com/default/topic/1007290/jetson-tx2/building-opencv-with-opengl-support-/post/5141945/#5141945[/url]
Have you tried it?
Hi DaneLLL,
Thank you for your response.
I tried the following:
I have put the content below to the file named OpenGLHeader.patch
diff --git a/cuda_gl_interop.h b/cuda_gl_interop.h
index 0f4aa17..e8c538c 100644
--- a/cuda_gl_interop.h
+++ b/cuda_gl_interop.h
@@ -59,13 +59,13 @@
#else /* __APPLE__ */
-#if defined(__arm__) || defined(__aarch64__)
-#ifndef GL_VERSION
-#error Please include the appropriate gl headers before including cuda_gl_interop.h
-#endif
-#else
+//#if defined(__arm__) || defined(__aarch64__)
+//#ifndef GL_VERSION
+//#error Please include the appropriate gl headers before including cuda_gl_interop.h
+//#endif
+//#else
#include <GL/gl.h>
-#endif
+//#endif
#endif /* __APPLE__ */
Then I executed:
sudo patch -N /usr/local/cuda-10.0/targets/aarch64-linux/include/cuda_gl_interop.h /home/nvidia/patches/OpenGLHeader.patch
now I am getting:
[ 15%] Built target tegra_hal
make[2]: *** No rule to make target '/usr/lib/aarch64-linux-gnu/libGL.so', needed by 'lib/libopencv_cudev.so.3.4.2'. Stop.
CMakeFiles/Makefile2:1590: recipe for target 'modules/cudev/CMakeFiles/opencv_cudev.dir/all' failed
make[1]: *** [modules/cudev/CMakeFiles/opencv_cudev.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
applying afterpatch
-sudo ln -sf tegra/libGL.so libGL.so
+sudo ln -sf /usr/lib/aarch64-linux-gnu/libGL.so.1.0.0 libGL.so
seems resolved. Thank you
though while installing opencv finished, another error occurred
OpenCV installed in: /usr/local
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/cv2/__init__.py", line 89, in <module>
bootstrap()
File "/usr/local/lib/python2.7/dist-packages/cv2/__init__.py", line 79, in bootstrap
import cv2
ImportError: /usr/local/lib/libopencv_dnn.so.3.4: undefined symbol: _ZN2cv6detail17check_failed_autoEmmRKNS0_12CheckContextE
There was an error loading OpenCV in the Python sanity test.
There was an error loading OpenCV in the Python sanity test.
The loaded version does not match the version built here.
Please check the installation.
The first check should be the PYTHONPATH environment variable.
echo $PYTHONPATH
Resolved
Hi,
I see there has been lot of discussion here and slightly different versions been proposed. I am not sure what to follow. Basically, I am trying to compile with OpenGL support for OpenCV 4.4.0 in Xavier AGX running JP 4.3. I have applied the link
sudo ln -sf /usr/lib/aarch64-linux-gnu/libGL.so.1.0.0 libGL.so
from /usr/lib, but I still see OpenGL support : NO in the GUI group of the configuration summary using CMake GUI. Could anybody please tell me the right steps to overcome this issue?
Thanks in advance,
Did you apply as well the patch to cuda_gl_interop.h
as shown by @Andrey1984 in post#3, cleaned, reconfigured, rebuilt and reinstalled opencv ?
This patch, I assume, is required after the fact, by that what I mean is, in case you get error during compilation, But my problem is during configure using CMake. CMake is not showing OpenGL support enabled. I have installed GTK GL modules using $sudo apt-get install libgtkgl* and also have created the link using $sudo ln -sf /usr/lib/aarch64-linux-gnu/libGL.so.1.0.0 libGL.so. Still no luck.
I think it is needless to say that I checked the box ENABLE_OPENGL in CMake.
Hi @caruofc
could you share the output of the list of the commands below, please?
sudo apt install mlocate -y
sudo updatedb
locate libGL.so
/usr/NX/scripts/vgl/libGL.so
/usr/lib/libGL.so
/usr/lib/aarch64-linux-gnu/libGL.so
/usr/lib/aarch64-linux-gnu/libGL.so.1
/usr/lib/aarch64-linux-gnu/libGL.so.1.0.0
among these /usr/lib/libGL.so is the link that I made which points to /usr/lib/aarch64-linux-gnu/libGL.so.1.0.0
have you tried the patch?
Not yet, do you want me to try that? I was assuming it would probably not gonna work as it is more for compile time error. I haven’t got to that point yet. I am trying the patch right now. will update you soon
Did not work. following is the configuration output of CMake. Does it have any other dependencies?
General configuration for OpenCV 4.4.0 =====================================
Version control: unknown
Platform:
Timestamp: 2020-10-21T00:57:41Z
Host: Linux 4.9.140-tegra aarch64
CMake: 3.10.2
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release
CPU/HW features:
Baseline: NEON FP16
required: NEON
disabled: VFPV3
C/C++:
Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: /usr/bin/c++ (ver 7.5.0)
C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,–gc-sections -Wl,–as-needed
Linker flags (Debug): -Wl,–gc-sections -Wl,–as-needed
ccache: NO
Precompiled headers: NO
Extra dependencies: m pthread cudart_static dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda/lib64 -L/usr/lib/aarch64-linux-gnu
3rdparty dependencies:
OpenCV modules:
To be built: alphamat aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 quality rapid reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab world xfeatures2d ximgproc xobjdetect xphoto
Disabled: -
Disabled by dependency: -
Unavailable: cnn_3dobj cvv hdf java js julia matlab ovis python3 python3 viz
Applications: tests perf_tests apps
Documentation: NO
Non-free algorithms: NO
GUI:
GTK+: YES (ver 3.22.30)
GThread : YES (ver 2.56.4)
GtkGlExt: NO
OpenGL support: NO
VTK support: NO
Media I/O:
ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
JPEG: libjpeg-turbo (ver 2.0.5-62)
WEBP: build (ver encoder: 0x020f)
PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.34)
TIFF: build (ver 42 - 4.0.10)
JPEG 2000: build Jasper (ver 1.900.1)
OpenEXR: build (ver 2.3.0)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
DC1394: NO
FFMPEG: YES
avcodec: YES (57.107.100)
avformat: YES (57.83.100)
avutil: YES (55.78.100)
swscale: YES (4.8.100)
avresample: YES (3.7.0)
GStreamer: YES (1.14.5)
v4l/v4l2: YES (linux/videodev2.h)
Parallel framework: pthreads
Trace: YES (with Intel ITT)
Other third-party libraries:
Lapack: NO
Eigen: YES (ver 3.3.4)
Custom HAL: YES (carotene (ver 0.0.1))
Protobuf: build (3.5.1)
NVIDIA CUDA: YES (ver 10.0, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 72
NVIDIA PTX archs:
cuDNN: YES (ver 7.6.3)
OpenCL: YES (no extra features)
Include path: /home/nvidia/Documents/opencv-4.4.0/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.17)
Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.17)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
install path: lib/python2.7/dist-packages/cv2/python-2.7
Python (for build): /usr/bin/python2.7
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: /usr/local
Configuring done
I just have tried on TX2, same result. I do not understand why configuration summary is showing NO support enabled for OpenGL despite of setting WITH_OPENGL and also having libGL.so in the right place presumably.
@caruofc
what is the exact cmake command being executed? could you paste the full command, please?
Moreover, you may try to use newest cmake as 3.10 is a somewhat obsolete version.
apt-get purge cmake -y && apt autoremove -y && wget https://github.com/Kitware/CMake/releases/download/v3.19.0-rc1/cmake-3.19.0-rc1.tar.gz && tar -zxvf cmake-3.19.0-rc1.tar.gz && cd cmake-3.19.0-rc1 && ./bootstrap && make && make install
However, we will try to setup opencv with gl on the newest Jetpack release.
What are the exact steps to reproduce the error?
I think that OpenGL support in opencv depends on QT backend.
So when configuring, try to define: WITH_QT=ON
[EDIT: QT is not mandatory. GTK2 may be better. See this later post]
@Andrey1984, I used CMake-gui which I find most convenient as visually I can see all options and select accordingly, less error prune. One extra component that I configure is cuDNN which I haven’t seen selected in the posted cmake command argument list. Not sure if that has any affect what so ever. However, I am not compiling with Qt to respond to your question @Honey_Patouceul, and by the way, my application is a non-Qt application. So do not want to compile it with WITH_QT=ON. My CMake version is 3.14.7, What CMake command you suggest to try? Can you please post it?
the arguments in the probable command could vary
there are examples in the forum threads, but once it got confirmed locally a bit later it will be possible to share an exact command.
Moreover, you may like to use newest opencv 4.5.0,
obsolete examples were like