OpenCV VideoCapture failed to open a file, how to determine reason? - opencv

Using C++ OpenCV I was just trying to open a video file in Cygwin environment. For some reason file is not getting opened i.e. isOpened() is always false.
I checked for "ffmpeg -codecs" output within cygwin and it displays all available video codecs.
Video exists in the directory and I verified physically
Still unable to open the video file. To debug this issue can I see the error number that get set when videocapture fails to open the file.
#include <opencv2/opencv.hpp>
#include <iostream>
int main( int argc, char* argv[] ) {
//Tried with both namedWindow and without namedWindow command
//cv::namedWindow( "Video", cv::WINDOW_AUTOSIZE );
cv::VideoCapture capture( argv[1], cv::CAP_FFMPEG );
if (!capture.isOpened())
{
std::cout << "Unable to open the file " << argv[1] << std::endl;
**std::cout << "Reason for catpure fails is " << ???????**
exit(0);
}
std::cout << "Opened " << argv[1] << std::endl;
capture.release();
}
Note : I have not installed ffmpeg in cygwin environment. Instead I have ffmpeg in my Windows 10 and I had included the same in my Windows PATH environment. Within cygwin I am able to execute ffmpeg command
General configuration for OpenCV 3.4.1 =====================================
Version control: unknown
Platform:
Timestamp: 2021-01-19T11:33:15Z
Host: CYGWIN 3.1.7(0.340/5/3) x86_64
CMake: 3.17.3
CMake generator: Ninja
CMake build tool: /usr/bin/ninja.exe
Configuration: RelWithDebInfo
CPU/HW features:
Baseline: SSE SSE2 SSE3
requested: SSE3
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (3 files): + SSSE3 SSE4_1
SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (4 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (0 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++11: YES
C++ Compiler: /usr/bin/g++.exe (ver 10.2.0)
C++ flags (Release): -fpermissive -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fpermissive -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/gcc.exe
C flags (Release): -ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fdebug-prefix-map=/pub/devel/opencv/v3.4/opencv-3.4.1-3.x86_64/build=/usr/src/debug/opencv-3.4.1-3 -fdebug-prefix-map=/pub/devel/opencv/v3.4/opencv-3.4.1-3.x86_64/src/opencv-3.4.1=/usr/src/debug/opencv-3.4.1-3 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fdebug-prefix-map=/pub/devel/opencv/v3.4/opencv-3.4.1-3.x86_64/build=/usr/src/debug/opencv-3.4.1-3 -fdebug-prefix-map=/pub/devel/opencv/v3.4/opencv-3.4.1-3.x86_64/src/opencv-3.4.1=/usr/src/debug/opencv-3.4.1-3 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release):
Linker flags (Debug):
ccache: NO
Precompiled headers: NO
Extra dependencies: dl m pthread rt
3rdparty dependencies:
OpenCV modules:
To be built: aruco bgsegm bioinspired calib3d ccalib core datasets dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching tracking ts video videoio videostab ximgproc xobjdetect xphoto
Disabled: dnn js world
Disabled by dependency: dnn_objdetect text
Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv dnn_modern java matlab ovis sfm viz
Applications: tests apps
Documentation: NO
Non-free algorithms: NO
GUI:
GTK+: YES (ver 3.22.28)
GThread : YES (ver 2.54.3)
GtkGlExt: NO
VTK support: NO
Media I/O:
ZLib: /lib/libz.dll.a (ver 1.2.11)
JPEG: /lib/libjpeg.dll.a (ver )
WEBP: /lib/libwebp.dll.a (ver encoder: 0x020e)
PNG: /lib/libpng.dll.a (ver 1.6.37)
TIFF: /lib/libtiff.dll.a (ver 42 / 4.2.0)
JPEG 2000: /lib/libjasper.dll.a (ver 2.0.14)
OpenEXR: build (ver 1.7.1)
Video I/O:
GStreamer:
base: YES (ver 1.12.5)
video: YES (ver 1.12.5)
app: YES (ver 1.12.5)
riff: YES (ver 1.12.5)
pbutils: YES (ver 1.12.5)
gPhoto2: NO
Parallel framework: pthreads
Trace: YES (with Intel ITT)
Other third-party libraries:
Lapack: NO
Eigen: YES (ver 3.3.9)
Custom HAL: NO
Protobuf: build (3.5.1)
NVIDIA CUDA: NO
OpenCL: YES (no extra features)
Include path: /usr/include/CL
Link libraries: Dynamic load
Python 2:
Interpreter: /usr/bin/python2.7.exe (ver 2.7.18)
Libraries: /lib/libpython2.7.dll.a (ver 2.7.18)
numpy: /usr/lib/python2.7/site-packages/numpy/core/include (ver 1.16.2)
packages path: lib/python2.7/site-packages
Python 3:
Interpreter: /usr/bin/python3 (ver 3.8.7)
Libraries: /lib/libpython3.8.dll.a (ver 3.8.7)
numpy: /usr/lib/python3.8/site-packages/numpy/core/include (ver 1.19.4)
packages path: lib/python3.8/site-packages
Python (for build): /usr/bin/python2.7.exe
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Matlab: NO
Install to: /usr
-----------------------------------------------------------------

Related

Problems on inference using GPU with OpenCV dnn and ONNX model

I am trying to inference on a Jetson Xavier with OpenCV dnn. I have converted a YOLOv5m model to .onnx format . Afterwards I attempt to run inference with the model using the following codes with optimizations for GPU using CUDA AND cuDNN:
net = cv2.dnn.readNetFromONNX(yolov5m.onnx)
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
However in inference on Jetson Xavier with MAXN power mode, on a 1280 X 720 resolution video, my detections are very slow (approximately 109ms per frame). Using Jetson Power GUI I see that the usage of GPU is very low (on most frames less than 20% of GPU).
Also running the code without (cv2.dnn.DNN_BACKEND_CUDA)and setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA), which means defaulting to use of CPU, shows that CPU usage is very high on every frame of video. GPU usage then becomes minimal.
I have also compiled OpenCV for running with CUDA and cuDNN, using this Git.
OpenCV build information is as follows:
General configuration for OpenCV 4.6.0 =====================================
Version control: eb1afab-dirty
Extra modules:
Location (extra): /home/jetsonjane/master/JEP/script/workspace/opencv_contrib-4.6.0/modules
Version control (extra): eb1afab-dirty
Platform:
Timestamp: 2022-09-18T13:43:39Z
Host: Linux 5.10.65-tegra aarch64
CMake: 3.16.3
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: RELEASE
CPU/HW features:
Baseline: NEON FP16
C/C++:
Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: /usr/bin/c++ (ver 9.4.0)
C++ flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -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 -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -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 -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -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 -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -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 -Wl,--no-undefined
Linker flags (Debug): -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
ccache: NO
Precompiled headers: NO
Extra dependencies: m pthread cudart_static dl rt nppc nppial nppicc nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda-11.4/lib64 -L/usr/lib/aarch64-linux-gnu
3rdparty dependencies:
OpenCV modules:
To be built: aruco barcode 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 hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python2 python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
Disabled: world
Disabled by dependency: -
Unavailable: alphamat cvv java julia matlab ovis sfm ts viz
Applications: apps
Documentation: NO
Non-free algorithms: NO
GUI: GTK2
GTK+: YES (ver 2.24.32)
GThread : YES (ver 2.64.6)
GtkGlExt: NO
VTK support: NO
Media I/O:
ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)
WEBP: build (ver encoder: 0x020f)
PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.37)
TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
JPEG 2000: build (ver 2.4.0)
OpenEXR: /usr/lib/aarch64-linux-gnu/libImath.so /usr/lib/aarch64-linux-gnu/libIlmImf.so /usr/lib/aarch64-linux-gnu/libIex.so /usr/lib/aarch64-linux-gnu/libHalf.so /usr/lib/aarch64-linux-gnu/libIlmThread.so (ver 2_3)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
DC1394: YES (2.2.5)
FFMPEG: YES
avcodec: YES (58.54.100)
avformat: YES (58.29.100)
avutil: YES (56.31.100)
swscale: YES (5.5.100)
avresample: YES (4.0.0)
GStreamer: YES (1.16.3)
v4l/v4l2: YES (linux/videodev2.h)
Parallel framework: pthreads
Trace: YES (with Intel ITT)
Other third-party libraries:
Lapack: NO
Eigen: NO
Custom HAL: YES (carotene (ver 0.0.1))
Protobuf: build (3.19.1)
NVIDIA CUDA: YES (ver 11.4, CUFFT CUBLAS)
NVIDIA GPU arch: 72 87
NVIDIA PTX archs:
cuDNN: YES (ver 8.3.2)
OpenCL: YES (no extra features)
Include path: /home/jetsonjane/master/JEP/script/workspace/opencv-4.6.0/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.18)
Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.18)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.5)
install path: lib/python2.7/dist-packages/cv2/python-2.7
Python 3:
Interpreter: /usr/bin/python3 (ver 3.8.10)
Libraries: /usr/lib/aarch64-linux-gnu/libpython3.8.so (ver 3.8.10)
numpy: /home/jetsonjane/.local/lib/python3.8/site-packages/numpy/core/include (ver 1.19.4)
install path: lib/python3.8/site-packages/cv2/python-3.8
Python (for build): /usr/bin/python2.7
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: /usr/local
-----------------------------------------------------------------
Also during inference with the code I can see that 1 cuda device is recognized by the system:
count = cv2.cuda.getCudaEnabledDeviceCount()
print(count)
1
Are there any steps in configuration of CUDA,cuDNN,OpenCV that I am missing?
I would be thankful for any insights or solutions.

C++ code running in ubuntu much slower than in Windows 10

I have a dual boot PC with Windows 10 and ubuntu 20.04 on same SSD. I build OpenCV 4.5.5 with contrib model in both platforms using same configuration (cmake config). My aim is to compare the performance of c++ program using OpenCV ximgproc functions in both platforms. To my surprise, the code is running much faster in Windows 10 than in ubuntu 20.04 (almost twice as fast). Do you know anything I can tune the Linux build so I can get similar performance?
On Windows 10, I use Visual Studio 2019, with latest updates. On ubuntu, I use the default g++ 9.4 from repos. The test code that I use is as follows (remove all error checking for simplicity):
…
try {
cv::Mat h_src = cv::imread(image_path, cv::IMREAD_GRAYSCALE);
cv::Mat img_thres_cmb;
int blockSize = 95, k = 1.5;
int type = cv::THRESH_BINARY_INV;
int method = cv::ximgproc::BINARIZATION_WOLF;
auto t3 = cv::getTickCount();
cv::ximgproc::niBlackThreshold(h_src, img_thres_cmb, 255, type, blockSize, k, method);
auto t4 = cv::getTickCount();
auto cpu_sgmnt = (t4 - t3) / cv::getTickFrequency();
std::cout << "[cpu_sgmnt]: [ " << cpu_sgmnt << " ] secs." << std::endl;
}
catch (const cv::Exception& ex) {
std::cout << "Error: " << ex.what() << std::endl;
}
…
The c++ code is very simple, it basically calls the OpenCV function niBlackThreshold which is compiled by OpenCV’s build system. I get the exact same result from both platforms, the only issue I have now is that the ubuntu version is running too slow. I test also on utunbu 16.04, 18.04, 21.04 and the runtime performance is the same as in 20.04.
You input and help is greatly appreciated.
Thanks and with Best Regards
Luke
//////////////////////////////////////////
Add info about build:
ubuntu 20.04
$ g++ test_ocv_2.cpp pkg-config --libs --cflags opencv4 -o test_ocv
$ pkg-config --libs --cflags opencv4
-I/usr/local/include/opencv4 -L/usr/local/lib -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_barcode -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_cudabgsegm -lopencv_cudafeatures2d -lopencv_cudaobjdetect -lopencv_cudastereo -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_cudacodec -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_videostab -lopencv_cudaoptflow -lopencv_optflow -lopencv_cudalegacy -lopencv_videoio -lopencv_cudawarping -lopencv_wechat_qrcode -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_cudaimgproc -lopencv_cudafilters -lopencv_imgproc -lopencv_cudaarithm -lopencv_core -lopencv_cudev
$ ./test_ocv 17218619999_r1c7_8k.png out.png
General configuration for OpenCV 4.5.5 =====================================
Version control: unknown
Extra modules:
Location (extra): /home/hologic/source/OpenCV/opencv_contrib-4.5.5/modules
Version control (extra): unknown
Platform:
Timestamp: 2022-05-03T21:57:05Z
Host: Linux 5.13.0-40-generic x86_64
CMake: 3.16.3
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release
CPU/HW features:
Baseline: SSE SSE2 SSE3
requested: SSE3
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (18 files): + SSSE3 SSE4_1
SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (33 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: /usr/bin/c++ (ver 9.4.0)
C++ flags (Release): -fsigned-char -ffast-math -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 -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -ffast-math -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 -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fsigned-char -ffast-math -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 -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -ffast-math -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 -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed
Linker flags (Debug): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed
ccache: NO
Precompiled headers: NO
Extra dependencies: m pthread cudart_static dl rt nppc nppial nppicc nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda/lib64 -L/usr/lib/x86_64-linux-gnu
3rdparty dependencies:
OpenCV modules:
To be built: aruco barcode 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 fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
Disabled: world
Disabled by dependency: -
Unavailable: alphamat cvv freetype java julia matlab ovis python2 python3 sfm viz
Applications: tests perf_tests apps
Documentation: NO
Non-free algorithms: YES
GUI: NONE
GTK+: NO
OpenGL support: NO
VTK support: NO
Media I/O:
ZLib: build (ver 1.2.11)
JPEG: build-libjpeg-turbo (ver 2.1.2-62)
WEBP: build (ver encoder: 0x020f)
PNG: build (ver 1.6.37)
TIFF: build (ver 42 - 4.2.0)
JPEG 2000: build (ver 2.4.0)
OpenEXR: build (ver 2.3.0)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
DC1394: NO
FFMPEG: YES
avcodec: YES (58.54.100)
avformat: YES (58.29.100)
avutil: YES (56.31.100)
swscale: YES (5.5.100)
avresample: YES (4.0.0)
GStreamer: YES (1.16.2)
v4l/v4l2: YES (linux/videodev2.h)
Parallel framework: pthreads
Trace: YES (with Intel ITT)
Other third-party libraries:
Intel IPP: 2020.0.0 Gold [2020.0.0]
at: /home/hologic/source/OpenCV/opencv_build-4.5.5/3rdparty/ippicv/ippicv_lnx/icv
Intel IPP IW: sources (2020.0.0)
at: /home/hologic/source/OpenCV/opencv_build-4.5.5/3rdparty/ippicv/ippicv_lnx/iw
VA: NO
Lapack: NO
Eigen: NO
Custom HAL: NO
Protobuf: build (3.19.1)
NVIDIA CUDA: YES (ver 11.4, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 70 75 80 86
NVIDIA PTX archs:
cuDNN: YES (ver 8.2.4)
OpenCL: YES (no extra features)
Include path: /home/hologic/source/OpenCV/opencv-4.5.5/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python (for build): /home/hologic/anaconda3/bin/python
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: /usr/local
[cpu_sgmnt]: [ 2.20123 ] secs.
//////////////////////////////////////////////
Windows 10
Copy of VS 2019 build property in Linker | Output section:
/OUT:"C:\Users\HLX\source\repos\cuda_ocv\x64\Release\cuda_ocv.exe" /MANIFEST /LTCG:incremental /NXCOMPAT /PDB:"C:\Users\HLX\source\repos\cuda_ocv\x64\Release\cuda_ocv.pdb" /DYNAMICBASE "opencv_core455.lib" "opencv_highgui455.lib" "opencv_imgcodecs455.lib" "opencv_imgproc455.lib" "opencv_videoio455.lib" "opencv_cudaarithm455.lib" "opencv_cudaimgproc455.lib" "opencv_cudafilters455.lib" "opencv_ximgproc455.lib" "nppig.lib" "nppif.lib" "cudart_static.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "cudart.lib" "cudadevrt.lib" /DEBUG /MACHINE:X64 /OPT:REF /PGD:"C:\Users\HLX\source\repos\cuda_ocv\x64\Release\cuda_ocv.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Release\cuda_ocv.exe.intermediate.manifest" /LTCGOUT:"x64\Release\cuda_ocv.iobj" /OPT:ICF /ERRORREPORT:PROMPT /ILK:"x64\Release\cuda_ocv.ilk" /NOLOGO /LIBPATH:"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\lib\x64" /LIBPATH:"C:\Users\HLX\source\OpenCV\opencv_build-4.5.5\install\x64\vc16\lib" /TLBID:1
(comment: The solution originally was created originally to support OpenCV GPU with cuda, but for this test, I don't use any of the GPU support in OpenCV, refer to code in my original post)
C:\Users\HLX\source\repos\cuda_ocv\x64\Release>cuda_ocv.exe D:\images\17218619999_r1c7_8k.png out.png
General configuration for OpenCV 4.5.5 =====================================
Version control: unknown
Extra modules:
Location (extra): C:/Users/HLX/source/OpenCV/opencv_contrib-4.5.5/modules
Version control (extra): unknown
Platform:
Timestamp: 2022-04-14T15:02:00Z
Host: Windows 10.0.19044 AMD64
CMake: 3.23.0
CMake generator: Visual Studio 16 2019
CMake build tool: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
MSVC: 1929
Configuration: Debug Release
CPU/HW features:
Baseline: SSE SSE2 SSE3
requested: SSE3
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (18 files): + SSSE3 SSE4_1
SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (33 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe (ver 19.29.30141.0)
C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP /MD /O2 /Ob2 /DNDEBUG
C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP /MDd /Zi /Ob0 /Od /RTC1
C Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /MP /MD /O2 /Ob2 /DNDEBUG
C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /MP /MDd /Zi /Ob0 /Od /RTC1
Linker flags (Release): /machine:x64 /INCREMENTAL:NO
Linker flags (Debug): /machine:x64 /debug /INCREMENTAL
ccache: NO
Precompiled headers: YES
Extra dependencies: cudart_static.lib nppc.lib nppial.lib nppicc.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cudnn.lib cufft.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64
3rdparty dependencies:
OpenCV modules:
To be built: aruco barcode 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 fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
Disabled: world
Disabled by dependency: -
Unavailable: alphamat cvv freetype java julia matlab ovis python2 sfm viz
Applications: tests perf_tests apps
Documentation: NO
Non-free algorithms: YES
Windows RT support: NO
GUI: WIN32UI
Win32 UI: YES
OpenGL support: YES (opengl32 glu32)
VTK support: NO
Media I/O:
ZLib: build (ver 1.2.11)
JPEG: build-libjpeg-turbo (ver 2.1.2-62)
WEBP: build (ver encoder: 0x020f)
PNG: build (ver 1.6.37)
TIFF: build (ver 42 - 4.2.0)
JPEG 2000: build (ver 2.4.0)
OpenEXR: build (ver 2.3.0)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
DC1394: NO
FFMPEG: YES (prebuilt binaries)
avcodec: YES (58.134.100)
avformat: YES (58.76.100)
avutil: YES (56.70.100)
swscale: YES (5.9.100)
avresample: YES (4.0.0)
GStreamer: NO
DirectShow: YES
Media Foundation: YES
DXVA: YES
Parallel framework: Concurrency
Trace: YES (with Intel ITT)
Other third-party libraries:
Intel IPP: 2020.0.0 Gold [2020.0.0]
at: C:/Users/HLX/source/OpenCV/opencv_build-4.5.5/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: sources (2020.0.0)
at: C:/Users/HLX/source/OpenCV/opencv_build-4.5.5/3rdparty/ippicv/ippicv_win/iw
Lapack: NO
Eigen: NO
Custom HAL: NO
Protobuf: build (3.19.1)
NVIDIA CUDA: YES (ver 11.4, CUFFT CUBLAS NVCUVID FAST_MATH)
NVIDIA GPU arch: 60 61 70 75 80 86
NVIDIA PTX archs:
cuDNN: YES (ver 8.2.4)
OpenCL: YES (NVD3D11)
Include path: C:/Users/HLX/source/OpenCV/opencv-4.5.5/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 3:
Interpreter: C:/Anaconda3/python.exe (ver 3.9.7)
Libraries: C:/Anaconda3/libs/python39.lib (ver 3.9.7)
numpy: C:/Anaconda3/lib/site-packages/numpy/core/include (ver 1.20.3)
install path: C:/Anaconda3/Lib/site-packages/cv2/python-3.9
Python (for build): C:/Anaconda3/python.exe
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: C:/Users/HLX/source/OpenCV/opencv_build-4.5.5/install
[cpu_sgmnt]: [ 1.42901 ] secs.

Compiling OpenCV creates cuda error - recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o' failed

I'm trying to compile openCV but it doesn't seem to work somehow.
Is this a problem with cuda?
I am running this in a docker-container (nvidia-docker)
Hardware is a Jetson Nano with newest JetPack - Version
What could that problem be?
[ 32%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o
In file included from /opencv/modules/core/src/opengl.cpp:48:0:
/usr/local/cuda/include/cuda_gl_interop.h:63:2: error: #error Please include the appropriate gl headers before including cuda_gl_interop.h
#error Please include the appropriate gl headers before including cuda_gl_interop.h
^~~~~
[ 32%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/out.cpp.o
In file included from /opencv/modules/core/include/opencv2/core/private.cuda.hpp:73:0,
from /opencv/modules/core/src/precomp.hpp:56,
from /opencv/modules/core/src/opengl.cpp:43:
/opencv/modules/core/src/opengl.cpp: In function ‘void cv::cuda::setGlDevice(int)’:
/opencv/modules/core/src/opengl.cpp:118:47: warning: ‘cudaError_t cudaGLSetGLDevice(int)’ is deprecated [-Wdeprecated-declarations]
cudaSafeCall( cudaGLSetGLDevice(device) );
^
/opencv/modules/core/include/opencv2/core/cuda/common.hpp:74:58: note: in definition of macro ‘cudaSafeCall’
#define cudaSafeCall(expr) cv::cuda::checkCudaError(expr, __FILE__, __LINE__, CV_Func)
^~~~
In file included from /opencv/modules/core/src/opengl.cpp:48:0:
/usr/local/cuda/include/cuda_gl_interop.h:305:57: note: declared here
extern __CUDA_DEPRECATED __host__ cudaError_t CUDARTAPI cudaGLSetGLDevice(int device);
^~~~~~~~~~~~~~~~~
modules/core/CMakeFiles/opencv_core.dir/build.make:1368: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o' failed
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:2763: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
Some info:
General configuration for OpenCV 4.1.1 =====================================
-- Version control: unknown
--
-- Extra modules:
-- Location (extra): /opencv_contrib/modules
-- Version control (extra): unknown
--
-- Platform:
-- Timestamp: 2020-01-06T00:19:08Z
-- 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++ Compiler: /usr/bin/c++ (ver 7.4.0)
-- C++ flags (Release): -fsigned-char -ffast-math -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 -ffast-math -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 -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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 -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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
-- Linker flags (Debug): -Wl,--gc-sections
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: m pthread /usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so cudart_static -lpthread dl rt /usr/local/cuda/lib64/stubs/libcuda.so nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda/lib64 -L/usr/lib/aarch64-linux-gnu
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 quality reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: cnn_3dobj hdf java js matlab ovis python2 sfm ts viz
-- Applications: apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- GUI:
-- QT: YES (ver 5.9.5)
-- QT OpenGL support: YES (Qt5::OpenGL 5.9.5)
-- GTK+: NO
-- OpenGL support: YES (/usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so)
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
-- JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)
-- WEBP: build (ver encoder: 0x020e)
-- PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.34)
-- TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
-- JPEG 2000: build (ver 1.900.1)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
-- DC1394: YES (2.2.5)
-- FFMPEG: YES
-- avcodec: YES (57.107.100)
-- avformat: YES (57.83.100)
-- avutil: YES (55.78.100)
-- swscale: YES (4.8.100)
-- avresample: NO
-- GStreamer: YES (1.14.5)
-- v4l/v4l2: YES (linux/videodev2.h)
--
-- Parallel framework: TBB (ver 2017.0 interface 9107)
--
-- 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: 53
-- NVIDIA PTX archs:
--
-- cuDNN: NO
--
-- OpenCL: YES (no extra features)
-- Include path: /opencv/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 3:
-- Interpreter: /usr/bin/python3.6 (ver 3.6.9)
-- Libraries: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (ver 3.6.9)
-- numpy: /usr/local/lib/python3.6/dist-packages/numpy/core/include (ver 1.18.0)
-- install path: lib/python3.6/dist-packages/cv2/python-3.6
--
-- Python (for build): /usr/bin/python3.6
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: /usr/local
-- -----------------------------------------------------------------
I'd really appreciate some help, i couldn't find anything on the web sadly
Big thanks!
The solution was to use the nvidia-libraries.
So i took the lib-files from the JetPack download-folder
and used them
-worked!

Raspberry pi 3B OpenCV 3.4.1 Empty screen/frame

I am new to StackOverflow in that this is my first post. I am hoping that I am abiding by the rules as such and that I am not frustrating anyone with me double-posting an issue.
My problem is the following. I was able to compile and install OpenCV 3.4.1. on my Raspberry Pi 3B. The only problem I was not able to solve is that when I test the camera (by viewing the cam-feed through OpenCV) I get an empty frame. Rarely it does flicker, and show the actual camera feed.
I have a screenshot to show what I mean:
What you can also see is that when I make a image, by using the video.py script and pressing "enter", it does produce the correct image. When I move the frame around (with the cursor) it seems to be flickering more (revealing the actual camera feed more often) than usual. I have tried reinstalling NOOBS, recompiling and reinstalling more times than I can recall. What could the problem be? If I missed sharing relevant information, please let me know!
Thank you soooo much for your time!
Kind regards, Pieter
Edit: Here is the print-out when running opencv_version -v in the terminal
opencv_version -v
General configuration for OpenCV 3.4.1 =====================================
Version control: unknown
Platform:
Timestamp: 2018-09-29T19:02:09Z
Host: Linux 4.14.71-v7+ armv7l
CMake: 3.7.2
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: RELEASE
CPU/HW features:
Baseline:
requested: DETECT
disabled: VFPV3 NEON
C/C++:
Built as dynamic libs?: YES
C++11: YES
C++ Compiler: /usr/bin/c++ (ver 6.3.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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfp16-format=ieee -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfp16-format=ieee -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=non-virtual-dtor -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-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfp16-format=ieee -fvisibility=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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfp16-format=ieee -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release):
Linker flags (Debug):
ccache: NO
Precompiled headers: YES
Extra dependencies: dl m pthread rt
3rdparty dependencies:
OpenCV modules:
To be built: calib3d core dnn features2d flann highgui imgcodecs imgproc java_bindings_generator ml objdetect photo python3 python_bindings_generator shape stitching superres video videoio videostab
Disabled: js python2 world
Disabled by dependency: -
Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java ts viz
Applications: examples apps
Documentation: NO
Non-free algorithms: NO
GUI:
GTK+: YES (ver 2.24.31)
GThread : YES (ver 2.50.3)
GtkGlExt: NO
VTK support: NO
Media I/O:
ZLib: /usr/lib/arm-linux-gnueabihf/libz.so (ver 1.2.8)
JPEG: /usr/lib/arm-linux-gnueabihf/libjpeg.so (ver )
WEBP: build (ver encoder: 0x020e)
PNG: /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.6.28)
TIFF: /usr/lib/arm-linux-gnueabihf/libtiff.so (ver 42 / 4.0.8)
JPEG 2000: /usr/lib/arm-linux-gnueabihf/libjasper.so (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
Video I/O:
DC1394: NO
FFMPEG: YES
avcodec: YES (ver 57.64.101)
avformat: YES (ver 57.56.101)
avutil: YES (ver 55.34.101)
swscale: YES (ver 4.2.100)
avresample: NO
GStreamer: NO
libv4l/libv4l2: NO
v4l/v4l2: linux/videodev2.h
gPhoto2: NO
Parallel framework: pthreads
Trace: YES (built-in)
Other third-party libraries:
Lapack: NO
Eigen: NO
Custom HAL: YES (carotene (ver 0.0.1))
Protobuf: build (3.5.1)
OpenCL: YES (no extra features)
Include path: /home/pi/opencv-3.4.1/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 3:
Interpreter: /usr/bin/python3 (ver 3.5.3)
Libraries: /usr/lib/arm-linux-gnueabihf/libpython3.5m.so (ver 3.5.3)
numpy: /home/pi/.local/lib/python3.5/site-packages/numpy/core/include (ver 1.15.2)
packages path: lib/python3.5/dist-packages
Python (for build): /usr/bin/python3
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Matlab: NO
Install to: /usr/local
-----------------------------------------------------------------

Can't access webcam OpenCV 3.3 Python 3

OpenCV on Python 2.7 has no problem accessing my webcam. For some reason it can't in Python 3. VideoCapture::read always returns none...
I even tried compiling from source.
This is my cmake (I don't think I did anything wrong):
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D WITH_V4L=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D PYTHON_EXECUTABLE3=/usr/bin/python3.6
-D PYTHON_EXECUTABLE2=/usr/bin/python2.7
-D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib64/python3.6/site-packages/numpy/core/include \
-D BUILD_EXAMPLES=ON ..
Has anything changed betwen implementations that could indicate whats causing my problems?
Edit:
As requested:
% python3.6 -c 'import cv2; print(cv2.getBuildInformation())'
General configuration for OpenCV 3.3.0
=====================================
Version control: 3.3.0
Extra modules:
Location (extra): /io/opencv_contrib/modules
Version control (extra): 3.3.0
Platform:
Timestamp: 2017-09-03T11:00:53Z
Host: Linux 4.4.0-83-generic x86_64
CMake: 3.9.0
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/gmake
Configuration: Release
CPU/HW features:
Baseline: SSE SSE2 SSE3
requested: SSE3
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2
requested: SSE4_1 SSE4_2 AVX FP16 AVX2
SSE4_1 (2 files): + SSSE3 SSE4_1
SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (7 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
C/C++:
Built as dynamic libs?: NO
C++ Compiler: /opt/rh/devtoolset-2/root/usr/bin/c++ (ver 4.8.2)
C++ flags (Release): -fPIC -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fPIC -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /opt/rh/devtoolset-2/root/usr/bin/cc
C flags (Release): -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release):
Linker flags (Debug):
ccache: NO
Precompiled headers: YES
Extra dependencies: /opt/Qt4.8.7/lib/libQtGui.so /opt/Qt4.8.7/lib/libQtTest.so /opt/Qt4.8.7/lib/libQtCore.so /lib64/libz.so stdc++ dl m pthread rt
3rdparty dependencies: ittnotify libprotobuf libjpeg libwebp libpng libtiff libjasper IlmImf
OpenCV modules:
To be built: core flann imgproc ml objdetect phase_unwrapping photo plot reg surface_matching video xphoto bgsegm dnn face fuzzy img_hash imgcodecs shape videoio xobjdetect highgui superres bioinspired dpm features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo structured_light tracking videostab xfeatures2d ximgproc aruco optflow stitching python3
Disabled: world contrib_world
Disabled by dependency: -
Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 ts viz cnn_3dobj cvv dnn_modern freetype hdf matlab sfm
GUI:
QT 4.x: YES (ver 4.8.7 EDITION = OpenSource)
QT OpenGL support: NO
OpenGL support: NO
VTK support: NO
Media I/O:
ZLib: /lib64/libz.so (ver 1.2.3)
JPEG: libjpeg (ver 90)
WEBP: build (ver encoder: 0x020e)
PNG: build (ver 1.6.24)
TIFF: build (ver 42 - 4.0.2)
JPEG 2000: build (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
GDAL: NO
GDCM: NO
Video I/O:
DC1394 1.x: NO
DC1394 2.x: NO
FFMPEG: NO
avcodec: NO
avformat: NO
avutil: NO
swscale: NO
avresample: NO
GStreamer: NO
OpenNI: NO
OpenNI PrimeSensor Modules: NO
OpenNI2: NO
PvAPI: NO
GigEVisionSDK: NO
Aravis SDK: NO
UniCap: NO
UniCap ucil: NO
V4L/V4L2: NO/NO
XIMEA: NO
Xine: NO
Intel Media SDK: NO
gPhoto2: NO
Parallel framework: pthreads
Trace: YES (with Intel ITT)
Other third-party libraries:
Use Intel IPP: NO
Use Intel IPP IW: NO
Use Intel IPP Async: NO
Use VA: NO
Use Intel VA-API/OpenCL: NO
Use Lapack: NO
Use Eigen: NO
Use Cuda: NO
Use OpenCL: YES
Use OpenVX: NO
Use custom HAL: NO
OpenCL: <Dynamic loading of OpenCL library>
Include path: /io/opencv/3rdparty/include/opencl/1.2
Use AMDFFT: NO
Use AMDBLAS: NO
Python 2:
Interpreter: NO
Python 3:
Interpreter: python (ver 3.6.0)
Libraries:
numpy: /opt/python/cp36-cp36m/lib/python3.6/site-packages/numpy/core/include (ver 1.11.3)
packages path: /opt/python/cp36-cp36m/lib/python3.6/site-packages
Python (for build): python
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Matlab: Matlab not found or implicitly disabled
Tests and samples:
Tests: NO
Performance tests: NO
C/C++ Examples: NO
Install path: /usr/local
cvconfig.h is in: /io/opencv/build
-----------------------------------------------------------------
Followed this guide: https://www.scivision.co/anaconda-python-opencv3/
Removed all failed attempts with pip before installing.
Make sure that the commands you execute in the guide above use the version of python you are targeting. Either alias python to python36 or replace it in the commands.

Resources