Artifact 71b970f72efb8b399a08c6c727c559c7667cb053:
Wiki page
[
wmf command] by
chw
2021-09-01 12:51:16.
D 2021-09-01T12:51:16.047
L wmf\scommand
P a8d25b9a552587bf575185d793ffdf42d770dea7
U chw
W 9395
<h2>wmf command</h2>
<h3>Name</h3>
<b>wmf</b> - Tcl interface to cameras using Windows Media Foundation
<h3>Synopsis</h3>
<tt>package require tclwmf</tt><br>
<tt>wmf <i>option</i> ?<i>arg ...</i>?</tt>
<h3>Description</h3>
This command provides several operations to interface cameras using the infrastructure provided by Windows Media Foundation. <tt><i>option</i></tt> indicates what to carry out on the Windows Media Foundation subsystem. Any unique abbreviation for <tt><i>option</i></tt> is acceptable. The valid options are:
<tt>wmf close <i>devid</i></tt>
Closes the device identified by <tt><i>devid</i></tt> which has been opened before using <tt>wmf open</tt>.
<tt>wmf devices</tt>
Returns a list of device names which can be used for <tt>wmf open</tt>. Each device adds two elements to the list: its symbolic link to be used in <tt>wmf open</tt> and its friendly name for presentation.
<tt>wmf format <i>devid</i> ?<i>index</i>?</tt>
Returns or changes the media format of the device identified by <tt><i>devid</i></tt>. The optional parameter <tt><i>index</i></tt> is an integer number giving the index of the media format to be used as returned in <tt>wmf listformats</tt>. If omitted, the currently active index is returned. Changing the media format is only possible if the device is not capturing images.
<tt>wmf greyimage <i>devid</i> ?<i>photoImage</i>?</tt>
Copies the most recent captured image of the device <tt><i>devid</i></tt> into the photo image identified by <tt><i>photoImage</i></tt> and returns non-zero on success or zero if no data transfer has taken place. The photo image is filled with grey values. If <tt><i>photoImage</i></tt> 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 grey values as a byte array. In this case an error is indicated by throwing an exception.
<tt>wmf image <i>devid</i> ?<i>photoImage</i>?</tt>
Copies the most recent captured image of the device <tt><i>devid</i></tt> into the photo image identified by <tt><i>photoImage</i></tt> and returns non-zero on success or zero if no data transfer has taken place. If <tt><i>photoImage</i></tt> 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.
<tt>wmf info <i>devid</i></tt>
Returns information on open devices. If <tt><i>devid</i></tt> 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 <tt>wmf open</tt>. If <tt><i>devid</i></tt> is omitted, a list of <tt><i>devid</i></tt>s, i.e. all currently opened devices is returned.
<tt>wmf listformats <i>devid</i></tt>
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 <tt>wmf format</tt>.
<tt>wmf mbcopy <i>bytearray1 bytearray2 mask</i></tt>
Copies the content of RGB byte array <tt><i>bytearray2</i></tt> into the byte array <tt><i>bytearray1</i></tt> using an RGB <tt><i>mask</i></tt>. Both byte arrays must have identical length which must be a multiple of 3 (for RGB). The main purpose of this command is to combine images from two cameras into an anaglyph 3D, where (for a red-cyan anaglyph) the left camera image uses mask 0xFF0000 (red component) and the right camera image uses mask 0x00FFFF (green and blue components).
<tt>wmf mcopy <i>photo1 photo2 mask</i></tt>
Copies the content of the photo image <tt><i>photo2</i></tt> into the photo image <tt><i>photo1</i></tt> using an ARGB <tt><i>mask</i></tt>. Both photo images must have identical width, height, and depth. The main purpose of this command is to combine images from two cameras into an anaglyph 3D, where (for a red-cyan anaglyph) the left camera image uses mask 0x00FF0000 (red component) and the right camera image uses mask 0x0000FFFF (green and blue components).
<tt>wmf mirror <i>devid</i> ?<i>x y</i>?</tt>
Retrieves or sets flags to mirror captured images along the X or Y axis. Parameters <tt><i>x</i></tt> and <tt><i>y</i></tt> if specified must be boolean values.
<tt>wmf open <i>devname callback</i></tt>
Opens the device with device symbolic link <tt><i>devname</i></tt> and establishes <tt><i>callback</i></tt> as command to be invoked on captured images and finally returns a <tt><i>devid</i></tt>, i.e. a handle to further deal with the device. Two additional parameters are appended when <tt><i>callback</i></tt> is invoked: the <tt><i>devid</i></tt> of the device and the current capture state as in <tt>wmf state</tt>. For the format of <tt><i>devname</i></tt> see the description of <tt>wmf devices</tt>.
<tt>wmf orientation <i>devid</i> ?<i>degrees</i>?</tt>
Retrieves or sets the orientation of captured images regarding image rotation. <tt><i>degrees</i></tt> if specified must be an integer number.
<tt>wmf parameters <i>devid</i> ?<i>key value ...</i>?</tt>
Returns or changes device parameters for the device identified by <tt><i>devid</i></tt> given as key-value pairs, e.g. <tt>brightness 100</tt> 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 <tt>array set</tt> or <tt>dict get</tt>.
<tt>wmf record <i>devid</i> frame <i>width height bpp bytearray</i></tt>
Transcodes the frame described by <tt><i>width</i></tt>, <tt><i>height</i></tt>, <tt><i>bpp</i></tt>, and <tt><i>bytearray</i></tt> to JPEG and writes the result to the recording file or stream. The recording must have been started with the <tt>-user</tt> option. The bits per pixel parameter <tt><i>bpp</i></tt> 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.
<tt>wmf record <i>devid</i> pause</tt>
Pauses recording to a file or stream.
<tt>wmf record <i>devid</i> resume</tt>
Continues recording to a file or stream.
<tt>wmf record <i>devid</i> start <i>options ...</i></tt>
Starts recording to a file or stream. <tt><i>options</i></tt> control the data format, frames per second, and output channel. The option <tt>-fps</tt> specifies the approximate rate in frames per second as a floating point number. The option <tt>-chan</tt> specifies the channel to which the frames are written. This channel is detached from the Tcl interpreter and controlled solely by the <tt>wmf record</tt> command. The <tt>-boundary</tt> option specifies a MIME multipart boundary string and selects the MIME type <b>multipart/x-mixed-replace</b> suitable for streaming to a web browser. The content type delivered to the browser is <b>image/jpeg</b>. If the <tt>-boundary</tt> option is omitted, the output format is raw AVI and requires the channel to be seekable. The option <tt>-mjpeg</tt> 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 <tt>-user</tt> turns off automatic frame write operations to the recording file or stream when a frame is delivered from the device. Instead, <tt>wmf record <i>devid</i> frame</tt> must be invoked in the callback function. The <tt>-user</tt> option implies <tt>-mjpeg</tt>.
<tt>wmf record <i>devid</i> state</tt>
Returns the current recording state as <b>stop</b>, <b>recording</b>, <b>pause</b>, or <b>error</b>. The state <b>error</b> indicates a write error on the file or stream. In this case no further frames will be written.
<tt>wmf record <i>devid</i> stop</tt>
Finishes recording to a file or stream and closes the underlying channel.
<tt>wmf start <i>devid</i></tt>
Starts capturing images of the device identified by <tt><i>devid</i></tt>. When an image is ready, the callback command set on <tt>wmf open</tt> is invoked.
<tt>wmf state <i>devid</i></tt>
Returns the image capture state of the device identified by <tt><i>devid</i></tt>. The result is the string <b>capture</b> if the device is started, <b>stopped</b> if the device is stopped.
<tt>wmf stop <i>devid</i></tt>
Stop capturing images of the device identified by <tt><i>devid</i></tt>.
<tt>wmf tophoto <i>width height bpp bytearray</i> ?<i>rot mirrorx mirrory</i>?</tt>
Makes the RGB (<tt><i>bpp</i></tt> is 3) or grey (<tt><i>bpp</i></tt> is 1) byte array <tt><i>bytearray</i></tt> of <tt><i>width</i></tt> times <tt><i>height</i></tt> pixels into a Tk photo image. Optionally, the data is rotated by <tt><i>rot</i></tt> degrees (possible values 0, 90, 180, 270) and/or mirrored along the X and/or Y axis as specified by the boolean values <tt><i>mirrorx</i></tt> and <tt><i>mirrory</i></tt>.
Z 3a2368063e564b43afa5b3666fcc6921