Video capture Isis software documentation

Video capture

This library provides platform-independent objects and routines for capturing video from external sources. Images are handled using the image buffer protocol.

Video capture object

(set vidcap (new-video-capture option option ...)) # initialize video capture new-video-capture initializes whatever video capture system is available on the machine. A procedure is returned that serves as the interface to the capture system.

Settin capture parameters

You can pass several options to new-video-capture to set capture parameters. Options take the form of lists in which the first item is an "opcode" that identifies the option and the second item is the value for that option. Below is a list of the accepted options which, if not passed, default to the specified values.

[vc-size [xsize ysize]] # set capture frame size # default is [320 240] [vc-format format] # set format of returned images # may be: vc-rgb, vc-yuv, vc-grey # default is vc-rgb [vc-device devicenum] # set device number # default is 0 [vc-input input] # set input number # default is 1 [vc-standard standard] # set video standard # may be: vc-ntsc, vc-pal, vc-secam # default is vc-ntsc [vc-field fieldmode] # set fields to capture # may be: vc-odd, vc-even, # vc-both, vc-interlace # default is vc-even Most of these options are self-explanatory. vc-device enables the selection of different physical capture devices, while vc-input enables the selection of different inputs on the same device, if available. Some configuration settings will not be available on all platforms, and in such a case, either an error message will be printed or a suitable alternate setting will be used.

Capturing images

(vidcap) # capture frame, return Isis image

The procedure that is returned from new-video-capture is your interface to the capture device. To capture an image, simply call this procedure with no arguments. It will return the captured frame in the form of a byte-sampled Isis image (3 channels for vc-rgb data, 1 channel for vc-grey data) or a list of 2 isis images if capturing vc-yuv data [y-image uv-image].

The returned images are only valid for processing from the time they are returned until the next call to capture a frame. If the data inside must survive longer, copy it to a separate location before making the next capture call.

Finishing capture

(vidcap vc-close) # close capture and free resources Call the video capture object with vc-close when finished so the capture device can be released and used by other processes.


The following captures a single frame and displays it.
(set vidcap (new-video-capture)) (set win (easywin-create (vidcap))) (vidcap vc-close)
This example creates continuous live video in a window.
(set framesize [640 480]) (set vidcap (new-video-capture [vc-size framesize])) (set window (win-create [win-size framesize] [win-title "Capture"])) (while True (window [win-put (vidcap)] [win-output]))
The following captures YUV format images and displays the separate channels continually in a window.
(set vidcap (new-video-capture [vc-format vc-yuv])) (set win (win-create [win-size [640 240]])) (while True (begin (set yuvbuf (vidcap)) (win [win-put (yuvbuf 0)] [win-put (isolate-channel 0 (yuvbuf 1)) [320 0]] [win-put (isolate-channel 1 (yuvbuf 1)) [480 0]] [win-output])))

Scripts: (load "video-capture.isis")
Other: At least one of the following libraries should be operational:
Video for Linux 2