Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Building OpenCV with the WITH_OPENMP flag means that the internal functions will use OpenMP to parallelize some of the algorithms.

In OpenCV, an algorithm can have a sequential (slowest) implementation; a parallel implementation using OpenMP or TBB; and a GPU implementation using OpenCL or CUDA (fastest). You can decide with the WITH_...flags which version to use.

Of course, not every algorithm can be parallelized.

Now, if you want to parallelize your methods with OpenMP, you have to implement it yourself.

A typical image processing function looks like:

for(int y=0;y<image.rows;y++)
    for(int x=0;x<image.cols;x++)
         //do something with pixel (x,y)

Typically it's the outer loop that gets parallelized; so you have to transform the for(y...) loop to a parallel for loop. I never used OpenMP, but it seems it's done with the #pragma omp for directive.

Building OpenCV with the WITH_OPENMP flag means that the internal functions will use OpenMP to parallelize some of the algorithms.

In OpenCV, an algorithm can have a sequential (slowest) implementation; a parallel implementation using OpenMP or TBB; and a GPU implementation using OpenCL or CUDA (fastest). You can decide with the WITH_...flags which version to use.

Of course, not every algorithm can be parallelized.

Now, if you want to parallelize your methods with OpenMP, you have to implement it yourself.

A typical image processing function looks like:

for(int y=0;y<image.rows;y++)
    for(int x=0;x<image.cols;x++)
         //do something with pixel (x,y)

Typically it's the outer loop that gets parallelized; so you have to transform the for(y...) loop to a parallel for loop. I never used OpenMP, but it seems it's done with the #pragma omp for directive.

directive; something like:

#pragma omp for
for(int y=0;y<image.rows;y++)
    for(int x=0;x<image.cols;x++)
         //do something with pixel (x,y)