About Archive Tags RSS Feed


Coding: GtkCam

11 March 2005 21:50

Steve in code writing shocker!

I've been writing original code this morning for the first time in months, and I feel fine!

Once upon a time I wrote a simple console application to grab a single frame from a webcam and output it to a .jpg file, camgrab. I've used this off and on ever since to take still images from my webcam, or to place shots online with a timer.

But it's very frustrating to write the following then realise you're not in the shot properly, or the lighting sucks

sleep 1 ; camgrab

So I decided to solve this by writing a GUI which would show a preview - like the applications I've seen people use on Windows.

I have a main window which shows the live view from the webcam, updating every half second. When you click on the main window it will save the currently displaying image to a numbered) file.

This allows a lot more flexaiblity.

I'm suprised something like this doesnt exist already, but I couldn't find anything with a quick search except for camstream which seems like a lot of overkill for me. I guess it does the same job but in a sexier way. (I notice it doesn't use temporary files, so I should investigate it's code).

I've used:

  • GTK
  • ImLib2
  • giblib
  • The Linux videodev interface

The code is nasty it grabs a frame, writes it to a temporary file, then updates the GUI. I can't seem to display an imlib2 image to a GtkImage object without that step - which seems to suggest I'm missing something obvious.

If there are any comments asking I'll post the source online. Nothing fancy, no timer to countdown or menubars…

Single sample output here (No I'm not that vain, just trying to document weight loss in my arms).

Update - Current source gtkcam. Needs to be refactored and improved.

| No comments