From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18845 invoked by alias); 12 Jul 2012 19:52:08 -0000 Received: (qmail 18832 invoked by uid 22791); 12 Jul 2012 19:52:07 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,KHOP_THREADED,NML_ADSP_CUSTOM_MED,TW_MG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from sam.nabble.com (HELO sam.nabble.com) (216.139.236.26) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Jul 2012 19:51:54 +0000 Received: from telerig.nabble.com ([192.168.236.162]) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1SpPQX-0004oR-Vy for cygwin@cygwin.com; Thu, 12 Jul 2012 12:51:53 -0700 Message-ID: <34152926.post@talk.nabble.com> Date: Thu, 12 Jul 2012 19:52:00 -0000 From: emon To: cygwin@cygwin.com Subject: Re: running .bat file in cygwin In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit References: <34146666.post@talk.nabble.com> 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/msg00237.txt.bz2 Can you help me on this: 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()); } Earnie wrote: > > On Wed, Jul 11, 2012 at 12:26 PM, emon wrote: >> >> Dear All, >> I am a newbie in cygwin. However, I have used mingw so >> far, >> but it is not supporting fork(), so I need to switch to cygwin. I have >> created a build.bat file in my mingw (programming language C): >> > > Note, fork requires the cygwin1.dll file. Are you prepared for that? > >> gcc -o mask mask.c -pg -I/c/opencv/build/include -lopencv_core231 >> -lopencv_highgui231 -lopencv_imgproc231 -L. >> -L/c/opencv/build/x86/mingw/lib >> >> Can anyone suggest me how I can run this .bat file at cygwin or refer me >> to >> a site. > > I've read all the other response, etc. However, if you want to use > the .bat file you can do > > cmd /c build.bat > > take care that your PATH has all you need and note that /posix/paths > don't 't work with MinGW gcc. But since you need fork() you'll need > to use the Cygwin GCC anyway. > > -- > Earnie > -- https://sites.google.com/site/earnieboyd > > -- > 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 > > > -- View this message in context: http://old.nabble.com/running-.bat-file-in-cygwin-tp34146666p34152926.html Sent from the Cygwin list mailing list archive at Nabble.com. -- 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