[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Linux Cairo, webcam displaying images

Mike Durham

11/10/2006 11:52:00 PM

G'day
Can anyone please advise me on how to constantly display the output from
a webcam using Ruby & Cairo?
I can operate the webcam, write images to disk etc and I can display a
Gdk::Pixbuf okay. It's just the updating of an image on the screen that
I'm missing.

The data returned from V4l is a ruby 'string' but how do I display it?
At first I thought to display a blank Gdk::Pixbuf of correct size
(640x480) and constantly modify it's buffer but I think this might not
be possible from within Ruby???

====
From the Ruby-Gnome2 site it says:
Gdk::Pixbuf.new(colorspace, has_alpha, bits_per_sample, width, height)
Creates a new Gdk::Pixbuf and allocates a buffer for it. The buffer
has an optimal rowstride. Note that the buffer is not cleared; you will
have to fill it completely yourself. Raises an...
====

note "you will have to fill it completely yourself" how is this achieved
in Ruby?

Any help would be most welcome.

Cheers, Mike
5 Answers

Kouhei Sutou

11/11/2006 3:59:00 AM

0

Kouhei Sutou

11/11/2006 4:13:00 AM

0

Mike Durham

11/11/2006 6:15:00 AM

0

Kouhei Sutou wrote:
> Hi,
>
> In <20061111.125758.14759375.kou@cozmixng.org>
> "Re: Linux Cairo, webcam displaying images" on Sat, 11 Nov 2006 12:58:41 +0900,
> Kouhei Sutou <kou@cozmixng.org> wrote:
>
>>> Can anyone please advise me on how to constantly display the output from
>>> a webcam using Ruby & Cairo?
>> Data from webcam (String) -> Gdk::Pixbuf ->
>> Cairo::ImageSurface.new(data, format, width, height, stride) ->
>> Cairo::Context.new(Cairo::XXXSurface.new) ->
>> context.set_source(image_surface) -> context.paint
>
> I mistook. Gdk::Pixbuf isn't needed.
>
> Data from webcam (String) ->
> Cairo::ImageSurface.new(data, format, width, height, stride) ->
> Cairo::Context.new(Cairo::XXXSurface.new) ->
> context.set_source(image_surface) -> context.paint
>
> Thanks,
> --
> kou
>
Thanks for the info kou,
Just a couple of questions to clarify things if you wouldn't mind.

> Cairo::ImageSurface.new(data, format, width, height, stride) ->

is 'data' a Ruby string returned from the V4l?

what is 'format'?

Thanks for your help kou
Mike

Kouhei Sutou

11/11/2006 6:55:00 AM

0

Mike Durham

11/11/2006 7:46:00 AM

0

Kouhei Sutou wrote:
> Hi,
>
> In <45557881_4@news.peopletelecom.com.au>
> "Re: Linux Cairo, webcam displaying images" on Sat, 11 Nov 2006 15:20:04 +0900,
> Mike Durham <mdurham@people.net.au> wrote:
>
>> Just a couple of questions to clarify things if you wouldn't mind.
>>
>> > Cairo::ImageSurface.new(data, format, width, height, stride) ->
>>
>> is 'data' a Ruby string returned from the V4l?
>
> Yes, it's a String. But I don't know V4l's data format. So,
> I can't promise you that you can use V4l's data directory.
>
>> what is 'format'?
>
> One of the cairo_format_t:
> http://www.cairographics.org/manual/cairo-Image-Surfaces.html...
>
> In rcairo, those formats are mapped to Cairo::FORMAT_XXX.
>
>
> Thanks,
> --
> kou
>
Thanks a lot kou, you're a star.
Cheers, Mike