title: Parallelizing OpenCV code using TBB
body: <p>I am trying to parallelize some Image Matching code written in OpenCV using TBB. Problem is that according to me matching (creating a 5x5 window in left image and looking for match in right pixel by pixel) is essentially a read only operation and currently I am trying to parallelize the inner loop ( ie at a given height. I assign different pixels to different threads). To my surprise though the <code>cvSetImageROI</code> command breaks when done in parallel. Here is the code.</p>
  
  <pre><code>//Code below just carves out a window(5x5) at a current width which is to be matched
  cvSetImageROI(leftImageROI, cvRect(curWidth - 2, 0, 5, 5));
  IplImage* currentROI = cvCreateImage(cvSize(5, 5), leftImageROI-&gt;depth, leftImageROI-&gt;nChannels);
  cvCopy(leftImageROI, currentROI);                   
  cvResetImageROI(leftImageROI);
  </code></pre>
  
  <p>Now all this looks thread safe to me since they are only reading images.However code crashes. If I put a lock at the very beginning though it works. Can someone help ?</p>