How to run Opencv with GPU code

asked 2019-06-24 06:22:19 -0500

prabhakarMP gravatar image

updated 2019-06-24 06:24:04 -0500

Hi,

I am running below code

/* OpenCV2: Thresholding using GPU */
using namespace std;

#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"

using namespace cv;

int main (int argc, char* argv[])
{
    try
    {
        cv::Mat src_host = cv::imread("home/nvidia/Desktop/Perspective/dog.jpg", CV_LOAD_IMAGE_GRAYSCALE);
        cv::gpu::GpuMat dst, src;
        src.upload(src_host);

        cv::gpu::threshold(src, dst, 128.0, 255.0, CV_THRESH_BINARY);

        cv::Mat result_host;
        dst.download(result_host);
        //cv::imshow("Result", result_host);
        //cv::waitKey();
    }
    catch(const cv::Exception& ex)
    {
        std::cout << "Error: " << ex.what() << std::endl;
    }
    return 0;
}

I used command g++ -I/usr/local/cuda/include -o output GPU.cpp pkg-config --cflags --libs opencv -lopencv_gpu

Where I am getting error as /usr/bin/ld: warning: libopencv_core.so.2.4, needed by /usr/lib/gcc/aarch64-linux-gnu/5/../../../aarch64-linux-gnu/libopencv_gpu.so, may conflict with libopencv_core.so.3.4 /usr/bin/ld: /tmp/ccwN8nW0.o: undefined reference to symbol '_ZN2cv3gpu6GpuMat7releaseEv' //usr/lib/aarch64-linux-gnu/libopencv_core.so.2.4: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

I am new to GPU and I am not sure about the command what I used. Please support.

Regards, Prabhakar M

edit retag flag offensive close merge delete