From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17757 invoked by alias); 12 Jul 2012 21:52:22 -0000 Received: (qmail 17749 invoked by uid 22791); 12 Jul 2012 21:52:21 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from nm18-vm0.access.bullet.mail.mud.yahoo.com (HELO nm18-vm0.access.bullet.mail.mud.yahoo.com) (66.94.236.23) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Thu, 12 Jul 2012 21:52:08 +0000 Received: from [66.94.237.197] by nm18.access.bullet.mail.mud.yahoo.com with NNFMP; 12 Jul 2012 21:52:08 -0000 Received: from [98.138.207.15] by tm8.access.bullet.mail.mud.yahoo.com with NNFMP; 12 Jul 2012 21:52:07 -0000 Received: from [127.0.0.1] by smtp108.biz.mail.ne1.yahoo.com with NNFMP; 12 Jul 2012 21:52:07 -0000 X-Yahoo-SMTP: ycweUreswBCK.d0cygTP5tXwHncbOU7YVeVfIxOQoyRMI2IuIKLmUqE- Received: from [192.168.10.168] (lmh_users-groups@71.232.178.51 with plain) by smtp108.biz.mail.ne1.yahoo.com with SMTP; 12 Jul 2012 14:52:07 -0700 PDT Message-ID: <4FFF4704.2030005@molconn.com> Date: Thu, 12 Jul 2012 21:52:00 -0000 From: LMH User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20120429 Firefox/12.0 SeaMonkey/2.9.1 MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: pthread help References: <34152902.post@talk.nabble.com> In-Reply-To: <34152902.post@talk.nabble.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2012-07/txt/msg00249.txt.bz2 This is a question for a programming forum, cygwin is an operating system. For questions about using the programs in the cygwin package, it is better to post in an application specific forum. This is the pace for questions about installing such cygwin packages and related issues. I would recommend these programming forums, CodeGuru http://forums.codeguru.com/index.php (look for the best sub-forum, I use the non-visual c++ forum most) The Unix and Linux programming forums http://www.unix.com/programming/ (the top two posts here are also about pthread) LMH emon wrote: > > 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 > > > void separateMask(IplImage *maskImg) > { > > for(r = contours; r != NULL; r = r->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(&tid[objectIndex],NULL,handleObject,(void *)&obj); > //pthread_join(tid[objectIndex],NULL); > printf("objectindx %d\n",obj.objindx); > objectIndex++; > > } > // cvReleaseImage(&objectMaskImg); > //cvReleaseMemStorage(&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(&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->objindx); > tas2.x=hndl->objindx; > tas2.objectMaskImg1=hndl->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(&lock); > > printf("Exiting handle object thread_id %d\n\n", pthread_self()); > } > -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple