Hi,
This function detectMultiScale works fine on GTX cards, Jetson TX1, TX2 devices (Pascale) but not on the Jetson Xavier (Volta).
On the Jetson Xavier, I am trying to get the following snippet working but it did not.
-
On opencv-3.4.2 : the function detectMultiscale is hanging on, after cout << “Before detectMultiScacle” << endl;
- On opencv-4.0 : the function detectMultscale crashes
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.0.1-dev) /home/nvidia/d970evo/tmp/opencv/modules/core/include/opencv2/core/private.cuda.hpp:113: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function 'throw_no_cuda'
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat frame = imread("images/lena_color_512.tif", cv::IMREAD_COLOR);
if (frame.empty()) {
cout << "Could not open an image" << endl;
return -1;
}
cv::Ptr<cv::cuda::CascadeClassifier> cascade_face = cv::cuda::CascadeClassifier::create("haarcascade_frontalface_alt2.xml");
std::vector<Rect> faces;
cv::Mat frame_gray;
cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
equalizeHist(frame_gray, frame_gray);
cv::cuda::GpuMat objs;
cv::cuda::GpuMat frame_gpu(frame_gray);
cv::cuda::Stream stream;
if (frame_gpu.empty()) {
cout << "Could not upload an image to GPU" << endl;
return -1;
}
cout << "Before detectMultiScacle" << endl;
cascade_face->detectMultiScale(frame_gpu, objs);
cout << "After detectMultiScacle" << endl;
cascade_face->convert(objs, faces);
cout << "detected rectangles: " << faces.size() << endl;
return 0;
}
Any help would be appreciated!
Thanks in advance
Hi, ndnparis
Could you try the following code?
Because, we can know the build configuration of OpenCV by this output.
#include <opencv2/core.hpp>
#include <iostream>
int main(int argc, const char* argv[])
{
std::cout << cv::getBuildInformation() << std::endl;
return 0;
}
Hi,
Thanks a lot for your reply.
Could I ask you a favour? Could you give my snippet sample a try on your Jetson Xavier, please?
Perhaps the function detectMultiScale is not available with the new Volta architecture? I think that opencv is not yet available for the CUDA_ARCH_BIN=“7.2” / CUDA_ARCH_PTX=“7.2”. But only Nvidia support can confirm that.
Please find the following results obtained with the getBuildInformation() on the Jetson Xavier.
opencv-3.4.0
General configuration for OpenCV 3.4.0 =====================================
Version control: unknown
Extra modules:
Location (extra): /home/nvidia/tmp/opencv_contrib/modules
Version control (extra): unknown
Platform:
Timestamp: 2018-12-23T09:15:36Z
Host: Linux 4.9.108-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++11: YES
C++ Compiler: /usr/bin/c++ (ver 7.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 -Wno-implicit-fallthrough -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -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=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 -Wno-implicit-fallthrough -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=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 -Wno-implicit-fallthrough -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release):
Linker flags (Debug):
ccache: NO
Precompiled headers: YES
Extra dependencies: dl m pthread rt cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda-10.0/lib64
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 datasets dnn dpm face features2d flann freetype fuzzy highgui img_hash imgcodecs imgproc 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 text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
Disabled: js world
Disabled by dependency: -
Unavailable: cnn_3dobj cvv dnn_modern hdf java matlab ovis sfm viz
Applications: tests apps
Documentation: NO
Non-free algorithms: NO
GUI:
QT: YES (ver 4.8.7 EDITION = OpenSource)
QT OpenGL support: NO
GTK+: 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 )
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 1.7.1)
Video I/O:
DC1394: YES (ver 2.2.5)
FFMPEG: YES
avcodec: YES (ver 57.107.100)
avformat: YES (ver 57.83.100)
avutil: YES (ver 55.78.100)
swscale: YES (ver 4.8.100)
avresample: YES (ver 3.7.0)
GStreamer:
base: YES (ver 1.14.1)
video: YES (ver 1.14.1)
app: YES (ver 1.14.1)
riff: YES (ver 1.14.1)
pbutils: YES (ver 1.14.1)
libv4l/libv4l2: NO
v4l/v4l2: linux/videodev2.h
gPhoto2: NO
Parallel framework: pthreads
Trace: YES (built-in)
Other third-party libraries:
Lapack: NO
Eigen: YES (ver 3.3.4)
Custom HAL: YES (carotene (ver 0.0.1))
NVIDIA CUDA: YES (ver 10.0, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 72
NVIDIA PTX archs:
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.15)
Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.15rc1)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
packages path: lib/python2.7/dist-packages
Python 3:
Interpreter: /usr/bin/python3 (ver 3.6.7)
Libraries: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (ver 3.6.7)
numpy: /home/nvidia/.local/lib/python3.6/site-packages/numpy/core/include (ver 1.14.5)
packages path: lib/python3.6/dist-packages
Python (for build): /usr/bin/python2.7
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Matlab: NO
Install to: /usr/local
-----------------------------------------------------------------
opencv-4.0.1-dev
General configuration for OpenCV 4.0.1-dev =====================================
Version control: 4.0.1-1-ge1f5b886f
Extra modules:
Location (extra): /home/nvidia/tmp/opencv_contrib/modules
Version control (extra): 4.0.0-28-g25221244
Platform:
Timestamp: 2018-12-22T16:56:54Z
Host: Linux 4.9.108-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.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 -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffast-math -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffast-math -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=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 -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -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 -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release):
Linker flags (Debug):
ccache: NO
Precompiled headers: YES
Extra dependencies: m pthread cudart_static -lpthread dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda-10.0/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 datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy gapi 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 text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
Disabled: world
Disabled by dependency: -
Unavailable: cnn_3dobj cvv hdf java js matlab ovis sfm viz
Applications: tests apps
Documentation: NO
Non-free algorithms: NO
GUI:
QT: YES (ver 4.8.7 EDITION = OpenSource)
QT OpenGL support: NO
GTK+: 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: 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 1.7.1)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
DC1394: YES (ver 2.2.5)
FFMPEG: YES
avcodec: YES (ver 57.107.100)
avformat: YES (ver 57.83.100)
avutil: YES (ver 55.78.100)
swscale: YES (ver 4.8.100)
avresample: YES (ver 3.7.0)
GStreamer:
base: YES (ver 1.14.1)
video: YES (ver 1.14.1)
app: YES (ver 1.14.1)
riff: YES (ver 1.14.1)
pbutils: YES (ver 1.14.1)
v4l/v4l2: linux/videodev2.h
Parallel framework: pthreads
Trace: YES (built-in)
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: 61 70 72
NVIDIA PTX archs: 61 70 72
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.15)
Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.15rc1)
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 3:
Interpreter: /usr/bin/python3 (ver 3.6.7)
Libraries: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (ver 3.6.7)
numpy: /home/nvidia/.local/lib/python3.6/site-packages/numpy/core/include (ver 1.14.5)
install path: lib/python3.6/dist-packages/cv2/python-3.6
Python (for build): /usr/bin/python2.7
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: /usr/local
-----------------------------------------------------------------
Hi WayneWWW,
Thanks for your help.
I have just installed opencv-4.0 with your script install_opencv4.0.0_Xavier.sh.
Unfornately, I always have the same errors with opencv-4.0.
Device 0: "Xavier" 15827Mb, sm_72, Driver/Runtime ver.10.0/10.0
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.0.0) /home/nvidia/d970evo/tmp/opencv-4.0.0/modules/core/include/opencv2/core/private.cuda.hpp:113: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function 'throw_no_cuda'
Aborted (core dumped)
Hi,
Are you sure there is cuda installed on your device? Can you run any cuda sample from jetpack?
Please note that we don’t guarantee the functionality of openCV. You could also refer to openCV forum for checking similar topics.
I read source code of OpenCV. In conclusion, I think that this is a issue of OpenCV.
At first, CUDA_DISABLER is defined in cascadeclassifier.cpp.
[url]opencv_contrib/cascadeclassifier.cpp at 4.0.1 · opencv/opencv_contrib · GitHub
As a result, cv::cuda::CascadeClassifier::create() always calls throw_no_cuda().
[url]opencv_contrib/cascadeclassifier.cpp at 4.0.1 · opencv/opencv_contrib · GitHub
Hi WayneWWW, dandelion1124
Yes, there is Cuda installed on my device and it was installed with Jetpack. Some functionnalities still work but I don’t think they are really for the Jetson Xavier (as described below about CUDA_GENERATION & CUDA_ARCH).
kernel.cu
#include <stdio.h>
#include <memory>
#include <iostream>
#include <cuda_runtime.h>
int main(int argc, char **argv)
{
int device_Count = 0;
cudaGetDeviceCount(&device_Count);
if (device_Count == 0) {
printf("No available device(s) that support CUDA\n");
}
else {
printf("Detected %d CUDA Capable device(s)\n", device_Count);
}
int device, driver_Version = 0, runtime_Version = 0;
for (device = 0; device < device_Count; ++device)
{
cudaSetDevice(device);
cudaDeviceProp device_Property;
cudaGetDeviceProperties(&device_Property, device);
printf("\nDevice %d: \"%s\"\n", device, device_Property.name);
// Console log
cudaDriverGetVersion(&driver_Version);
cudaRuntimeGetVersion(&runtime_Version);
printf("Driver Version / Runtime Version %d.%d / %d.%d\n", driver_Version / 1000, (driver_Version % 100) / 10, runtime_Version / 1000, (runtime_Version % 100) / 10);
printf("CUDA Capability Major/Minor version number: %d.%d\n", device_Property.major, device_Property.minor);
}
}
./kernel
Detected 1 CUDA Capable device(s)
Device 0: "Xavier"
Driver Version / Runtime Version 10.0 / 10.0
CUDA Capability Major/Minor version number: 7.2
As showed in the file ./opencv-4.0.0/cmake/OpenCVDetectCUDA.cmake, there is CUDA_GENERATION Volta but there is no __cuda_arch_bin “7.2” for the Jetson Xavier.
set(__cuda_arch_ptx "")
if(CUDA_GENERATION STREQUAL "Fermi")
set(__cuda_arch_bin "2.0")
elseif(CUDA_GENERATION STREQUAL "Kepler")
set(__cuda_arch_bin "3.0 3.5 3.7")
elseif(CUDA_GENERATION STREQUAL "Maxwell")
set(__cuda_arch_bin "5.0 5.2")
elseif(CUDA_GENERATION STREQUAL "Pascal")
set(__cuda_arch_bin "6.0 6.1")
elseif(CUDA_GENERATION STREQUAL "Volta")
set(__cuda_arch_bin "7.0")
elseif(CUDA_GENERATION STREQUAL "Turing")
set(__cuda_arch_bin "7.5")
elseif(CUDA_GENERATION STREQUAL "Auto")
As showed in the file ./opencv-4.0.0/cmake/OpenCVDetectCUDA.cmake, there is CUDA_GENERATION Volta but there is no __cuda_arch_bin “7.2” for the Jetson Xavier.
This issue was resolved in OpenCV 4.0.1.
Plese refer to https://github.com/opencv/opencv/pull/13430.
Hi dandelion1124,
I have just installed opencv-4.0.1 and I always have the same errors. As you can can see that I am under opencv-4.0.1.
I don’t know if the compiler & linker (PTX) have also taken in consideration about sm_72.
Device 0: "Xavier" 15827Mb, sm_72, Driver/Runtime ver.10.0/10.0
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.0.1) /home/nvidia/d970evo/tmp/opencv/modules/core/include/opencv2/core/private.cuda.hpp:113: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function 'throw_no_cuda'
FYI
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.0.1'
At first, CUDA_DISABLER is defined in cascadeclassifier.cpp.
https://github.com/opencv/opencv_contrib/blob/4.0.1/modules/cudaobjdetect/src/cascadeclassifier.cpp#L44
As a result, cv::cuda::CascadeClassifier::create() always calls throw_no_cuda().
https://github.com/opencv/opencv_contrib/blob/4.0.1/modules/cudaobjdetect/src/cascadeclassifier.cpp#L49-L54
This problem has not been fixed in OpenCV 4.0.1.
Maybe this problems may not occur with OpenCV 3.4.5.
If you try to build OpenCV 3.4.5, you need to add the following flag to CMake.
-D CUDA_ARCH_BIN="7.2" -D CUDA_ARCH_PTX=""
Hi dandelion1124,
Likes in opencv-3.4.2, the function detectMultiscale is hanging in opencv-3.4.5.
They are not compatible with Jetson Xavier.
Anyway, thanks a lot for your help.
Hi WayneWWW,
On the opencv.org, I just found this interesting topic about opencv-4 : What's the future of cuda modules after Opencv 4 - OpenCV Q&A Forum
So this means that, at present and in the near future, there is no OpenCV-CUDA for the Jetson Xavier (and all systems built around an Nvidia Volta GPU). Is that right?
[b][b][/b][/b]
Thanks in advance
- On opencv-3.4.2 : the function detectMultiscale is hanging on, after cout << “Before detectMultiScacle” << endl;
- On opencv-4.0 : the function detectMultscale crashes
I think that these problem is a issue of OpenCV.
terminate called after throwing an instance of ‘cv::Exception’
what(): OpenCV(4.0.0) /home/nvidia/d970evo/tmp/opencv-4.0.0/modules/core/include/opencv2/core/private.cuda.hpp:113: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function ‘throw_no_cuda’
And, the following problem is reproduced even if it is not Volta GPU.
So, I think that it is better to report to https://github.com/opencv/opencv/ instead of this forum.