Ask Your Question

Revision history [back]

Can not create cuda::ORB. Program Stucks

Hi everyone,

I have a simple piece of code that uses both cv::ORB and Cuda:ORB. In my code, I can not use cv::Ptr<cuda::ORB> orb = cuda::ORB::create(); It stucks my program.

For example this is the code I am using; (I did not remove the unused .hpp files for this example because In my real program I need them too)

#include "opencv2/core/core.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/cudaarithm.hpp"
#include "opencv2/cudawarping.hpp"
#include "opencv2/cudafilters.hpp"
#include "opencv2/cudafeatures2d.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/core/cuda.hpp"
#include "opencv2/xfeatures2d.hpp"
#include "opencv2/ximgproc.hpp"
#include <time.h>
#include <iostream>

using namespace cv;
using namespace std;


int main(int argc, char* argv[]) {


    Mat img1 = imread("amanda.jpg", CV_LOAD_IMAGE_GRAYSCALE);
    Mat img2 = imread("amanda.jpg", CV_LOAD_IMAGE_GRAYSCALE);

    std::cout << "1 " << std::endl;

    cv::cuda::GpuMat img1_gpu, img2_gpu;
    img1_gpu.upload(img1);
    img2_gpu.upload(img2);

    std::cout << "2 " << std::endl;

    cv::Ptr<cuda::ORB> orb = cuda::ORB::create();


    cv::imshow("Show Image", img1);

    return 0;

}

To be sure what is going on here I put two print statement in my code. Above code just writes "1" to console and stuck. How is it possible? How did this program get stuck? How did print 1 and not 2?

If I change Cuda:ORB to cv:ORB everything is fine. If I put cv::Ptr<cuda::ORB> orb = Cuda::ORB::create(); beginning of the code, program prints nothing to console which is expected in my case.

Things get more interesting here. If I wait 30 seconds or more sometimes program does print 2. And If I use Cuda::ORB, it does the job. For a really small image, why it takes too much time to response?

Is this a bug? Should I open a bug report on Github?

For the ones who wants to test this can use this little piece of code. It makes me wait too much and sometimes never response:

    int main(int argc, char* argv[]) {

    std::cout << "1 " << std::endl;
    cv::Ptr<cuda::ORB> orb = cuda::ORB::create();
    std::cout << "2 " << std::endl;

    return 0;
}

Any comment or idea are appreciated.