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


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[])
        cv::Mat src_host = cv::imread("home/nvidia/Desktop/Perspective/dog.jpg", CV_LOAD_IMAGE_GRAYSCALE);
        cv::gpu::GpuMat dst, src;

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

        cv::Mat result_host;;
        //cv::imshow("Result", result_host);
    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:, needed by /usr/lib/gcc/aarch64-linux-gnu/5/../../../aarch64-linux-gnu/, may conflict with /usr/bin/ld: /tmp/ccwN8nW0.o: undefined reference to symbol '_ZN2cv3gpu6GpuMat7releaseEv' //usr/lib/aarch64-linux-gnu/ 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