error . A case of face recognition program to test the camera

ubuntu@tegra-ubuntu:~$ cd opencv-3.1.0
ubuntu@tegra-ubuntu:~/opencv-3.1.0$ cd samples/gpu
ubuntu@tegra-ubuntu:~/opencv-3.1.0/samples/gpu$ g++ cascadeclassifier.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o cascadeclassifier
/tmp/ccJSAQZM.o: In function convertAndResize(cv::cuda::GpuMat const&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, double)': cascadeclassifier.cpp:(.text+0x494): undefined reference to cv::cuda::Stream::Null()’
cascadeclassifier.cpp:(.text+0x4b0): undefined reference to cv::cuda::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int, cv::cuda::Stream&)' cascadeclassifier.cpp:(.text+0x550): undefined reference to cv::cuda::Stream::Null()’
cascadeclassifier.cpp:(.text+0x574): undefined reference to cv::cuda::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int, cv::cuda::Stream&)' /tmp/ccJSAQZM.o: In function matPrint(cv::Mat&, int, cv::Scalar_, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)':
cascadeclassifier.cpp:(.text+0x674): undefined reference to cv::getTextSize(cv::String const&, int, double, int, int*)' cascadeclassifier.cpp:(.text+0x740): undefined reference to cv::putText(cv::InputOutputArray const&, cv::String const&, cv::Point, int, double, cv::Scalar
, int, int, bool)’
cascadeclassifier.cpp:(.text+0x7ac): undefined reference to cv::putText(cv::_InputOutputArray const&, cv::String const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)' /tmp/ccJSAQZM.o: In function main’:
cascadeclassifier.cpp:(.text+0xe8c): undefined reference to cv::cuda::getCudaEnabledDeviceCount()' cascadeclassifier.cpp:(.text+0xed8): undefined reference to cv::cuda::getDevice()’
cascadeclassifier.cpp:(.text+0xedc): undefined reference to cv::cuda::printShortCudaDeviceInfo(int)' cascadeclassifier.cpp:(.text+0x11e0): undefined reference to cv::cuda::CascadeClassifier::create(cv::String const&)’
cascadeclassifier.cpp:(.text+0x1208): undefined reference to cv::CascadeClassifier::load(cv::String const&)' cascadeclassifier.cpp:(.text+0x12c4): undefined reference to cv::imread(cv::String const&, int)’
cascadeclassifier.cpp:(.text+0x1338): undefined reference to cv::error(int, cv::String const&, char const*, char const*, int)' cascadeclassifier.cpp:(.text+0x1368): undefined reference to cv::VideoCapture::open(cv::String const&)’
cascadeclassifier.cpp:(.text+0x13c0): undefined reference to cv::error(int, cv::String const&, char const*, char const*, int)' cascadeclassifier.cpp:(.text+0x1434): undefined reference to cv::error(int, cv::String const&, char const*, char const*, int)’
cascadeclassifier.cpp:(.text+0x1458): undefined reference to cv::namedWindow(cv::String const&, int)' cascadeclassifier.cpp:(.text+0x1494): undefined reference to cv::cuda::GpuMat::defaultAllocator()’
cascadeclassifier.cpp:(.text+0x14a4): undefined reference to cv::cuda::GpuMat::defaultAllocator()' cascadeclassifier.cpp:(.text+0x14b4): undefined reference to cv::cuda::GpuMat::defaultAllocator()’
cascadeclassifier.cpp:(.text+0x14c4): undefined reference to cv::cuda::GpuMat::defaultAllocator()' cascadeclassifier.cpp:(.text+0x15b0): undefined reference to cv::cuda::GpuMat::upload(cv::InputArray const&)’
cascadeclassifier.cpp:(.text+0x16c0): undefined reference to cv::cuda::Stream::Null()' cascadeclassifier.cpp:(.text+0x17e8): undefined reference to cv::CascadeClassifier::detectMultiScale(cv::InputArray const&, std::vector<cv::Rect, std::allocator<cv::Rect
> >&, double, int, int, cv::Size
, cv::Size_)’
cascadeclassifier.cpp:(.text+0x1ba0): undefined reference to cv::imshow(cv::String const&, cv::_InputArray const&)' /tmp/ccJSAQZM.o: In function cv::String::String(char const*)‘:
cascadeclassifier.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x40): undefined reference to cv::String::allocate(unsigned long)' /tmp/ccJSAQZM.o: In function cv::String::~String()’:
cascadeclassifier.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x10): undefined reference to cv::String::deallocate()' /tmp/ccJSAQZM.o: In function cv::String::String(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)‘:
cascadeclassifier.cpp:(.text._ZN2cv6StringC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN2cv6StringC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x54): undefined reference to cv::String::allocate(unsigned long)' /tmp/ccJSAQZM.o: In function cv::cuda::GpuMat::~GpuMat()’:
cascadeclassifier.cpp:(.text._ZN2cv4cuda6GpuMatD2Ev[_ZN2cv4cuda6GpuMatD5Ev]+0x10): undefined reference to `cv::cuda::GpuMat::release()’
collect2: error: ld returned 1 exit status

i don’t know how to solve it.can you give me a favor.

One possible cause could be that it builds against opencv4tegra-2.4 that is installed in standard path /usr.
You may try to pass explicit paths to g++ :

g++ -I<path_to_opencv3.1.0_includes> cascadeclassifier.cpp -L<path_to_opencv3.1.0_libs> -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o cascadeclassifier

Note that you may also have to add path to opencv-3.1.0 libs to your shell environment variable LD_LIBRARY_PATH for execution of your application.

Hi,

Some required libraries are missing.

Based on the source code, more cuda libraries should be linked.

#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/cudaobjdetect.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/cudawarping.hpp"

Try this:

g++ cascadeclassifier.cpp -I/usr/local/include/ -L./../../release/lib/ -lopencv_objdetect -lopencv_imgproc -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio -lopencv_cudaobjdetect -lopencv_cudaimgproc -lopencv_cudawarping

ubuntu@tegra-ubuntu:~/opencv-3.1.0/samples/gpu$ g++ cascadeclassifier.cpp -L./usr/local/lib/ -lopencv_objdetect -lopencv_imgproc -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio -lopencv_cudaobjdetect -lopencv_cudaimgproc -lopencv_cudawarping
/usr/bin/ld: warning: libopencv_imgproc.so.3.1, needed by //usr/local/lib/libopencv_imgcodecs.so, may conflict with libopencv_imgproc.so.2.4
/usr/bin/ld: /tmp/ccCzKRl0.o: undefined reference to symbol ‘_ZN2cv7putTextERKNS_17_InputOutputArrayERKNS_6StringENS_6Point_IiEEidNS_7Scalar_IdEEiib’
//usr/local/lib/libopencv_imgproc.so.3.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

ubuntu@tegra-ubuntu:~/opencv-3.1.0/samples/gpu$ g++ cascadeclassifier.cpp -L./usr/local/lib -lopencv_objdetect -lopencv_imgproc -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio -lopencv_cudaobjdetect -lopencv_cudaimgproc -lopencv_cudawarping
/usr/bin/ld: warning: libopencv_imgproc.so.3.1, needed by //usr/local/lib/libopencv_imgcodecs.so, may conflict with libopencv_imgproc.so.2.4
/usr/bin/ld: /tmp/ccc39eO4.o: undefined reference to symbol ‘_ZN2cv7putTextERKNS_17_InputOutputArrayERKNS_6StringENS_6Point_IiEEidNS_7Scalar_IdEEiib’
//usr/local/lib/libopencv_imgproc.so.3.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

that means conflict? how can i fix it

Hi,

You can remove opencv4tegra by

sudo apt-get purge libopencv4tegra-dev libopencv4tegra
sudo apt-get purge libopencv4tegra-repo
sudo apt-get update

Thanks.

Assuming you’ve installed opencv-3.1.0 into /usr/local, you should be able to build it only changing:

g++ cascadeclassifier.cpp -L<b>.</b>/usr/local/lib -lopencv_objdetect -lopencv_imgproc -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio -lopencv_cudaobjdetect -lopencv_cudaimgproc -lopencv_cudawarping

to

g++ <b>-I/usr/local/include</b> cascadeclassifier.cpp <b>-L/usr/local/lib</b> -lopencv_objdetect -lopencv_imgproc -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio -lopencv_cudaobjdetect -lopencv_cudaimgproc -lopencv_cudawarping <b>-o cascadeclassifier</b>

If you don’t need it, removing opencv4tegra would avoid later issues with pkg-config.

Thanks for your help.now, i wan to
./cascadeclassifier --cascade ~/opencv-3.1.0/data/haarcascades/haarcascade_frontalface_alt.xml --camera 1
but

ubuntu@tegra-ubuntu:~/opencv-3.1.0/samples/gpu$ ./cascadeclassifier --cascade ~/opencv-3.1.0/data/haarcascades/haarcascade_frontalface_alt.xml --camera 0
Device 0: “NVIDIA Tegra X1” 3995Mb, sm_53, Driver/Runtime ver.8.0/8.0
OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file /home/ubuntu/opencv-3.1.0/modules/core/src/persistence.cpp, line 4976
terminate called after throwing an instance of ‘cv::Exception’
what(): /home/ubuntu/opencv-3.1.0/modules/core/src/persistence.cpp:4976: error: (-2) The node does not represent a user object (unknown type?) in function cvRead

Aborted

i’m very appreciate for your help.

Hi,

cv::cuda::CascadeClassifier only support old haar classifier format.
Please find model in this page:

Thanks.

Thanks for your patience,you help me solve the problem!

Hello AastaLLL

Is what you wrote in this post still true ? i.e. that only Haar cascade can be used with cv::cuda::CascadeClassifier. If that is the case then it contradicts the function description here: //docs.opencv.org/3.1.0/d9/d80/classcv_1_1cuda_1_1CascadeClassifier.html#details which says that LBP cascades can be used as well.

Please let me know: I am using openCV-3.1.0 with Cuda 9.0.

Hi,

This topic is discussing the format of HAAR cascades.
There are two possible data format of HAAR cascades and only older one is supported.

Thanks.

Hi

So what do I need to do to get an answer to my question about LBP classifiers ?

Hi,

You can get more information from OpenCV developer:

If LBP is listed as a supported feature, it’s recommended to give it a try.
Thanks.