wmf command
Not logged in

Name

wmf - Tcl interface to cameras using Windows Media Foundation

Synopsis

package require tclwmf
wmf option ?arg ...?

Description

This command provides several operations to interface cameras using the infrastructure provided by Windows Media Foundation. option indicates what to carry out on the Windows Media Foundation subsystem. Any unique abbreviation for option is acceptable. The valid options are:

wmf close devid

Closes the device identified by devid which has been opened before using wmf open.

wmf devices

Returns a list of device names which can be used for wmf open. Each device adds two elements to the list: its symbolic link to be used in wmf open and its friendly name for presentation.

wmf format devid ?index?

Returns or changes the media format of the device identified by devid. The optional parameter index is an integer number giving the index of the media format to be used as returned in wmf listformats. If omitted, the currently active index is returned. Changing the media format is only possible if the device is not capturing images.

wmf image devid ?photoImage?

Copies the most recent captured image of the device devid into the photo image identified by photoImage and returns non-zero on success or zero if no data transfer has taken place. If photoImage is omitted, a four element list is returned with the first element being the image width, the second the image height, the third the number of bytes per pixel, and the last the image's RGB values with 3 bytes per pixel in red, green, blue order as a byte array. In this case an error is indicated by throwing an exception.

wmf info devid

Returns information on open devices. If devid is specified, a list of two elements is returned, the first being the device symbolic link and the second the image callback command for that device, i.e. the same arguments which were used on wmf open. If devid is omitted, a list of devids, i.e. all currently opened devices is returned.

wmf listformats devid

Returns a dictionary keyed by a media format index as integer with the values being another dictionary with information about the frame size and rate of that media format. The respective index can be used in wmf format.

wmf mirror devid ?x y?

Retrieves or sets flags to mirror captured images along the X or Y axis. Parameters x and y if specified must be boolean values.

wmf open devname callback

Opens the device with device symbolic link devname and establishes callback as command to be invoked on captured images and finally returns a devid, i.e. a handle to further deal with the device. Two additional parameters are appended when callback is invoked: the devid of the device and the current capture state as in wmf state. For the format of devname see the description of wmf devices.

wmf orientation devid ?degrees?

Retrieves or sets the orientation of captured images regarding image rotation. degrees if specified must be an integer number.

wmf parameters devid ?key value ...?

Returns or changes device parameters for the device identified by devid given as key-value pairs, e.g. brightness 100 will change the brightness setting of captured images to the device dependent value 100. The command returns the current device parameters (after the potential change, when keys and values were given) as a key-value list which can be processed with array set or dict get.

wmf record devid frame width height bpp bytearray

Transcodes the frame described by width, height, bpp, and bytearray to JPEG and writes the result to the recording file or stream. The recording must have been started with the -user option. The bits per pixel parameter bpp must be 3. An integer number is returned as result: 1 indicates successful write, 0 no write due to frame rate constraints, and -1 an error during the write.

wmf record devid pause

Pauses recording to a file or stream.

wmf record devid resume

Continues recording to a file or stream.

wmf record devid start options ...

Starts recording to a file or stream. options control the data format, frames per second, and output channel. The option -fps specifies the approximate rate in frames per second as a floating point number. The option -chan specifies the channel to which the frames are written. This channel is detached from the Tcl interpreter and controlled solely by the wmf record command. The -boundary option specifies a MIME multipart boundary string and selects the MIME type multipart/x-mixed-replace suitable for streaming to a web browser. The content type delivered to the browser is image/jpeg. If the -boundary option is omitted, the output format is raw AVI and requires the channel to be seekable. The option -mjpeg forces the recorded data to JPEG format, i.e. a transcoding to JPEG will be performed in software, if the device doesn't already deliver a JPEG stream. The option -user turns off automatic frame write operations to the recording file or stream when a frame is delivered from the device. Instead, wmf record devid frame must be invoked in the callback function. The -user option implies -mjpeg.

wmf record devid state

Returns the current recording state as stop, recording, pause, or error. The state error indicates a write error on the file or stream. In this case no further frames will be written.

wmf record devid stop

Finishes recording to a file or stream and closes the underlying channel.

wmf start devid

Starts capturing images of the device identified by devid. When an image is ready, the callback command set on wmf open is invoked.

wmf state devid

Returns the image capture state of the device identified by devid. The result is the string capture if the device is started, stopped if the device is stopped.

wmf stop devid

Stop capturing images of the device identified by devid.

wmf tophoto width height bpp bytearray ?rot mirrorx mirrory?

Makes the RGB (bpp is 3) or gray (bpp is 1) byte array bytearray of width times height pixels into a Tk photo image. Optionally, the data is rotated by rot degrees (possible values 0, 90, 180, 270) and/or mirrored along the X and/or Y axis as specified by the boolean values mirrorx and mirrory.