Warning
This page is located in archive.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
help:common:kamera_matlab_chameleon_en [2014/02/19 13:32]
zimmerk [Camera control]
help:common:kamera_matlab_chameleon_en [2022/10/25 12:27] (current)
wagnelib [Camera Control (Python)]
Line 2: Line 2:
 Camera Chameleon is digital USB 2.0 camera //​[[http://​www.ptgrey.com/​products/​chameleon/​Chameleon_datasheet.pdf|Chameleon]]//​ manufactued by [[http://​www.ptgrey.com|PointGrey]]. Camera Chameleon is digital USB 2.0 camera //​[[http://​www.ptgrey.com/​products/​chameleon/​Chameleon_datasheet.pdf|Chameleon]]//​ manufactued by [[http://​www.ptgrey.com|PointGrey]].
  
-==== Camera control ====+==== Camera control ​(Matlab on Windows) ​====
 The camera can be operated in MATLAB via [[http://​www.mathworks.com/​access/​helpdesk/​help/​toolbox/​imaq/​f9-75080.html|Image Acquisition Toolboxu]]. The camera can be operated in MATLAB via [[http://​www.mathworks.com/​access/​helpdesk/​help/​toolbox/​imaq/​f9-75080.html|Image Acquisition Toolboxu]].
  
Line 10: Line 10:
 vid.FrameGrabInterval = 1; vid.FrameGrabInterval = 1;
 start(vid);</​code>​ start(vid);</​code>​
-  - Reading a frame from the buffer ​is as follows ​<​code>​im = getdata(vid,​1);</​code>​+  - The following command reads one frame from the current ​buffer <​code>​im = getdata(vid,​1);</​code>​
   - The camera provides video in RAW format, therefore [[http://​en.wikipedia.org/​wiki/​Bayer_filter|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 <​code>​im_debay(:,:,​1) = im(2:​2:​end,​1:​2:​end);​   - The camera provides video in RAW format, therefore [[http://​en.wikipedia.org/​wiki/​Bayer_filter|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 <​code>​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(:,:,​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);</​code> ​ im_debay(:,:,​3) = 6.5 * im(1:​2:​end,​2:​2:​end);</​code> ​
-  - Evetually, you can clear the memory by the following commands <​code>​stop(vid);​+  - Eventually, you can clear the memory by the following commands <​code>​stop(vid);​
 delete(vid);</​code>​ delete(vid);</​code>​
  
 +
 +==== Camera control (Matlab on Linux) ====
 +
 +   * In linux version of matlab the driver for the camera doe's not work properly, therefore we have added simple function to grab an image (**flygrab**).
 +   * First add path to the flygrab directory:
 +<code matlab>
 +addpath('/​opt/​flygrab'​);​
 +</​code>​
 +
 +   * Then grab an image:
 +<code matlab>
 +img = flygrab();
 +</​code>​
 +
 +   * In order to configuration the camera use the **FlyCap2** utility.
 +
 +==== Camera control (ROS) ====
 +
 +Driver documentation:​ [[http://​wiki.ros.org/​pointgrey_camera_driver|pointgray_camera_driver]] ​
 +
 +Start camera driver nodes:
 +<code bash>
 +# 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
 +</​code>​
 +
 +Display camera stream:
 +<code bash>
 +$ rosrun image_view image_view image:​=/​camera/​image_color
 +</​code>​
 +
 +   * In order to configuration the camera use the **FlyCap2** utility.
 +
 +
 +==== Camera Control (Python) ====
 +
 +From Python the library used for the communication with the camera is PyCapture2. There is an example of the camera usage in python:
 +
 +<code 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
 +</​code>​
 +
 +More documentation about the PyCapture2 can be found with this command: ​
 +<​code>​
 +evince /​opt/​salt-install/​PyCapture2-2.13.31/​docs/​PyCapture2doc.pdf
 +</​code>​
 ==== Parameter Settings ==== ==== 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 set the capturing parameters.+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: Unfortunately MATLAB interface allows to adjust only a limited number of parameters. The following parameters can be set:
Line 46: Line 133:
   * Picture degradation (spillage) when using different image resolution.   * Picture degradation (spillage) when using different image resolution.
  
 +==== Parameter Settings (flycap2) ====
 +
 +   * In terminal run:
 +<code shell>
 +$ flycap2
 +<​code>​
help/common/kamera_matlab_chameleon_en.1392813125.txt.gz · Last modified: 2018/02/03 10:48 (external edit)