OpenCV capture delay in parallel programming

272 views Asked by At

I'm trying to capture from webcam in OpenCV parallel programming.

When I capture a frame without parallel block, it works with 60fps.

But when it works in parallel block like OpenMP or TBB, it works only 10~20fps.

Especially, VideoCapture::grab() function takes more double or triple time in parallel block.

There are capture programming code using OpenMP or TBB below.

Using openMP

#pragma omp parallel
#pragma omp sections
{
#pragma omp section
{
    clock_t a1 = clock();
    cap.grab();
    printf("grab : %f\n", double(clock() - a1) / double(CLOCKS_PER_SEC));
    cap.retrieve(Origin);
    printf("cam : %f\n", double(clock() - a1) / double(CLOCKS_PER_SEC));
}

#pragma omp section
{
    clock_t a2 = clock();
    BOriginal.copyTo(OriginA);
    cvtColor(AAOri, HSOriginA, COLOR_BGR2HSV);
    HSOriginA.copyTo(HSOrigin);
}
}

Using TBB

task_scheduler_init init;

parallel_invoke([capture, Origin]()->void {

    clock_t aas = clock();
    cap.grab();
    printf("grab time : %f\n", double(clock() - aas) / double(CLOCKS_PER_SEC));
    cap.retrieve(Origin);
    printf("cam time : %f\n", double(clock() - aas) / double(CLOCKS_PER_SEC));

},
[BOriginal, OriginA, HSOriginA, HSOrigin]()->void {
    clock_t a2 = clock();
    BOriginal.copyTo(OriginA);
    cvtColor(OriginA, HSOriginA, COLOR_BGR2HSV);
    HSOriginA.copyTo(HSOrigin);

});

In OpenMP, capture programming block whether in omp master or in omp single, omp section, it works the same.

How can I capture(grab(), retrieve()) without delay in parallel programming.

My environment is ARM processor and Linux Fedora 3.10 Kernel.

0

There are 0 answers