Ir para o conteúdo

Software livre Brasil

Tela cheia
 Feed RSS

Eu, Fujii

27 de Maio de 2009, 0:00 , por Software Livre Brasil - | Ninguém está seguindo este artigo ainda.

Cheese 2.91.91 using Camerabin

12 de Março de 2011, 0:00, por Software Livre Brasil - 0sem comentários ainda

In January I started changing Cheese to use Camerabin as its pipeline base. I blogged about it twice, but, in case you missed it or forgot everything about it, let me repeat myself: Camerabin is the high level GStreamer element that basically does what a camera does, that is, take pictures, record video and show preview. Since Cheese does all that and more, it makes sense to use this element instead of re-implementing it all. The news part is that this work is now in Cheese’s master branch and also in release 2.91.91.

There are some other things I haven’t posted about yet:

Event handling: There was a warning in Cheese after the change to Camerabin which said “Internal GStreamer error: clock problem“. Investigating that I discovered that it was a problem in the input-selector that Camerabin uses internally.

Right now Camerabin has a copy of input-selector, because it uses the “select-all” property that was removed from current input-selector. The problem was that the input-selector didn’t handle upstream events (from the sink to the source direction) when the input-selector had the “select-all” property set. Well, input-selector can have many inputs and choose among them, as you can guess from the name. So, when select-all is set you need to send the event to all of those inputs. Other than the warning, this actually has no effect in Cheese’s case, because the event that is not forwarded (a latency event) wouldn’t actually be handled by the elements that don’t get it. Even so, I submitted a patch which was committed to master branch of gst-plugins-bad.

Taking photo without saving: Cheese Camera has a method that takes a photo and then provides the picture as a GDK pixbuf without saving it. The api may not be the best and there were some nice comments on how to improve it, but at least in Cheese without Camerabin this worked and it was used inside of cheese-avatar-chooser. Well, I didn’t realize that before my last blog post about Camerabin, but this was totally broken in my Camerabin branch, in fact, I hadn’t implement it at all.

Camerabin can send a preview message after taking a photo if you set the preview-caps with the desired format for the preview. I thought using the preview message was the best way to implement cheese_camera_take_photo_pixbuf(). The problem is that Camerabin only took photos to save them too, meaning the file name of the photo to be saved had to be set. Right now Cheese works around that by setting the file name to /dev/null, but I also sent a patch to Camerabin to allow taking a picture without saving if preview-caps is set, meaning it won’t encode the image just to save it to /dev/null. I’m keeping the workaround for now, since the change wasn’t released yet, but we will be able to remove it in the future.

Many thanks to Thiago Santos, who held my hand when I met those and other problems in Camerabin and who always encourages me to fix stuff and send patches.

I’m very excited about this change in Cheese. I’m sure there will be bugs, but I think using Camerabin will make some improvements in Cheese easier and we will grow with Camerabin (and maybe Camerabin2 in the future) and also push it to be better.

My GTK3 porting story

20 de Fevereiro de 2011, 0:00, por Software Livre Brasil - 0sem comentários ainda

It is now possible to run Cheese using GTK+ 3 getting it from Cheese’s branch gtk3.

Cheese has a gtk3 branch for a while, but until very recently it only had one patch changing mostly versions in Then Bastien Nocera made 3 more patches changing code of CheeseWidget, CheeseFlash and um-crop-area. I wanted to use the changes, and silly me, I thought the branch was going to compile when I first tried to run it. It turns out that I spent days on it until it finally compiled and then a little more time before I was able to run it.

Most of the changes were on build system and Cheese’s vala code. I have never programmed in vala before, so this was a learning opportunity with some challenges in the way.

Funny story

Cheese was still using libunique-1.0, but in order to work with gtk3 I would have to switch to libunique-3.0. There was no vala binding for libunique 3, but I also hadn’t found one for clutter-gtk-1.0 and I was using the GObject Instrospection one instead and it seemed to work at the time.

Using gir files didn’t work so well with libunique. Vala was loading the right gir file, but it said the namespace “Unique” did not exist. So, I asked for help on the #vala channel. The first piece of advice was to switch to GApplication instead of using libunique, but I didn’t know how hard that would be and I wanted to understand why I was unable to use libunique-3.0 first. With some more help from someone else in the #vala channel I found out that the Unique-3.0.gir file had the wrong package name on it. As I didn’t know how to fix that and I didn’t even know if it was a problem in libunique or a GObject Introspection parsing problem I asked for help in #introspection.

In the #introspection channel, Emmanuele Bassi (ebassi) was the one that helped me, libunique’s maintainer. Isn’t it nice when that happens? I mean, you’re just asking for anyone less clueless than you to help, but you can actually talk with people that work on what you’re using. Anyway, continuing with the long story, ebassi told me the problem was in libunique, that he wouldn’t work on it soon, but he encouraged me to file a bug for it and I did. It turned out that the bug was easy to fix (for him at least) and something like 15 mins later he had fixed it and pushed it to master already. That was a nice surprise!

