<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Thema "Re: Urgent question on openmp and opencv" in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Urgent-question-on-openmp-and-opencv/m-p/966479#M5425</link>
    <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I don't see any OpenMP errors in your program, provided the cvQueryFrame and cvShowImage functions are threadsafe. I'm not an OpenCV expert so I don't know if these functions can be called simultaneously by multiple threads. Does the OpenCV documentation say anything about threadsafety?&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Henry&lt;/P&gt;</description>
    <pubDate>Fri, 28 Oct 2005 02:29:37 GMT</pubDate>
    <dc:creator>Henry_G_Intel</dc:creator>
    <dc:date>2005-10-28T02:29:37Z</dc:date>
    <item>
      <title>Urgent question on openmp and opencv</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Urgent-question-on-openmp-and-opencv/m-p/966478#M5424</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
I am currently using openmp in the computer vision. What I want to do is grab images from to cameras. By using the parallel structure, I firstly generate two threads using the omp sections. The each stream from these cameras is proposed to grabbed and displayed in a corresponding thread. I am using the opencv to grab and display images. Once I use the series structure, i.e. images from two cameras are grabbed one by one, there is no problem. However, if I use the parallel structure, I can see that two threads do work, but I can only display one image. I am not quite sure about the problem. I need your help in this issue or any other suggestion.&lt;BR /&gt;
&lt;BR /&gt;
I am using Xeon 2Cpu workstation with winxp system and intel cpp compiler 9.0 installed. The opencv is v4beta. The c file is shown as follows:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
#include "cv.h"&lt;BR /&gt;
#include "highgui.h"&lt;BR /&gt;
#include "cxcore.h"&lt;BR /&gt;
#include &lt;BR /&gt;
#include &lt;BR /&gt;
#include &lt;BR /&gt;
&lt;BR /&gt;
void main()&lt;BR /&gt;
{&lt;BR /&gt;
IplImage *image1, *image2;&lt;BR /&gt;
&lt;BR /&gt;
CvCapture *capture1, *capture2;&lt;BR /&gt;
&lt;BR /&gt;
clock_t t1, t2;&lt;BR /&gt;
&lt;BR /&gt;
int nframe1, nframe2, tid, nthreads;&lt;BR /&gt;
&lt;BR /&gt;
capture1=cvCaptureFromCAM(-1);&lt;BR /&gt;
capture2=cvCaptureFromCAM(-1);&lt;BR /&gt;
&lt;BR /&gt;
cvNamedWindow("camera1", 1);&lt;BR /&gt;
cvNamedWindow("camera2", 1);&lt;BR /&gt;
&lt;BR /&gt;
cvResizeWindow("camera1", 320, 240);&lt;BR /&gt;
cvResizeWindow("camera2", 320, 240);&lt;BR /&gt;
&lt;BR /&gt;
omp_set_num_threads(2);&lt;BR /&gt;
&lt;BR /&gt;
nframe1=0;&lt;BR /&gt;
nframe2=0;&lt;BR /&gt;
&lt;BR /&gt;
for (;;)&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
t1=clock();&lt;BR /&gt;
&lt;BR /&gt;
#pragma omp parallel private(tid)&lt;BR /&gt;
{&lt;BR /&gt;
tid=omp_get_thread_num();&lt;BR /&gt;
&lt;BR /&gt;
if (tid==0)&lt;BR /&gt;
{&lt;BR /&gt;
nthreads=omp_get_num_threads();&lt;BR /&gt;
printf("Number of threads = %d
", nthreads);&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
printf("Thread %d starting....
", tid);&lt;BR /&gt;
&lt;BR /&gt;
#pragma omp sections&lt;BR /&gt;
{&lt;BR /&gt;
#pragma omp section&lt;BR /&gt;
{&lt;BR /&gt;
printf("Thread %d grabbing from camera 1
", tid);&lt;BR /&gt;
&lt;BR /&gt;
image1=cvQueryFrame(capture1);&lt;BR /&gt;
cvShowImage("camera1", image1);&lt;BR /&gt;
&lt;BR /&gt;
printf("This is the No %d frame from camera1
", nframe1);&lt;BR /&gt;
&lt;BR /&gt;
nframe1++;&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
#pragma omp section&lt;BR /&gt;
{&lt;BR /&gt;
printf("Thread %d grabbing from camera 2
", tid);&lt;BR /&gt;
image2=cvQueryFrame(capture2);&lt;BR /&gt;
cvShowImage("camera2", image2);&lt;BR /&gt;
&lt;BR /&gt;
printf("This is the No %d frame from camera2
", nframe2);&lt;BR /&gt;
nframe2++;&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
t2=clock();&lt;BR /&gt;
&lt;BR /&gt;
printf("Time is %f
", (double)(t2-t1)/CLOCKS_PER_SEC);&lt;BR /&gt;
&lt;BR /&gt;
if (cvWaitKey(10)&amp;gt;=0)&lt;BR /&gt;
break;&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
cvReleaseCapture(&amp;amp;capture1);&lt;BR /&gt;
cvReleaseCapture(&amp;amp;capture2);&lt;BR /&gt;
cvDestroyAllWindows();&lt;BR /&gt;
&lt;BR /&gt;
}</description>
      <pubDate>Thu, 27 Oct 2005 23:08:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Urgent-question-on-openmp-and-opencv/m-p/966478#M5424</guid>
      <dc:creator>lijianemail</dc:creator>
      <dc:date>2005-10-27T23:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Urgent question on openmp and opencv</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Urgent-question-on-openmp-and-opencv/m-p/966479#M5425</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I don't see any OpenMP errors in your program, provided the cvQueryFrame and cvShowImage functions are threadsafe. I'm not an OpenCV expert so I don't know if these functions can be called simultaneously by multiple threads. Does the OpenCV documentation say anything about threadsafety?&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Henry&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2005 02:29:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Urgent-question-on-openmp-and-opencv/m-p/966479#M5425</guid>
      <dc:creator>Henry_G_Intel</dc:creator>
      <dc:date>2005-10-28T02:29:37Z</dc:date>
    </item>
  </channel>
</rss>

