Version 8 of Webcams / Digital Cameras

Updated 2005-06-13 19:56:56

MG starts this page on June 12th 2005, to list some of the Tcl applications or extensions for working with Digital Cameras or Webcams.

I wanted to capture some footage from a webcam (or at least see if it was possible) for embedding it in a webpage (I have a program that converts most common movie formats into Flash movies files at the touch of a button), and thought I'd see about doing it in Tcl. There seem to be several extensions (generally aimed at MS Windows, it seems) for working with web cams, so below is a list of all the ones I've found, after a very brief search. If anyone has any more extensions, or info on using webcams or digital still cameras with Tcl and/or Tk, please post it here!

QuickTimeTcl provides a webcam capture facility, according to its homepage, which I believe runs on MS Windows and MacOS (and requires that Quicktime be installed, on both).

Pat Thoyts wrote a Tk widget for displaying streaming video from a webcam. It can also take still images from the webcam, but can't save the video to a file/pipe it through a channel, at present. See [L1 ] and [L2 ] for more info.

PT: 13-Jun-2005: I can look into streaming to a file if you'd like. The tkvideo widget basically wraps the DirectShow API so it's mostly a matter of constructing the correct filter graph and deciding how this should be presented to the Tk programmer.

MG That would be really great. The two main things I'd like to be able to achieve with webcams myself are

  • record "movies" - basically, save to a file in any recognised movie format (that being, whatever's possible will be great, not that I want 'em all:)
  • pipe the video through a channel - basically for displaying in a widget just like your code does now, Pat, but on a different computer (for instant messaging-type programs, etc).

Whether those two things would basically be the same (for instance, piping AVI-movie data down a channel, and a widget at the other end reading it and displaying it) or not, I don't know - beyond using things from Tcl, I'm completely clueless. QuickTimeTcl is apparantly capable of doing it, but I've had problems myself with it crashing my application - and all the extra features, plus the dependance on Quicktime itself (which you now can't download without 'iTunes', I don't believe), are let-downs, IMHO. So.. yeah, anything you do if you get time would be absolutely brilliant :)

The AviCapTcl package on Sourceforge (at [L3 ], and apparantly also [L4 ], though the second is down due to a work at present) also supports webcam video (and audio) capture to an AVI movie file.

And finally, though I haven't looked at it yet (and taken straight from the Applications in Tcl and Tcl/Tk page: Audela is a free and open source astronomy software intended for digital observations (CCD cameras, Webcams, etc.). Audela is fully customizable and reprogrammable using simple Tcl-Tk scripts. It enables not only camera control, but also full telescope control, locally or at long distance via a network. It has been written for both Windows and Linux platforms and is available in 6 languages (fr,uk,es,it,de,dk). See [L5 ]

SRIV June 12th 2005 I wrote a v4l (video for linux) tcl extension to capture frames from a framegrabber (bt848), but it's been tested with a Phillips/Logitech USB webcam and Logitech USB notebook cam. It doesnt require Tk, so it can be easily used in server-side and cgi applications. It grabs a frame, then converts it to jpeg and returns the jpeg file data, which could then be streamed back to a client as stills or a mjpeg stream. I'll get a page assembled for it here in the next day or so.

MG today (June 13 05) tested PT's tkvideo and the AviCapTcl package on Win XP SP2, just by running their demos. PT's tkvideo works great. The AviCapTcl package displays the webcam on-screen fine, but running their 'test-avicap' demo, to record to an AVI file, only recorded a very (less than 1 second) brief clip, though it should've recorded more. I'll see if I can find out why later...

I haven't looked at QuickTimeTcl's webcam features yet - I tried them once before, and it crashed, but I now have reason to believe the crash was from my drivers, not QuickTimeTcl, so will re-try it later on...

Harm Olthof June 13 2005 - I am not much of a programmer (Windows or Tcl), but this worked for me, using tcom to interface Windows XP's WIA (Windows Image Acquisition).

   package require tcom
   ::tcom::import c:/WINDOWS/system32/wiascr.dll

   set WIAobj [::WIALib::Wia]
   set WIAdevice [$WIAobj Create]
   set WIAcoll [$WIAdevice GetItemsFromUI]
   for {set i 0} {$i<[$WIAcoll Count]} {incr i} {
       set WIAitem($i) [$WIAcoll Item $i]  
      $WIAitem($i) Transfer d:/pic_${i}.bmp 0

This works only for stills, but video should also be possible. More info at [L6 ] I could not getting to work transfering to "clipboard" or using "TakePicture".

Category Multimedia