Note that there are some explanatory texts on larger screens.

plurals
  1. POpthread parallel processing
    primarykey
    data
    text
    <p>Need urgent help on thread: the goal here is the separtemask will take each image and separate different contours and for each contour in the image it will call handleobject thread. So every for loop will call the handeobject thread. However, object index variable needs to be passed in each thread. But only last value of objectndex is passed, this is becuase the speratemask function loops and repalces the value of obj.objindx and only the last value of obj.objindx is passed to all the threads. Is there anyway to pass each objectindex value in handleobject. The code runs fine if we uncomment the pthread_join(tid[objectIndex],NULL); but it will not give a parralel program</p> <pre><code>void separateMask(IplImage *maskImg) { for(r = contours; r != NULL; r = r-&gt;h_next) { cvSet(objectMaskImg, cvScalarAll(0), NULL); CvScalar externalColor = cvScalarAll(0xff); CvScalar holeColor = cvScalarAll(0x00); int maxLevel = -1; int thinkness = CV_FILLED; int lineType = 8; /* 8-connected */ cvDrawContours(objectMaskImg, r, externalColor, holeColor, maxLevel, thinkness,lineType, cvPoint(0,0));; obj.objectMaskImg1[objectIndex]=(IplImage *) malloc(sizeof(IplImage)); obj.objectMaskImg1[objectIndex]=objectMaskImg; obj.objindx=objectIndex; obj.intensityOut1=intensityOut; obj.tasOut1=tasOut; pthread_create(&amp;tid[objectIndex],NULL,handleObject,(void *)&amp;obj); //pthread_join(tid[objectIndex],NULL); printf("objectindx %d\n",obj.objindx); objectIndex++; } // cvReleaseImage(&amp;objectMaskImg); //cvReleaseMemStorage(&amp;storage); printf("Exitng Separatemask\n"); } void* handleObject(void *arg) { int i, j; handle *hndl; hndl=(handle *) malloc(sizeof(handle)); hndl=(handle*)arg; pthread_mutex_t lock=PTHREAD_MUTEX_INITIALIZER; pthread_mutex_lock(&amp;lock); IplImage *pImg; float statistics_ratio[3][9]; pthread_t tid3; tas3 tas2; pImg = cvLoadImage("image.tif", CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH); if(pImg == NULL) { fprintf(stderr, "Fail to load image %s\n", "tiff file"); return ; } tas2.pImg1=pImg; printf("tst%d\n",hndl-&gt;objindx); tas2.x=hndl-&gt;objindx; tas2.objectMaskImg1=hndl-&gt;objectMaskImg1[tas2.x]; tas2.statistics_ratio[3][9]=statistics_ratio[3][9]; double mean = average_intensity(pImg, tas2.objectMaskImg1); int total = total_white(pImg, tas2.objectMaskImg1); pthread_mutex_unlock(&amp;lock); printf("Exiting handle object thread_id %d\n\n", pthread_self()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload