Hi,
I just find to add a "while(1)" loop in "main()" that can run "update" of NonPeriodicActivity all the time.
Is that any other way to do that?
Today I get an error about "Camera" component:
<code>
(Camera:21467): GLib-WARNING **: g_main_context_prepare(): main loop already active in another thread
**
** GLib:ERROR:(/build/buildd/glib2.0-2.16.6/glib/gmain.c:1963):g_main_dispatch: assertion failed: (source)
</code>
Is that meaning I should not use "while" loop in "main" part ?
I really don't understand what's that mean..
All your best,
GL
How to make NonPeriodicActivity update all the time?
Submitted by guoliang liu on Tue, 2009-02-17 14:10 |
How to make NonPeriodicActivity update all the time?
The Problem might be because I add "cvWaitKey" in "main":
<code>
while(1)
{
break;
}
</code>
It seems cvWaitKey has some problems with Orocos Camera part.
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,
I just find to add a "while(1)" loop in "main()" that can run "update" of NonPeriodicActivity all the time.
Is that any other way to do that?
Today I get an error about "Camera" component:
<code>
(Camera:21467): GLib-WARNING **: g_main_context_prepare(): main loop already active in another thread
**
** GLib:ERROR:(/build/buildd/glib2.0-2.16.6/glib/gmain.c:1963):g_main_dispatch: assertion failed: (source)
</code>
Is that meaning I should not use "while" loop in "main" part ?
I really don't understand what's that mean..
All your best,
<font color="#888888">GL
<font><blockquote>
How to make NonPeriodicActivity update all the time?
On Tuesday 17 February 2009 15:08:36 guoliang liu wrote:
> Hi,
>
> I just find to add a "while(1)" loop in "main()" that can run "update" of
> NonPeriodicActivity all the time. Is that any other way to do that?
>
>
> Today I get an error about "Camera" component:
>
>
> Is that meaning I should not use "while" loop in "main" part ?
> I really don't understand what's that mean..
This is something that rings a bell:
It's due to the opencv threading for the windows. Did you use the camera
component from ocl?
It is due to calling cvShowImage in different threads, you should use the
function cvStartWindowThread() in every thread that uses cvShowImage. It also
enables the remove of the magic cvWaitKey() to make sure an image is actually
shown.
This is solved in the hardware/camera and vision (complete vision toolkit
which also has an ImageReporter, and IplImage Type support) of the ocl-pma
branch.
Ruben
How to make NonPeriodicActivity update all the time?
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
>
> I just find to add a "while(1)" loop in "main()" that can run "update" of
> NonPeriodicActivity all the time. Is that any other way to do that?
>
>
> Today I get an error about "Camera" component:
> <code>
> (Camera:21467): GLib-WARNING **: g_main_context_prepare(): main loop
> already active in another thread **
> **
> GLib:ERROR:(/build/buildd/glib2.0-2.16.6/glib/gmain.c:1963):g_main_dispatch
>: assertion failed: (source) </code>
>
> Is that meaning I should not use "while" loop in "main" part ?
> I really don't understand what's that mean..
This is something that rings a bell:
It's due to the opencv threading for the windows. Did you use the camera
component from ocl? <blockquote>
Yes, I am using camera component from ocl.
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It is due to calling cvShowImage in different threads, you should use the
function cvStartWindowThread() in every thread that uses cvShowImage. It also
enables the remove of the magic cvWaitKey() to make sure an image is actually
shown.<blockquote>
Do you mean I should add cvStartWindowThread() before cvShowImage and cvWaitKey()??
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
This is solved in the hardware/camera and vision (complete vision toolkit
which also has an ImageReporter, and IplImage Type support) of the ocl-pma
branch.<blockquote>
Where is this branch?
In ocl-pma, can I use cvWaitKey in every thread without cvStartWindowThread()?
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ruben
<font color="#888888">
--
Orocos-Users mailing list
Orocos-Users [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
<font><blockquote>
Thanks for your reply..
GL
How to make NonPeriodicActivity update all the time?
On Tuesday 17 February 2009 15:36:49 guoliang liu wrote:ruben [dot] smits [..] ...>>
> 2009/2/17 Ruben Smits
> <ruben [dot] smits [..] ...
>
> On Tuesday 17 February 2009 15:08:36 guoliang liu wrote:
> > Hi,
> >
> > I just find to add a "while(1)" loop in "main()" that can run "update" of
> > NonPeriodicActivity all the time. Is that any other way to do that?
> >
> >
> > Today I get an error about "Camera" component:
> >
> >
> > Is that meaning I should not use "while" loop in "main" part ?
> > I really don't understand what's that mean..
>
> This is something that rings a bell:
>
> It's due to the opencv threading for the windows. Did you use the camera
> component from ocl?
>
> Yes, I am using camera component from ocl.
>
>
> It is due to calling cvShowImage in different threads, you should use the
> function cvStartWindowThread() in every thread that uses cvShowImage. It
> also enables the remove of the magic cvWaitKey() to make sure an image is
> actually shown.
>
> Do you mean I should add cvStartWindowThread() before cvShowImage and
> cvWaitKey()??
>
>
> This is solved in the hardware/camera and vision (complete vision toolkit
> which also has an ImageReporter, and IplImage Type support) of the ocl-pma
> branch.
>
> Where is this branch?
> In ocl-pma, can I use cvWaitKey in every thread without
> cvStartWindowThread()?
I don't know, AFAIK the cvWaitKey only makes sense for an OpenCV window-
showing thread, so you must at least have on thread that you want to wait in.
I posted the needed patches on the mailinglist, in the camera component
cvWaitKey was used to make sure that the image was actually shown when the
camera-component had to show the raw-image while debugging (do not use it
otherwise, it will slow down the camera-component) We used cvWaitKey(3),. the
"3" was a magic number that sometimes worked, sometimes not. By calling
cvStartWindowThread() _once_ in the thread that will put images in the window
and wait for something, the cvWaitKey(3) could be removed and the strange GLib
warning disappeared.
Ruben
>
> Ruben
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...<mailto:Orocos-Users [..] ...en
>.be> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
>
>
>
>
> Thanks for your reply..
> GL
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
How to make NonPeriodicActivity update all the time?
On Tuesday 17 February 2009 15:08:36 guoliang liu wrote:
> Hi,
>
> I just find to add a "while(1)" loop in "main()" that can run "update" of
> NonPeriodicActivity all the time.
> Is that any other way to do that?
Don't call update() directly. You should start the NonPeriodicActivity and
then in your component's updateHook() function, write:
// in case of updateHook():
this->engine()->getActivity()->trigger(); // will cause us to loop.
>
>
> Today I get an error about "Camera" component:
>
>
> Is that meaning I should not use "while" loop in "main" part ?
Yes. Don't do that.
Peter
How to make NonPeriodicActivity update all the time?
I also use trigger() in updateHook part. But in the main part ,I still need update keeps running, so I still need a while loop in "main" to give time to trigger update.
Do you think so?
The error part becauses I add cvWaitKey in the while loop..
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> Hi,
>
> I just find to add a "while(1)" loop in "main()" that can run "update" of
> NonPeriodicActivity all the time.
> Is that any other way to do that?
Don't call update() directly. You should start the NonPeriodicActivity and
then in your component's updateHook() function, write:
// in case of updateHook():
this->engine()->getActivity()->trigger(); // will cause us to loop.
>
>
> Today I get an error about "Camera" component:
> <code>
> (Camera:21467): GLib-WARNING **: g_main_context_prepare(): main loop
> already active in another thread
> **
> **
> GLib:ERROR:(/build/buildd/glib2.0-2.16.6/glib/gmain.c:1963):g_main_dispatch
>: assertion failed: (source)
> </code>
>
> Is that meaning I should not use "while" loop in "main" part ?
Yes. Don't do that.
Peter
<font color="#888888">
--
Peter Soetens -- FMTC -- <http://www.fmtc.be>
<font><blockquote>
How to make NonPeriodicActivity update all the time?
On Tuesday 17 February 2009 15:30:32 guoliang liu wrote:
> I also use trigger() in updateHook part. But in the main part ,I still need
> update keeps running, so I still need a while loop in "main" to give time
> to trigger update.
> Do you think so?
>
> The error part becauses I add cvWaitKey in the while loop..
Ok. I misunderstood that part. So it's a pure OpenCV problem, I don't know how
to fix that.
Peter