public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* pthread help
@ 2012-07-12 19:48 emon
  2012-07-12 21:19 ` marco atzeri
  2012-07-12 21:52 ` LMH
  0 siblings, 2 replies; 6+ messages in thread
From: emon @ 2012-07-12 19:48 UTC (permalink / raw)
  To: cygwin


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());
}

-- 
View this message in context: http://old.nabble.com/pthread-help-tp34152902p34152902.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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pthread help
  2012-07-12 19:48 pthread help emon
@ 2012-07-12 21:19 ` marco atzeri
  2012-07-12 21:52 ` LMH
  1 sibling, 0 replies; 6+ messages in thread
From: marco atzeri @ 2012-07-12 21:19 UTC (permalink / raw)
  To: cygwin

On 7/12/2012 9:48 PM, 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
>

wrong mailing list ???

--
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pthread help
  2012-07-12 19:48 pthread help emon
  2012-07-12 21:19 ` marco atzeri
@ 2012-07-12 21:52 ` LMH
  2012-07-12 22:29   ` Larry Hall (Cygwin)
  1 sibling, 1 reply; 6+ messages in thread
From: LMH @ 2012-07-12 21:52 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pthread help
  2012-07-12 21:52 ` LMH
@ 2012-07-12 22:29   ` Larry Hall (Cygwin)
  2012-07-12 22:53     ` LMH
  0 siblings, 1 reply; 6+ messages in thread
From: Larry Hall (Cygwin) @ 2012-07-12 22:29 UTC (permalink / raw)
  To: cygwin

On 7/12/2012 5:52 PM, LMH wrote:
> This is a question for a programming forum, cygwin is an operating system.
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sorry, can't let this one slide in case others stumble across it in the
archives.  Cygwin is not an O/S.  From the web site:

   Cygwin is:

     a collection of tools which provide a Linux look and feel environment
       for Windows.

     a DLL (cygwin1.dll) which acts as a Linux API layer providing
       substantial Linux API functionality.

All of that makes Cygwin seem like an O/S sometimes but it's really not
even close.

But you're right that this list isn't a generic programming forum.


-- 
Larry

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?


--
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pthread help
  2012-07-12 22:29   ` Larry Hall (Cygwin)
@ 2012-07-12 22:53     ` LMH
  2012-07-13  1:20       ` Andrey Repin
  0 siblings, 1 reply; 6+ messages in thread
From: LMH @ 2012-07-12 22:53 UTC (permalink / raw)
  To: cygwin

Sorry for the confusion. It is probably better classified as a Linux 
emulator. I think of it more or less as a virtualized OS, but that's not 
exactly right either (I don't think it has it's own kernel, etc).

I meant to make an analogy of the different between installing and 
configuring an OS, and installing/configuring/using applications that 
run on the OS, to point out that the previous post was more like the 
latter. I guess I didn't do that very well.

LMH


Larry Hall (Cygwin) wrote:
> On 7/12/2012 5:52 PM, LMH wrote:
>> This is a question for a programming forum, cygwin is an operating
>> system.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Sorry, can't let this one slide in case others stumble across it in the
> archives. Cygwin is not an O/S. From the web site:
>
> Cygwin is:
>
> a collection of tools which provide a Linux look and feel environment
> for Windows.
>
> a DLL (cygwin1.dll) which acts as a Linux API layer providing
> substantial Linux API functionality.
>
> All of that makes Cygwin seem like an O/S sometimes but it's really not
> even close.
>
> But you're right that this list isn't a generic programming forum.
>
>

--
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pthread help
  2012-07-12 22:53     ` LMH
@ 2012-07-13  1:20       ` Andrey Repin
  0 siblings, 0 replies; 6+ messages in thread
From: Andrey Repin @ 2012-07-13  1:20 UTC (permalink / raw)
  To: LMH, cygwin

Greetings, LMH!

> Sorry for the confusion. It is probably better classified as a Linux 
> emulator.

It's not more an emulator, than WINE. Which is NOT an emulator.

> I think of it more or less as a virtualized OS,

Which is totally wrong thought.
It's not virtualized, it's exactly opposite. Pretty much naturalized. you
could even share handles between Cygwin and non-Cygwin processes.

> but that's not exactly right either (I don't think it has it's own kernel,
> etc). 

> I meant to make an analogy of the different between installing and 
> configuring an OS, and installing/configuring/using applications that 
> run on the OS, to point out that the previous post was more like the 
> latter. I guess I didn't do that very well.

Well, Cygwin in essence is a library. cygwin1.dll
the rest is a collection of tools built over it. But they are hardly
necessary, if you don't need them.

Also, please don't top-post. Thank you.


--
WBR,
Andrey Repin (anrdaemon@freemail.ru) 13.07.2012, <05:10>

Sorry for my terrible english...


--
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-07-13  1:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-12 19:48 pthread help emon
2012-07-12 21:19 ` marco atzeri
2012-07-12 21:52 ` LMH
2012-07-12 22:29   ` Larry Hall (Cygwin)
2012-07-12 22:53     ` LMH
2012-07-13  1:20       ` Andrey Repin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).