Ask Your Question
0

Parallel for

asked 2013-03-15 12:59:19 -0600

Alexander Pantiukhin gravatar image

updated 2013-03-15 13:00:19 -0600

Soi I have some problems. It's hard to understand how it works. I've red some information like this http://answers.opencv.org/question/3730/how-to-use-parallel_for/ can you help me with my code

for( int y=0; y<dst->height; y++ ) {
    uchar* ptr = (uchar*) (dst->imageData + y * dst->widthStep); 
    uchar* ptrM = (uchar*) (outCircle->imageData + y * outCircle->widthStep); 
    for( int x=0; x<dst->width; x++ ) {
        if(outCircle->imageData[outCircle->widthStep*y+x]==0){      
                ptr[3*x]=0;
                ptr[3*x+1]=0;
                ptr[3*x+2]=0;
        }

I have this one and i don't understand how to implement parallel_for

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-03-15 13:31:50 -0600

Daniil Osokin gravatar image

Hi! You can read general information about parallel_for in TBB docs. So, you shold just put your top for loop in the operator() of Body class (as pointed by @Vladislav Vinogradov in answer on the same question). Something like this:


void operator ()( const cv::Range& rowRange ) const
{
    for ( int y = rowRange.start; y < rowRange.end; y++ )
    {
        // your loop body
    }
}
...
// calling parallel_for_
cv::parallel_for_(cv::Range(0, dst->height), body);

edit flag offensive delete link more

Comments

1

@Daniil Osokin thank you)

Alexander Pantiukhin gravatar imageAlexander Pantiukhin ( 2013-03-15 13:56:58 -0600 )edit

Question Tools

Stats

Asked: 2013-03-15 12:59:19 -0600

Seen: 2,281 times

Last updated: Mar 15 '13