Search
Camera Chameleon is digital USB 2.0 camera Chameleon manufactued by PointGrey.
The camera can be operated in MATLAB via Image Acquisition Toolboxu.
vid = videoinput('winvideo',1,'Y800_1280x960');
inspect(getselectedsource(vid));
set(getselectedsource(vid), 'PropertyName', 'PropertyValue');
get(getselectedsource(vid), 'PropertyName');
propoinfo(getselectedsource(vid), 'PropertyName');
set(vid,'TriggerRepeat',Inf); vid.FrameGrabInterval = 1; start(vid);
im = getdata(vid,1);
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);
stop(vid); delete(vid);
addpath('/opt/flygrab');
img = flygrab();
Driver documentation: pointgray_camera_driver
Start camera driver nodes:
# Assuming that the B3B33ROB ROS Enviroment was properly sourced i.e. : source /opt/ros/b3b33rob # just camera driver $ roslaunch b3b33rob_ros camera.launch # or camera with robot $ roslaunch b3b33rob_ros start_rv6sdl.launch camera:=true $ roslaunch b3b33rob_ros start_rv6s.launch camera:=true $ roslaunch b3b33rob_ros start_fake_rv6sdl.launch camera:=true $ roslaunch b3b33rob_ros start_fake_rv6sdl.launch camera:=true
Display camera stream:
$ rosrun image_view image_view image:=/camera/image_color
From Python the library used for the communication with the camera is PyCapture2. There is an example of the camera usage in python:
import PyCapture2 import cv2 import numpy as np # Initialize bus and camera bus = PyCapture2.BusManager() camera = PyCapture2.Camera() # Select first camera on the bus camera.connect(bus.getCameraFromIndex(0)) # Start capture camera.startCapture() while True: # Retrieve image from camara in PyCapture2.Image format image = camera.retrieveBuffer() # Convert from MONO8 to RGB8 image = image.convert(PyCapture2.PIXEL_FORMAT.RGB8) # Convert image to Numpy array rgb_cv_image = np.array(image.getData(), dtype="uint8").reshape((image.getRows(), image.getCols(), 3)); # Convert RGB image to BGR image to be shown by OpenCV bgr_cv_image = cv2.cvtColor(rgb_cv_image, cv2.COLOR_RGB2BGR) # Show image cv2.imshow('frame',bgr_cv_image) # Wait for key press, stop if the key is q if cv2.waitKey(1) & 0xFF == ord('q'): break
More documentation about the PyCapture2 can be found with this command:
evince /opt/salt-install/PyCapture2-2.13.31/docs/PyCapture2doc.pdf
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:
<code shell> $ flycap2 <code>