<?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>topic Second question: communication within threads in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Second-question-communication-within-threads/m-p/966451#M5423</link>
    <description>Hi all, This is the second question. What I want to do is starting two threads using openmp. The first thread grabs image from a camera and the second thread obtains information (images) from the first thread with a constant temporal interval. For example, thread 1 grabs images continuously and thread 2 displays a frame of image in the first thread every 10 frames. For this task, it seems there should be some parameters which can be shared within threads. Currently, I am using a omp section directive, in which the image is shared between two threads. However, my program does not work properly. Could please offer me some suggestion regarding this issue. Thanks a lot. The original program is shown as below: #include "cv.h" #include "highgui.h" #include #include void main() { IplImage *image; CvCapture *capture; int nframe, tid, nthreads; capture=cvCaptureFromCAM(-1); cvNamedWindow("show1", 0); cvNamedWindow("show2", 0); omp_set_num_threads(2); nframe=0; for (;;) { #pragma omp parallel shared(image) private(tid) { tid=omp_get_thread_num(); if (tid==0) { nthreads=omp_get_num_threads(); printf("Number of threads = %d
", nthreads); } printf("Thread %d starting....
", tid); #pragma omp sections nowait { #pragma omp section { printf("Thread %d grabbing from the camera
", tid); image=cvQueryFrame(capture); cvShowImage("show1", image); printf("This is the No %d frame from the camera
", nframe); nframe++; } #pragma omp section { printf("Thread %d obtains frames from camera
", tid); if (nframe%10==0) { cvShowImage("show2", image); printf("This is the copy of No %d frame from camera
", nframe); } } } } if (cvWaitKey(10)&amp;gt;=0) break; } cvReleaseCapture(&amp;amp;capture); cvDestroyAllWindows(); }</description>
    <pubDate>Thu, 27 Oct 2005 23:19:20 GMT</pubDate>
    <dc:creator>lijianemail</dc:creator>
    <dc:date>2005-10-27T23:19:20Z</dc:date>
    <item>
      <title>Second question: communication within threads</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Second-question-communication-within-threads/m-p/966451#M5423</link>
      <description>Hi all, This is the second question. What I want to do is starting two threads using openmp. The first thread grabs image from a camera and the second thread obtains information (images) from the first thread with a constant temporal interval. For example, thread 1 grabs images continuously and thread 2 displays a frame of image in the first thread every 10 frames. For this task, it seems there should be some parameters which can be shared within threads. Currently, I am using a omp section directive, in which the image is shared between two threads. However, my program does not work properly. Could please offer me some suggestion regarding this issue. Thanks a lot. The original program is shown as below: #include "cv.h" #include "highgui.h" #include #include void main() { IplImage *image; CvCapture *capture; int nframe, tid, nthreads; capture=cvCaptureFromCAM(-1); cvNamedWindow("show1", 0); cvNamedWindow("show2", 0); omp_set_num_threads(2); nframe=0; for (;;) { #pragma omp parallel shared(image) private(tid) { tid=omp_get_thread_num(); if (tid==0) { nthreads=omp_get_num_threads(); printf("Number of threads = %d
", nthreads); } printf("Thread %d starting....
", tid); #pragma omp sections nowait { #pragma omp section { printf("Thread %d grabbing from the camera
", tid); image=cvQueryFrame(capture); cvShowImage("show1", image); printf("This is the No %d frame from the camera
", nframe); nframe++; } #pragma omp section { printf("Thread %d obtains frames from camera
", tid); if (nframe%10==0) { cvShowImage("show2", image); printf("This is the copy of No %d frame from camera
", nframe); } } } } if (cvWaitKey(10)&amp;gt;=0) break; } cvReleaseCapture(&amp;amp;capture); cvDestroyAllWindows(); }</description>
      <pubDate>Thu, 27 Oct 2005 23:19:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Second-question-communication-within-threads/m-p/966451#M5423</guid>
      <dc:creator>lijianemail</dc:creator>
      <dc:date>2005-10-27T23:19:20Z</dc:date>
    </item>
  </channel>
</rss>

