Going real time
One of the main advantages of using the GPU to perform computations in images is that they are much faster. This increase in speed allows you to run heavy computational algorithms in real-time applications, such as stereo vision, pedestrian detection, or dense optical flow. In the next matchTemplateGPU
example, we show an application that matches a template in a video sequence:
#include <iostream> #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/features2d/features2d.hpp" #include "opencv2/gpu/gpu.hpp" #include "opencv2/nonfree/gpu.hpp" using namespace std; using namespace cv; int main( int argc, char** argv ) { Mat img_template_cpu = imread( argv[1],IMREAD_GRAYSCALE); gpu::GpuMat img_template; img_template.upload(img_template_cpu); //Detect keypoints and compute descriptors of the template gpu::SURF_GPU surf; gpu::GpuMat keypoints_template, descriptors_template; surf(img_template,gpu::GpuMat()...