O'Reilly logo

OpenCV Essentials by Jesus Salido Tercero, Julio Alberto Patón Incertis, Ismael Serrano Gracia, Gloria Bueno García, Noelia Vállez Enano, Mª del Milagro Fernández Carrobles, Oscar Deniz Suarez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required