Ask Your Question

Revision history [back]

OpenCV Error: Gpu API call

Hello,

I am using openCV for my first time, and I'm having some problems. The matter is that I want to use the CUDA functionallity, but it gives me an error:

OpenCV Error: Gpu API call (NCV Assertion Failed: NcvStat=25, file=/home/alex/Downloads/opencv-3.0.0/modules/cudalegacy/src/cuda/NCVHaarObjectDetection.cu, line=2421) in NCVDebugOutputHandler, file /home/alex/Downloads/opencv-3.0.0/modules/cudaobjdetect/src/cascadeclassifier.cpp, line 156
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/alex/Downloads/opencv-3.0.0/modules/cudaobjdetect/src/cascadeclassifier.cpp:156: error: (-217) NCV Assertion Failed: NcvStat=25, file=/home/alex/Downloads/opencv-3.0.0/modules/cudalegacy/src/cuda/NCVHaarObjectDetection.cu, line=2421 in function NCVDebugOutputHandler

What I'm trying to do is only to measure the time that CUDA lasts to process my image, here is the code:

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

#include <iostream>
#include <time.h>

using namespace std;
using namespace cv;


int main(){

    vector<Rect> faces;
    Mat image = imread("image.jpg");
    Mat imageGray;
    cuda::GpuMat imageGPU(image);
    String s = "cuda.xml";

    Ptr<cuda::CascadeClassifier> _faceCascade = cuda::CascadeClassifier::create("cuda.xml");

    cuda::GpuMat objectBuffer;
    clock_t t_ini, t_fin;
    double secs;

    t_ini = clock();
    _faceCascade->detectMultiScale(imageGPU, objectBuffer);
    t_fin = clock();

    _faceCascade->convert(objectBuffer, faces);

    secs = (double)(t_fin - t_ini) / CLOCKS_PER_SEC;
    cout << secs * 1000 << "milliseconds" << endl;

    for (int i = 0; i < int(faces.size()); i++){
        cv::rectangle(image, faces[i], Scalar(255));
    }



    imshow("Result", image);
    waitKey(0);

    return 0;

}

I'm working with Eclipse and CUDA 7.5

Thanks!