Editing Image acquisition package

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
The {{Forge|image-acquisition}} package is part of the [[Octave Forge]] project.
The {{Forge|image_acquisition}} package is part of the [[Octave Forge]] project.


Build dependencies for Debian GNU/Linux are '''libv4l-dev''' and '''libfltk1.3-dev''' or '''libfltk1.1-dev'''. You can install it on GNU/Linux in octave with
There is not release package yet but if you can get the source here [http://sourceforge.net/p/octave/image-acquisition/ci/default/tree/]
  octave> pkg install -forge image-acquisition
 
If you see complains about a missing mkoctfile: [[FAQ#I_cannot_install_a_package._Octave_complains_about_a_missing_mkoctfile.]]
 
If you want to report a bug: [[Image_acquisition_package#Reporting_bugs]]
 
'''image-acquisition will not work on Windows as far as there is not port of v4l2 (standing for ''Video for Linux 2'')'''


== Example session ==
== Example session ==


Lines starting with "octave:>" are executed on the octave prompt.
Lines starting with $ are commands executed on the octave prompt.


=== Load the package and list available hardware ===
Let's load the package and list available hardware


  octave:> pkg load image-acquisition
<code>
  octave:> imaqhwinfo
  $ pkg load image-acquisition
  $ imaqhwinfo
  ans =
  ans =
   scalar structure containing the fields:
   scalar structure containing the fields:
     driver = uvcvideo
     driver = uvcvideo
     card = UVC Camera (046d:0825)
     card = UVC Camera (046d:0825)
     bus_info = usb-0000:00:12.2-4
     bus_info = usb-0000:00:16.2-2
     version = 3.16.7
     version = 3.2.51
     capabilities =   2.2314e+09
     capabilities = 83886081
     device = /dev/video0
     device = /dev/video0
 
</code>
=== Open the v4l2 device and output the result ===
$
 
$ obj = videoinput("v4l2", "/dev/video0")
octave:> obj = videoinput("v4l2", "/dev/video0")
obj = videoinput for v4l2
obj = videoinput for v4l2
       device             = /dev/video0
       device               = /dev/video0
       driver             = uvcvideo
       driver               = uvcvideo
       card               = UVC Camera (046d:0825)
       card                 = UVC Camera (046d:0825)
       VideoInput         = 0
       VideoInput           = 0
       VideoResolution   = 320 x 240 px
       VideoResolution     = 320 x 240 px
       VideoFrameInterval = 1/30 s (30.0 fps)
       VideoFormat          = YUYV
$ get(obj)
 
ans =  
=== Query which properties are available for the used device ===
{
 
The first 8 ones, starting with an upper letter are fixed, the other specific to the used v4l2 device.
octave:> get(obj)
ans =  
{
   [1,1] = SelectedSourceName
   [1,1] = SelectedSourceName
   [2,1] = ReturnedColorSpace
   [2,1] = DeviceCapabilities
   [3,1] = BayerSensorAlignment
   [3,1] = VideoInput
   [4,1] = DeviceCapabilities
   [4,1] = VideoResolution
   [5,1] = VideoInput
   [5,1] = VideoFrameInterval
   [6,1] = VideoResolution
   [6,1] = VideoFormat
   [7,1] = VideoFrameInterval
   [7,1] = brightness
   [8,1] = VideoFormat
   [8,1] = contrast
   [9,1] = brightness
   [9,1] = saturation
   [10,1] = contrast
   [10,1] = white_balance_temperature_auto
   [11,1] = saturation
   [11,1] = gain
   [12,1] = white_balance_temperature_auto
   [12,1] = power_line_frequency
   [13,1] = gain
   [13,1] = white_balance_temperature
   [14,1] = power_line_frequency
   [14,1] = sharpness
   [15,1] = white_balance_temperature
   [15,1] = backlight_compensation
   [16,1] = sharpness
   [16,1] = exposure_auto
   [17,1] = backlight_compensation
   [17,1] = exposure_absolute
   [18,1] = exposure_auto
   [18,1] = exposure_auto_priority
  [19,1] = exposure_absolute
}
  [20,1] = exposure_auto_priority
$
}
$ get(obj, "DeviceCapabilities")
ans =


=== Set VideoFormat to RGB3 aka RGB24 ===
  scalar structure containing the fields:


octave:> set(obj, "VideoFormat", "RGB3");
    driver = uvcvideo
    card = UVC Camera (046d:0825)
    bus_info = usb-0000:00:16.2-2
    version = 3.2.51
    capabilities =  83886081


=== List available video resolutions ===
$
$ set(obj, "VideoResolution")
ans =


octave:> set(obj, "VideoResolution")
ans =
     640    480
     640    480
     160    120
     160    120
Line 95: Line 90:
   1280    960
   1280    960


=== Set the video resolution to 320x240px ===
$ set(obj, "VideoResolution", [320 240])
$
$ get(obj, "brightness")
ans = 100
$ set(obj, "brightness")
ans =


octave:> set(obj, "VideoResolution", [320 240])
  scalar structure containing the fields:
 
=== Get the current brightness value ===
 
octave:> get(obj, "brightness")
ans =  100
 
=== Query possible range for brightness ===


octave:> set(obj, "brightness")
ans =
  scalar structure containing the fields:
     min = 0
     min = 0
     max =  255
     max =  255
Line 116: Line 104:
     default =  128
     default =  128


=== Set a new value for brightness ===
$ set(obj, "brightness", 100)
 
$
octave:> set(obj, "brightness", 100)
$ preview(obj)
 
=== Start preview ===
 
octave:> preview(obj)
 
Close it with CTRL+C or with [X] on the preview window
 
=== Use higher resolution and start streaming with 2 buffers ===
 
octave:> set(obj, "VideoResolution", [640 480]);
octave:> start(obj, 2)
 
=== Get an image from the buffers, view and save it ===
 
octave:> img = getsnapshot(obj);
octave:> image(img)
octave:> imwrite(img, "ex1_a.png")
octave:> [img, seq, t] = getsnapshot(obj);
octave:> seq
seq =  1
octave:> t
t =
  scalar structure containing the fields:
    tv_sec =  10281
    tv_usec =  779303
 
=== Stop streaming ===
 
octave:> stop(obj)


== Using v4l2loopback for tests ==
== Using v4l2loopback for tests ==
If you don't have a v4l2 device but want to test the package you could create a loopback device:
If you don't have a v4l2 device but test the package you could create a loopback device:
  modprobe v4l2loopback
  modprobe v4l2loopback
  gst-launch-0.10 videotestsrc ! v4l2sink device=/dev/video0
  gst-launch-0.10 videotestsrc ! v4l2sink device=/dev/video0
Line 176: Line 132:
There might be some warnings like "warning: function xyz shadows a built-in function" at start.
There might be some warnings like "warning: function xyz shadows a built-in function" at start.


Exit octave and add libv4l2_debug.log to your bug report. The logfile libv4l2_debug.log is overwritten between open/close so you have to rename it if you run different scripts.
Exit octave and add libv4l2_debug.log to your bug report


Consider running the included tests:
Consider running the included tests:


  octave> test @videoinput/videoinput
  test @videoinput/videoinput
  octave> test @videoinput/get
  test @videoinput/get
  octave> test @videoinput/set
  test @videoinput/set
  octave> test @videoinput/getsnapshot
  test @videoinput/getsnapshot
 
Run the compliance check (perhaps also with -s)
 
v4l2-compliance -d /dev/video0
 
== Build source from mercurial repository ==
 
'''Warning: You really should use the <pkg install -forge> method described above if you are not sure what you are doing here.'''
 
Get the source and build it yourself. The build dependencies for Debian GNU/Linux jessie are '''libv4l-dev''' and '''libfltk1.3-dev''' or '''libfltk1.1-dev'''. You also need the GNU autotools to generate the configure script.
 
$ hg clone http://hg.code.sf.net/p/octave/image-acquisition octave-image-acquisition
$ cd octave-image-acquisition/
$ make install
 
== make check ==
 
If you have cloned the hg repo you can also run the test scripts to see if all works.
 
$ cd octave-image-acquisition/devel
$ make check
octave -q run_tests.m
../src/__v4l2_handler__.cc........................ PASS 3/3
@videoinput/videoinput............................ PASS 1/1
@videoinput/get................................... PASS 4/4
@videoinput/set................................... PASS 7/7
@videoinput/getsnapshot........................... PASS 4/4
imaqhwinfo........................................ PASS 1/1
Summary:
  PASS  20
  FAIL  0
 
If there are tests which FAIL, then please have a look at the generated fntest.log and add it to your bug report.
 
[[Category:Octave Forge]]
Please note that all contributions to Octave may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Octave:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: