Ask Your Question
0

GPU Face Detection Error

asked 2017-07-10 12:45:51 -0600

I need help with an error in my simple GPU face detection program. The CPU version of this code runs fine with the same CascadeClassifier. This program is running on a NVIDIA TX2.

Error: OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/core/src/persistence.cpp, line 5008 terminate called after throwing an instance of 'cv::Exception' what(): /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/core/src/persistence.cpp:5008: error: (-2) The node does not represent a user object (unknown type?) in function cvRead

Code :

#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include<opencv2/highgui/highgui.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <opencv2/gpu/gpumat.hpp>
#include <stdlib.h>
#include <chrono>
#include <iostream> 

int main()
{

using std::chrono::duration_cast;
    using std::chrono::nanoseconds;
    typedef std::chrono::high_resolution_clock clock;


cv::Mat img = cv::imread("lena.tiff",CV_LOAD_IMAGE_GRAYSCALE);
cv::equalizeHist(img,img);
auto start = clock::now();

cv::gpu::GpuMat image_gpu(img);


cv::gpu::CascadeClassifier_GPU face_detector_gpu("/usr/share/OpenCV/haarcascades/haarcascade_frontalface_default.xml");


cv::gpu::GpuMat objbuf;
int detections = face_detector_gpu.detectMultiScale(image_gpu, objbuf);

cv::Mat obj_host;
objbuf.colRange(0,detections).download(obj_host);

cv::Rect* gpu_faces = obj_host.ptr<cv::Rect>();
for (int i=0;i<detections;i++)
    cv::rectangle(img,gpu_faces[i],cv::Scalar(255));


auto end = clock::now();
    std::cout << duration_cast<nanoseconds>(end-start).count()/1000000 << "ms\n";


cv::imshow("img",img);
cv::waitKey();

return 0;

}

Compiled with: g++ -std=c++11 main.cpp -I/usr/include -lopencv_core -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_objdetect -o main

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-10 12:52:46 -0600

berak gravatar image

updated 2017-07-10 12:55:31 -0600

you'll have to use an xml file from here for anything using cuda.

(long time ago, they updated the cascade format to use e.g. lbp cascades as well, unfortunately, the cuda branch was left behind, and you can only use "old-style" cascades (generated from opencv_haartraining), not the "new" one (generated from opencv_traincascade)

(it's a "data" error, nothing to do with your code)

edit flag offensive delete link more

Comments

Thank you for the response, this makes sense. I currently have OpenCV 2.4 running on my TX2, do I have to upgrade to OpenCV 3.0 or higher to have access to this other xml file? I was not able to download it from the link you sent.

AlexMagsam gravatar imageAlexMagsam ( 2017-07-10 13:28:32 -0600 )edit

replace "blob" with "raw" in any of that github links, like this: https://raw.githubusercontent.com/ope...

(most probably, you'll get redirected to the proper src)

berak gravatar imageberak ( 2017-07-10 13:39:00 -0600 )edit

What next, copy the source code to a new xml file? I tried this and did not work.

AlexMagsam gravatar imageAlexMagsam ( 2017-07-10 13:57:12 -0600 )edit

OpenCV Error: Gpu API call (NCV Assertion Failed: cudaError_t=18, file=/hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/nvidia/NPP_staging/NPP_staging.cu, line=337 ) in NCVDebugOutputHandler, file /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/cascadeclassifier.cpp, line 173 terminate called after throwing an instance of 'cv::Exception' what(): /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/cascadeclassifier.cpp:173: error: (-217) NCV Assertion Failed: cudaError_t=18, file=/hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/src/nvidia/NPP_staging/NPP_staging.cu, line=337 in function NCVDebugOutputHandler

AlexMagsam gravatar imageAlexMagsam ( 2017-07-10 13:58:11 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-07-10 12:45:51 -0600

Seen: 869 times

Last updated: Jul 10 '17