openalpr / openalpr

Automatic License Plate Recognition library
http://www.openalpr.com
GNU Affero General Public License v3.0
11.01k stars 2.49k forks source link

Compiling issues with Cuda or COMPILE_GPU=1 #438

Open 770R opened 7 years ago

770R commented 7 years ago

I've been trying to compile the project with GPU usage for a few days now. Found out that a few header files were missing namespace std, that fixed most errors, then it moved on to the last and most annoying error of them all.

openalpr/libopenalpr.so.2: undefined reference to cv::gpu::GpuMat::download(cv::Mat&) const' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::GpuMat::upload(cv::Mat const&)' openalpr/libopenalpr.so.2: undefined reference to cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU()' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::CascadeClassifierGPU::detectMultiScale(cv::gpu::GpuMat const&, cv::gpu::GpuMat&, double, int, cv::Size)' openalpr/libopenalpr.so.2: undefined reference to cv::gpu::GpuMat::GpuMat(cv::gpu::GpuMat const&, cv::Range, cv::Range)' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::CascadeClassifier_GPU::load(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)' openalpr/libopenalpr.so.2: undefined reference to cv::gpu::CascadeClassifier_GPU::~CascadeClassifier_GPU()' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::GpuMat::release()' collect2: error: ld returned 1 exit status CMakeFiles/alprd.dir/build.make:209: recipe for target 'alprd' failed make[2]: [alprd] Error 1 CMakeFiles/Makefile2:69: recipe for target 'CMakeFiles/alprd.dir/all' failed make[1]: [CMakeFiles/alprd.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... openalpr/libopenalpr.so.2: undefined reference to cv::gpu::GpuMat::download(cv::Mat&) const' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::GpuMat::upload(cv::Mat const&)' openalpr/libopenalpr.so.2: undefined reference to cv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU()' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::CascadeClassifierGPU::detectMultiScale(cv::gpu::GpuMat const&, cv::gpu::GpuMat&, double, int, cv::Size)' openalpr/libopenalpr.so.2: undefined reference to cv::gpu::GpuMat::GpuMat(cv::gpu::GpuMat const&, cv::Range, cv::Range)' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::CascadeClassifier_GPU::load(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)' openalpr/libopenalpr.so.2: undefined reference to cv::gpu::CascadeClassifier_GPU::~CascadeClassifier_GPU()' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::GpuMat::release()' collect2: error: ld returned 1 exit status CMakeFiles/alpr.dir/build.make:130: recipe for target 'alpr' failed make[2]: [alpr] Error 1 CMakeFiles/Makefile2:108: recipe for target 'CMakeFiles/alpr.dir/all' failed make[1]: [CMakeFiles/alpr.dir/all] Error 2 Makefile:149: recipe for target 'all' failed make: [all] Error 2 root@nms:/home/nms/openalpr/src/build#

Bit of background, originally used OpenCV 3.2 & Cuda 8, then assumed OpenCV might be glitching and recompiled it on version 3.1 & CUDA 8. Tried adding in header file for gpumat, still no luck. Resorting to asking for help. Thanks in advance

770R commented 7 years ago

Forgot to mention, whenever I tried to cmake it with -DCOMPILE_GPU=1, it always told me "manually set flag won't be used -DCOMPILE_GPU=1". That originally made me assume that OpenCV wasn't correctly compiled. Got around the error by making it default in the code.

matthill commented 7 years ago

It appears that your OpenCV is not compiled with GPU support enabled. That's what the undefined reference messages are saying. You've compiled everything together, but the code is linked to things that don't exist in your OpenCV binaries.

codestamp commented 7 years ago

Just want to ask here whether the gpu support gets enabled if I configure opencv using WITH_CUDA=ON option? I

limon71 commented 6 years ago

Friends i have the same problem in a board nvidia tk1 , ubuntu 14 jetpack 3.1

****error to compile openalpr*****

[ 63%] Building CXX object CMakeFiles/alpr.dir/main.cpp.o Linking CXX executable alpr openalpr/libopenalpr.so.2: undefined reference to cv::gpu::GpuMat::download(cv::Mat&) const' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::CascadeClassifier_GPU::load(std::string const&)' openalpr/libopenalpr.so.2: undefined reference to cv::gpu::GpuMat::GpuMat(cv::gpu::GpuMat const&, cv::Range, cv::Range)' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::GpuMat::upload(cv::Mat const&)' openalpr/libopenalpr.so.2: undefined reference to cv::gpu::CascadeClassifier_GPU::detectMultiScale(cv::gpu::GpuMat const&, cv::gpu::GpuMat&, double, int, cv::Size_<int>)' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::CascadeClassifier_GPU::CascadeClassifier_GPU()' openalpr/libopenalpr.so.2: undefined reference to cv::gpu::CascadeClassifier_GPU::~CascadeClassifier_GPU()' openalpr/libopenalpr.so.2: undefined reference tocv::gpu::GpuMat::release()' collect2: error: ld returned 1 exit status make[2]: [alpr] Error 1 make[1]: [CMakeFiles/alpr.dir/all] Error 2 make: *** [all] Error 2

ubuntu@tegra-ubuntu:~$ python --version Python 3.4.3 :: Continuum Analytics, Inc.

"OPencv compile 3.2 with Cuda 6.5, from jetpack 3.1"

cmake -DWITH_CUDA=ON -DCUDA_ARCH_BIN="3.2" -D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D CUDA_ARCH_PTX="" -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D WITH_CUBLAS=ON ..

"compile openalpr"

cmake -DWITH_UTILITIES=OFF -D WITH_GPU_DETECTOR=ON -D WITH_DAEMON=OFF -D WITH_TESTS=OFF -D CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -g -Og" .

****General configuration for OpenCV 3.2.0*** Version control: unknown

Platform: Timestamp: 2017-11-17T01:23:59Z Host: Linux 3.10.40-ga7da876 armv7l CMake: 2.8.12.2 CMake generator: Unix Makefiles CMake build tool: /usr/bin/make Configuration: Release

C/C++: Built as dynamic libs?: YES C++ Compiler: /usr/bin/c++ (ver 4.8.4) 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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-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 -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-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 -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG Linker flags (Release):
Linker flags (Debug):
ccache: NO Precompiled headers: YES Extra dependencies: /usr/lib/arm-linux-gnueabihf/libpng.so /usr/lib/arm-linux-gnueabihf/libz.so /usr/lib/arm-linux-gnueabihf/libtiff.so /usr/lib/arm-linux-gnueabihf/libjasper.so /usr/lib/arm-linux-gnueabihf/libjpeg.so /usr/lib/arm-linux-gnueabihf/libImath.so /usr/lib/arm-linux-gnueabihf/libIlmImf.so /usr/lib/arm-linux-gnueabihf/libIex.so /usr/lib/arm-linux-gnueabihf/libHalf.so /usr/lib/arm-linux-gnueabihf/libIlmThread.so gtk-x11-2.0 gdk-x11-2.0 atk-1.0 gio-2.0 pangoft2-1.0 pangocairo-1.0 gdk_pixbuf-2.0 cairo pango-1.0 fontconfig gobject-2.0 glib-2.0 freetype gthread-2.0 gstbase-1.0 gstreamer-1.0 gstvideo-1.0 gstapp-1.0 gstriff-1.0 gstpbutils-1.0 dc1394 avcodec avformat avutil swscale dl m pthread rt tbb cudart nppc nppi npps cublas cufft -L/usr/local/cuda-6.5/lib 3rdparty dependencies: libwebp tegra_hal

OpenCV modules: To be built: cudev core cudaarithm flann imgproc ml video cudabgsegm cudafilters cudaimgproc cudawarping imgcodecs photo shape videoio cudacodec highgui objdetect features2d calib3d cudafeatures2d cudalegacy cudaobjdetect cudaoptflow cudastereo stitching superres videostab python2 python3 Disabled: world Disabled by dependency: - Unavailable: java ts viz

GUI: QT: NO GTK+ 2.x: YES (ver 2.24.23) GThread : YES (ver 2.40.2) GtkGlExt: NO OpenGL support: 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 0.3.1) PNG: /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.2.50) TIFF: /usr/lib/arm-linux-gnueabihf/libtiff.so (ver 42 - 4.0.3) JPEG 2000: /usr/lib/arm-linux-gnueabihf/libjasper.so (ver 1.900.1) OpenEXR: /usr/lib/arm-linux-gnueabihf/libImath.so /usr/lib/arm-linux-gnueabihf/libIlmImf.so /usr/lib/arm-linux-gnueabihf/libIex.so /usr/lib/arm-linux-gnueabihf/libHalf.so /usr/lib/arm-linux-gnueabihf/libIlmThread.so (ver 1.6.1) GDAL: NO GDCM: NO

