Ir para o conteúdo

Software livre Brasil

 Voltar a Eu, Fujii
Tela cheia

Presenting the new Libcheese

1 de Fevereiro de 2011, 0:00 , por Software Livre Brasil - 0sem comentários ainda | Ninguém está seguindo este artigo ainda.
Visualizado 173 vezes

Yesterday Daniel made a new Cheese release. It contains a library called simply LibCheese that contains basically a way to take photos, record video and see preview with your webcam plus some detecting stuff. It also allows you to add an effect to that.

LibCheese without GTK

Libcheese concept exists for a long time now, but it was not in a good shape. There used to be two libraries in cheese, one called libcheesecommon, that was only used internally, and one called libcheese-gtk that was installed. The problem is that Cheese is still using GTK+ 2, which is a deal breaker for potential users such as The Board. Also, libcheese-gtk has some things that are a bit old and are not very useful right now.

What I did was to change libcheesecommon to contain only non-gtk stuff and then export it calling it libcheese, which was Lucas‘ idea. So, even though Cheese is still using GTK+ 2, applications using GTK+ 3 can use libcheese if they want to. This involved changing cheese-flash to libcheese-gtk instead of libchesecommon, but also removing some old GTK code stuff that was not being used anymore.

Taking advantage of the moment, Daniel also removed cheese-countdown.c, which draws the countdown on the GtkWindow, since Cheese now uses cheese-countdown.vala that draws countdown on top of the video preview using clutter.

GObject Introspection

I also started annotating CheeseCamera, which is the main part of LibCheese, to allow applications written in different languages to use it. While doing that I made small changes to the api to help GObject Introspection annotation such as adding const to strings when appropriate. You can find my not yet tested GObject Introspection annotation in libcheese branch, and the other changes are all already in master and in the new release.

Next step will be to test and improve GObject Introspection annotation. If jhbuild is nice to me I might try to use LibCheese in The Board.

Quick LibCheese example

I also added a new test to Cheese that tests CheeseCamera, which is also a good example of how to use LibCheese. Here are the important bits:

CheeseCamera *camera;

camera = cheese_camera_new (CLUTTER_TEXTURE (texture), NULL, width, height);

cheese_camera_setup (camera, NULL, &error);

cheese_camera_play (camera);

The texture is the ClutterTexture where you want the video to be drawn. You can also set the device name instead of using NULL to create CheeseCamera.

To take a picture after that:

cheese_camera_take_photo (camera, filename);

To record video:

cheese_camera_start_video_recording (camera, filename);

cheese_camera_stop_video_recording (camera);
Special thanks to kov for helping me with autotools and other build issues in the worst hours possible.


0sem comentários ainda

Enviar um comentário

Os campos são obrigatórios.

Se você é um usuário registrado, pode se identificar e ser reconhecido automaticamente.