But my problems didn’t end there. After I fixed some GObject Introspection annotation in libunique for my code to work, valac started to crash with a segfault. I reported it, but I still don’t know what the exact problem was. The only way I found to fix it was to switch to GtkApplication and stop using libunique. If only I had listened to that first advice! Using clutter-gtk with GObject Introspection did not work in the end either, but turns out I was just missing the recently released vala binding for it.

I learned many things on this quest. I had never looked at gir files or vapi files before and I learned a little trying to debug and fix problems. The non-technical lessons were: it’s really painful to use stuff that is new and not widely used (yet?), you will find problems. But it’s also very nice to be able to fix the problems and work with helpful people.

By the way, to share my love for GNOME I’m organizing a GNOME 3.0 Release party in my town – Belo Horizonte, Brazil. So, if you’re in the area, save April 9th and get in touch if you want to help with organization.

Update: Patricia Santana Cruz had already made a patch to port Cheese to Gtk.Application (which is also way better than mine), so if I was any smarter I wouldn’t have half of the work I did. And now I know she is also one of the responsibles for we having the clutter-gtk-1.0 binding for vala too and she is working on some more bugs in vala and going after the warnings that affects Cheese. In short, she is awesome!

Presenting the new Libcheese

1 de Fevereiro de 2011, 0:00, por Software Livre Brasil - 0sem comentários ainda

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.

Cheese with Camerabin

21 de Janeiro de 2011, 0:00, por Software Livre Brasil - 0sem comentários ainda

So, last week I posted I started changing Cheese to use Camerabin, the high level GStreamer element that can capture video, photos and show preview. I can now say that Cheese is now working using Camerabin as its base, at least for me and two other people.

I’m a little embarrassed to say that the black preview problem I was having all along was actually because of lack of dconf installed in jhbuild. Because of that, my contrast and saturation were always set to zero when I started Cheese and I thought that was a problem with the preview, specially because I did have a problem with clutter-gst before. Thanks to Laura I discovered that.

Other problems were much easier to solve after I stopped debugging this nonexistent problem. The main problem was that Camerabin sets a lot of stuff by default, such as resolution and filtered video format. This caused a lot of negotiation problems depending on which camera was used or which size of photo or video was requested. After working around the defaults, it seems to be working ok now.

Another improvement was to use Camerabin’s signal “set-video-resolution-fps” to set resolution for photo and video, instead of using a capsfilter for that. In the future, we might be able to switch between photo-capture and video-capture modes in Cheese without turning off the camera. But, for now, I’ll leave it like it used to be, specially because it seems Camerabin doesn’t set image-capture size separate from video-capture size as it should.

I just posted a bug with the patch to add camerabin to master in Cheese. I really hope it’s working perfectly, but it would be really nice to have more people testing it. So, if you feel like it, check camerabin branch and tell me the results.

Next week I plan to work on other improvements in libcheese. Maybe I’ll try to make some improvements in the API before the API freeze for 3.0.

Cheese slowly moving to camerabin

14 de Janeiro de 2011, 0:00, por Software Livre Brasil - 0sem comentários ainda

This week I started working on libcheese to see if it is in a better shape for GNOME 3.0.

Last week I talked briefly about Cheese Widget not working right. I continued to look into that and discovered that the reason cheese-test-widget was not working was gconfaudiosrc, the source Cheese uses to capture audio. It makes sense that this doesn’t work, since Cheese is now using GSettings, but I really couldn’t understand why Cheese works with it (without using Cheese Widget) and cheese-test-widget doesn’t (and with the same code for pipeline). The fact is that replacing gconfaudiosrc solved the problem for cheese-test-widget.

Instead of changing only the audio source, I decided to start changing Cheese to use Camerabin. This is one of my goals for GNOME Outreach Program. Camerabin takes care of taking pictures, recording video and preview, so it fits Cheese perfectly, and Cheese won’t have to do this all again.

First part of using Camerabin in Cheese worked great, with some help of my mentor Thiago, camerabin specialist. I even made a small patch for camerabin. I can take pictures and record video using Cheese with Camerabin, and it even solved a bug that I had using Cheese master branch.

The tricky part about using Camerabin in Cheese is that, besides recording video and taking pictures, Cheese has effects, and it does a live preview of this effects. You can set a “video-source-filter” property in Camerabin which takes a GStreamer element as argument and sets a filter between capture and all the other components (video-capture, image-capture, view finder).

I tried to add Cheese complexity inside this video-source-filter, with a big Gstreamer Bin that splits camera into the branch that is going to image capture, video capture and preview and the other branch that will be used for live preview of the effects. When I added that, I started experiencing again the black preview bug. Since I’m the only one that I know having this bug and can’t find a way to fix it, I can’t actually tell if other people would actually see the preview when using Cheese with Camerabin. I have been trying to persuade some people to test it for me and tell me. Maybe you could do it too? Check camerabin branch in Cheese repository in

One thing that is definitely broken is to apply effects. Yes, I know Cheese is no fun without it. I am working on getting it fixed. If you have worked with GStreamer for a while, you probably had negotiation problems that were hard to fix too.

While working on that I ended up making a patch to be applied to master to handle GStreamer warning and error messages. And another one just removing an extra colorspace.

Tags deste artigo: gnome cheese gstreamer free software software livre