Video I/O: DC1394 1.x: NO DC1394 2.x: YES (ver 2.2.1) FFMPEG: YES avcodec: YES (ver 54.35.1) avformat: YES (ver 54.20.4) avutil: YES (ver 52.3.0) swscale: YES (ver 2.1.1) avresample: NO GStreamer:
base: YES (ver 1.2.4) video: YES (ver 1.2.4) app: YES (ver 1.2.4) riff: YES (ver 1.2.4) pbutils: YES (ver 1.2.4) OpenNI: NO OpenNI PrimeSensor Modules: NO OpenNI2: NO PvAPI: NO GigEVisionSDK: NO Aravis SDK: NO UniCap: NO UniCap ucil: NO V4L/V4L2: NO/YES XIMEA: NO Xine: NO gPhoto2: NO

Parallel framework: TBB (ver 4.2 interface 7000)

Other third-party libraries: Use IPP: NO Use VA: NO Use Intel VA-API/OpenCL: NO Use Lapack: NO Use Eigen: YES (ver 3.2.0) Use Cuda: YES (ver 6.5) Use OpenCL: YES Use OpenVX: NO Use custom HAL: YES (carotene (ver 0.0.1))

NVIDIA CUDA Use CUFFT: YES Use CUBLAS: YES USE NVCUVID: NO NVIDIA GPU arch: 32 NVIDIA PTX archs: Use fast math: YES

OpenCL: Include path: /home/ubuntu/opencv-3.2.0/3rdparty/include/opencl/1.2 Use AMDFFT: NO Use AMDBLAS: NO

Python 2: Interpreter: /usr/bin/python2.7 (ver 2.7.6) Libraries: /usr/lib/arm-linux-gnueabihf/libpython2.7.so (ver 2.7.6) numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.2) packages path: lib/python2.7/dist-packages

Python 3: Interpreter: /home/ubuntu/miniconda3/bin/python3.4 (ver 3.4.3) Libraries: /usr/lib/arm-linux-gnueabihf/libpython3.4m.so (ver 3.4.3) numpy: /home/ubuntu/miniconda3/lib/python3.4/site-packages/numpy/core/include (ver 1.9.2) packages path: lib/python3.4/site-packages

Python (for build): /usr/bin/python2.7

Java: ant: NO JNI: NO Java wrappers: NO Java tests: NO

Matlab: Matlab not found or implicitly disabled

Documentation: Doxygen: NO

Tests and samples: Tests: NO Performance tests: NO C/C++ Examples: NO

Install path: /usr/local

cvconfig.h is in: /home/ubuntu/opencv-3.2.0/release

THanks for all me friends

frank