(Unix version only) Acquires an image from a camera, with a user-supplied driver. For example, images can be acquired from the Connectix QuickCam 2 using the program cqcam, available from: www.cs.virginia.edu/~patrick/quickcam
A driver is a command-line program that writes a file to standard output in PNM format. Tnimage controls the driver using the driver's command line parameters, which are stored in a configuration file when the camera is given the ``initialize'' command.
Below is the procedure for configuring a new camera interface, if it has not already been set up automatically by the Install program:
For example:
quickcam
mycamera
my_other_camera
mycamera-at-320x200
| driver /home/you/camera/cqcam | Path for driver binary |
| defaults /home/you/.cqcrc | Path for driver's configuration file (see below) |
| other -32+ | Any other command line options. |
| scale -s | Driver's command to set scale |
| width -x | Driver's command to set width. |
| height -y | Driver's command to set height. |
| brightness -b | Driver's command to set brightness. |
| black -B | Driver's command to set black level |
| white -w | Driver's command to set white balance |
| hue -H | Driver's command to set hue (blue level). |
| saturation -S | Driver's command to set saturation |
| contrast -c | Driver's command to set contrast. |
| initialize -a+ -r | Driver's command(s) to initialize the camera. |
| normal -a- | Command(s) to acquire an image normally. |
| extra | Any other command line options. |
Anything entered after ``other'' will be placed immediately after the driver name on the command line. In this example, -32+ was added as a sample ``other'' command line option (this causes the driver to produce 32-bit/pixel output).
The ``initialize'' command should also include any options for automatically saving the driver's new configuration in its config file ( -r in this case).
Anything entered after ``extra'' will be placed at the end of the command line. In this example, no extra commands will be sent.
Change the command-line options as needed for your driver. The numerical values for the above parameters will be supplied by tnimage.
Any of the above options may be omitted if desired.
NOTE: Each camera driver has different command-line options. For example, the ``-s'' command sets the scale for cqcam but other camera drivers may use a completely different command line option. Consult the driver documentation before creating a config file.
Next, add the following default parameters to the ``mycamera'' configuration file, along with the desired numbers. Change the width and height to match the image size produced by the camera:
| #default parameters | A comment (begins with #) |
| default_shell 1 | 1= put camera image in a separate, positionable window. |
| default_width 640 | Width in pixels of image created by camera. |
| default_height 480 | Height in pixels of image created by camera. |
| default_scale 1 | Starting scale value for camera. |
| default_depth 3 | Bytes/pixel of image produced by camera. |
| default_post_command | Post-processing command |
If ``default_shell'' is 0, the camera image will appear on the main tnimage window; otherwise, it will be placed in its own separate, positionable frame.
The default_post_command can be any tnimage command or macro. If the box beside the command is checked, this command will be executed as a macro after every frame. For example, the line
default_post_command filter(1,1,10);
Will sharpen the image by 10% using a 3x3 sharpening filter after each frame. See Sec. 13 for details on macros.
A common use of post-processing is to adjust the image color. This can be done by entering a mathematical formula (See ``image algebra'', Sec. 12), for example,
r+=20;
to increase the brightness of the red component by 20 (on a scale of -255 to 255). For simple commands such as color or brightness adjustment, it is usually much faster to use the corresponding macro command, i.e.:
color(0, 20, 0, 0);
which will do the same thing, nearly instantaneously.
Note that the post-processing command is not executed unless the box next to it is checked.
| contrast 104 | Contrast |
| white 100 | White balance |
| blacklevel 100 | Black level |
| hue 110 | Hue (blue level) |
Put the name and path of this .cqcrc file after ``defaults'' in the first (`mycamera') file. These parameters will be the starting default values for the camera. (Note: cqcam produces a .cqcrc file automatically). During initialization, the dialog will automatically be updated to reflect the new settings in the defaults file.
As an example, here is the $HOME/.tnimage/cameras file on my system:
quickcam
Here is the $HOME/.tnimage/quickcam file on my system:
# tnimage configuration file for connectix quickcam
# order of parameters may be important
# command-line options for camera driver
driver /home/tjnelson/camera/cqcam-0.45a/cqcam
defaults /home/tjnelson/.cqcrc
other -32+
scale -s
width -x
height -y
brightness -b
black -B
white -w
hue -H
saturation -S
contrast -c
initialize -a+ -r
normal -a-
# default parameters
# 0=put camera image on main window, 1=put in separate window
default_shell 1
# width and height of image produced by camera
default_width 640
default_height 480
# scale of image as defined by camera driver
default_scale 1
# depth of camera image, in bytes/pixel
default_depth 3
# default post-processing command or macro name
default_post_command filter 1 1 10
Here is the $HOME/.cqcrc file on my system, which was created by the driver:
brightness 127
A camera config file and a patch for the bttv driver for the Hauppauge WinTV camera card is included in the file bttv_kit.tgz. (This file was contributed by Michael Lapsley (mlapsley@sthelier.sghms.ac.uk)).
Camera Dialog Options
Acquisition mode
in For example, below is a low-resolution image of an infrared TV remote control created using a QuickCam (which is sensitive to infrared as well as visible light). The original top image A contains numerous vertical streaks. Subtracting the dark current produced B. The vertical streaks are mostly eliminated, although the picture is more grainy. This could have been repaired by accumulating several frames. Darker scenes are more susceptible to dark current artifacts.
Camera
Frames
When the ``OK'' button or the main ``Cancel'' buttons are clicked, image acquisition stops and the dialog box disappears, leaving the camera image that is currently visible as the final image.
Notes: