Our first GPU-based program
In this section, we show two versions of the same program: one version uses the CPU to perform computations, and the other version uses the GPU. These two examples are called edgesCPU
and edgesGPU
, respectively, and allow us to point out the differences when using the GPU
module in OpenCV.
The edgesCPU
example is presented in the first place:
#include <iostream> #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" using namespace cv; int main(int argc, char** argv){ if ( argc < 2 ){ std::cout << "Usage: ./edgesGPU <image>" << std::endl; return -1; } Mat orig = imread(argv[1]); Mat gray, dst; bilateralFilter(orig,dst,-1,50,7); cvtColor(dst,gray,COLOR_BGR2GRAY); Canny(gray,gray,7,20); imshow("Canny Filter", gray); waitKey(0); return 0; }
Now the edgesGPU
example is shown as follows:
#include <iostream> #include <opencv2...