Warning

### USB camera Chameleon

Camera Chameleon is digital USB 2.0 camera Chameleon manufactued by PointGrey.

### Camera control

The camera can be operated in MATLAB via Image Acquisition Toolboxu.

1. Camera can be accessed as follows
vid = videoinput('winvideo',1,'Y800_1280x960');
2. If you need to change capturing parameters (the default setting is fully automatic camera), the following script sets the manual control::
inspect(getselectedsource(vid));
or the following command sets a parameter value:
set(getselectedsource(vid), 'PropertyName', 'PropertyValue');
If you need to determine the current value of the parameter it is possible to use the command
get(getselectedsource(vid), 'PropertyName');
Useful information can be obtained by calling
propoinfo(getselectedsource(vid), 'PropertyName');
NOTE: Most of the parameters influencing the image capturing can be set only when capturing is off (before calling “start(vid)”).
3. Capturing of the endless video stream is initiated by the following commands
set(vid,'TriggerRepeat',Inf);
vid.FrameGrabInterval = 1;
start(vid);
4. The following command reads one frame from the current buffer
im = getdata(vid,1);
5. The camera provides video in RAW format, therefore debayering is needed. This can be done for example by using the following commands. We could not figure out how to change the white balance for blue channel in the MATLAB environment, therefore blue channel must be multiplied by an appropriate value
im_debay(:,:,1) = im(2:2:end,1:2:end);
im_debay(:,:,2) = im(1:2:end,1:2:end)/2 + im(2:2:end,2:2:end)/2;
im_debay(:,:,3) = 6.5 * im(1:2:end,2:2:end);
6. Eventually, you can clear the memory by the following commands
stop(vid);
delete(vid);

### Parameter Settings

As described above, it is possible to set some camera parameters in the MATLAB environment. These parameters influence the image provided by the camera, and they are therefore important for the successful use of the camera. Description of paremeters in the camera documentation is very limited. Therefore, we conducted a limited survey and testing in order to determine the possibility to set the capturing parameters.

Unfortunately MATLAB interface allows to adjust only a limited number of parameters. The following parameters can be set:

Gain - This parameter is used to change the gain of the video signal amplifier. With the growing gain, grows also the image brightness, but unfortunately also the noise. If it is not necessary for other reasons (e.g. maintaining a slow shutter speed), it is recommended to set the gain at 1.0 ~ 0 dB (output = input). Gain value equal to 0dB corresponds to the value of parameter 160.

set(getselectedsource(vid),'GainMode','manual');
set(getselectedsource(vid),'Gain',160);

Gamma - Sets the amount of non-linear amplification of the video signal. Non-linear amplification compensates (i) imaging device inaccuracy and (ii) the human perception properties (details e.g. Wikipedia:Gamma correction). This additional nonlinear compensation has no meaning for autonomous computer processing. It can reduce measurement accuracy for some brightness levels due to uneven discretization. Therefore, we recommend that you set up the scanning without compensation, which corresponds to the gamma=1.0. Gamma equal to 1.0 corresponds to the value of the parameter equal to 1024.

set(getselectedsource(vid),'GammaMode','manual');
set(getselectedsource(vid),'Gamma',1024);

WhiteBalance - White Balance determines the overall mixture of colors in an image (Wikipedia:White balance). Autonomous white balance setting of the Chameleon camera is not properly implemented and the used algorithm is not described. You are encourage to play with it. If you do not need to use a color image, we recommend to set this parameter manually to the default value equal to 100.

set(getselectedsource(vid),'WhiteBalanceMode','manual');
set(getselectedsource(vid),'WhiteBalance',100);

Brightness - is a global parameter, which can be used to adjust the overall brightness in the image. This parameter does not have a direct physical meaning. If “Shutter ” and “ Gain” are set to “Auto Select”, brightness value directly influences these parameters​. Method for determining the brightness of the image (and the corresponding algorithm) is not described in detail. In our case, if the “Shutter ” and “ Gain” are adjusted manually (not automatically), then “Brightness” has no influence on the camera settings.

Unfortunately, the shutter speed setting (“Shutter”) is not allowed in the Matlab environment. However, “Brightness” can be used for this purpose. If you set the “Brightness” mode to “auto” (using the program AMCAP Shutter) and set the appropriate constant value of the “Exposure”, then “Brightness” directly influences the shutter speed (“Shutter”). However, the shutter speed will change according to “Brightness” with a certain delay corresponding to the time constants of the automatic camera settings.

For all the above mentioned parameters, there is always pair parameter “NameMode”. This pair parameter determines which value will be adjusted manually and which automatically. Automatic setting is provided directly by the camera. In the automatic setting, it is necessary to take into account the time constants of the in-built algorithm. Stabilization of automatically set values ​after the arameter change should be about 1s.

AMCAP program (provided by the camera manufacturer) is suitable for real-time monitoring of parameter changes. Running the AMCAP program simultaneously with capturing in the Matlab environment is not recommended. Problems are as follows:

• Irregular distribution of captured frames between the two programs. Variable frame rate and/or transport delay is especially annoying during the critical time image processing (closing the feedback loop).
• Picture degradation (spillage) when using different image resolution.