Op 22-02-12 12:19, Joseph S. Alcântara schreef:
Hi, now I get access to FAQ PyGTK talking about threads. It seems a
little complicated, and I didn't get it to work yet.
Like there teaches, I put at the begin, before anything be called,
gtk.threads_init() (that my python says it's deprecated and suggest me
to use gtk.gdk.threads_init, as well as threads_enter/leave)
So, I put gtk.main() between thrads_enter/leave and every part of code
I want to be a thread, I put into this code (enter/leave) but it
continue working the same. ie, it's now working.
I'm did something like this, into a class:
gtk.gdk.threads_enter
self.th <http://self.th> = Thread(target=self.camera.runvideo)
self.th.start()
gtk.gdk.threads_leave
It's a class that calls a gtk.Window. After, in self.camera.runvideo,
it calls famous routine to show images from webcam
I think it's also in the FAQ, but you shouldn't do any GUI stuff in a
thread, and if you do so, call it with gobject.idle_add().
Cheers,
Timo
*Joseph Soares Alcântara*
Engenharia da Computação - 8º semestre
Universidade Federal do Ceará - UFC
Sobral - Ceará
+--------------------------------------------------------------------------+
.| - °v°...A liberdade não pode ser comprada e sim |
.| -/(_)\..conquistada. Conquiste a sua também use |
.| - ^^ G N U / L I N U X |
+--------------------------------------------------------------------------+
2012/2/21 Joseph S. Alcântara <[email protected]
<mailto:[email protected]>>
How do I show a IplImage in a gtk.Image?
*Joseph Soares Alcântara*
Engenharia da Computação - 8º semestre
Universidade Federal do Ceará - UFC
Sobral - Ceará
+--------------------------------------------------------------------------+
.| - °v°...A liberdade não pode ser comprada e sim |
.| -/(_)\..conquistada. Conquiste a sua também use |
.| - ^^ G N U / L I N U X |
+--------------------------------------------------------------------------+
2012/2/21 Joseph S. Alcântara <[email protected]
<mailto:[email protected]>>
I cannot access FAQ, I think it's not working now.
Don't you have any example how could I solve that?
Yes, I'd like to show image from cv.QueryFrame in a gtk.Image,
But I am new in this, I'm learning a little slow.
It's a project to the university. We have an Open Source Study
Group, and I have to create a program using python + opencv + gtk.
Thank you
*Joseph Soares Alcântara*
Engenharia da Computação - 8º semestre
Universidade Federal do Ceará - UFC
Sobral - Ceará
+--------------------------------------------------------------------------+
.| - °v°...A liberdade não pode ser comprada e sim |
.| -/(_)\..conquistada. Conquiste a sua também use |
.| - ^^ G N U / L I N U X
|
+--------------------------------------------------------------------------+
2012/2/21 John Stowers <[email protected]
<mailto:[email protected]>>
IIRC opecv starts a mainloop when create window is called.
In general, don't use threads unless you have read the FAQ and
understand what you are doing.
John
2012/2/21 Joseph S. Alcântara <[email protected]
<mailto:[email protected]>>:
> Even if I don't use, ie, if I comment the lines where
NamedWindow, ShowImage
> and WaitKey appear it freezes too.
>
> Joseph Soares Alcântara
> Engenharia da Computação - 8º semestre
> Universidade Federal do Ceará - UFC
> Sobral - Ceará
>
>
+--------------------------------------------------------------------------+
> .| - °v°...A liberdade não pode ser comprada e sim |
> .| -/(_)\..conquistada. Conquiste a sua também use |
> .| - ^^ G N U / L I N U X
|
>
+--------------------------------------------------------------------------+
>
>
>
> 2012/2/21 John Stowers <[email protected]
<mailto:[email protected]>>
>>
>> GTK is not threadsafe.
>>
>> If opencv shows a gtk mainwindow in cv.ShowImage, and
that occurs in a
>> different thread to the one running gtk_main, then
unpredictable
>> crashes and odd behaviour will result.
>>
>> Please check the pygtk FAQ for how to use threading and
pygtk.
>>
>> I suggest displaying the image yourself in by getting
the data from
>> the IPL image and copying it into a GtkImage. Or be
much more careful
>> with which operations you do in which thread (i.e.
cv.ShowImage,
>> cv.WaitKey)
>>
>> John
>>
>> 2012/2/21 Joseph S. Alcântara <[email protected]
<mailto:[email protected]>>:
>> > Hi, Thank you for response to me.
>> >
>> > See, can I sand you my program to you see what I am
making? I've used
>> > Thread, but seems like is not working like I want.
>> >
>> > You must run from main.py
>> >
>> > Joseph Soares Alcântara
>> > Engenharia da Computação - 8º semestre
>> > Universidade Federal do Ceará - UFC
>> > Sobral - Ceará
>> >
>> >
>> >
+--------------------------------------------------------------------------+
>> > .| - °v°...A liberdade não pode ser comprada e sim |
>> > .| -/(_)\..conquistada. Conquiste a sua também use |
>> > .| - ^^ G N U / L I N U X
|
>> >
>> >
+--------------------------------------------------------------------------+
>> >
>> >
>> >
>> > 2012/2/19 Hart's Antler <[email protected]
<mailto:[email protected]>>
>> >>
>> >> Hi Joseph,
>> >> I got GTK and OpenCV working together using threads.
This example
>> >> works
>> >> with CPython2, CPython3 and PyPy, see my blog post.
>> >> http://pyppet.blogspot.com/2011/12/rpythonic-044.html
>> >>
>> >> -brett-
>> >>
>> >> ________________________________
>> >> From: Joseph S. Alcântara <[email protected]
<mailto:[email protected]>>
>> >> To: [email protected] <mailto:[email protected]>
>> >> Sent: Sunday, February 19, 2012 9:46 AM
>> >> Subject: [pygtk] PyGTK + OpenCV
>> >>
>> >> hi, I'm writing a application that uses pygtk and
opencv. and I had a
>> >> problem. When I run the program it shows a gui. So
far so good. But,
>> >> when I
>> >> click in a menuitem, it should call a functino that
runs the famous
>> >> routine
>> >> to show a video from webcam. But in this moment, the
app freezes. I
>> >> have
>> >> tried to use thread, but opencv gui runs just after
I call
>> >> gtk.main_quit().
>> >> What could solve my problem? Thanks.
>> >>
>> >> Estou escrevendo um programa em python, usando pygtk
e opencv. Quando
>> >> rodo
>> >> o programa, aparece uma janela e até aí, beleza. Mas
quando eu clico em
>> >> um
>> >> menuitem, ele deve chamar uma função que roda a
famosa rotina que exibe
>> >> um
>> >> vídeo a partir da webcam. No entanto, neste momento,
o programa trava.
>> >> Então, eu tentei usar Thread, mas a parte do opencv
só roda depois que
>> >> eu
>> >> fecho a janela, chamando gtk.main_quit(). O que
poderia ser? Obrigado
>> >> desde
>> >> já.
>> >>
>> >> Joseph Soares Alcântara
>> >> Engenharia da Computação - 8º semestre
>> >> Universidade Federal do Ceará - UFC
>> >> Sobral - Ceará
>> >>
>> >>
>> >>
>> >>
+--------------------------------------------------------------------------+
>> >> .| - °v°...A liberdade não pode ser comprada e sim |
>> >> .| -/(_)\..conquistada. Conquiste a sua também use |
>> >> .| - ^^ G N U / L I N U X
|
>> >>
>> >>
>> >>
+--------------------------------------------------------------------------+
>> >>
>> >>
>> >> _______________________________________________
>> >> pygtk mailing list [email protected]
<mailto:[email protected]>
>> >> http://www.daa.com.au/mailman/listinfo/pygtk
>> >> Read the PyGTK FAQ: http://faq.pygtk.org/
>> >>
>> >
>> >
>> > _______________________________________________
>> > pygtk mailing list [email protected]
<mailto:[email protected]>
>> > http://www.daa.com.au/mailman/listinfo/pygtk
>> > Read the PyGTK FAQ: http://faq.pygtk.org/
>
>
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/