Editing Image acquisition package
Jump to navigation
Jump to search
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 7: | Line 7: | ||
If you want to report a bug: [[Image_acquisition_package#Reporting_bugs]] | If you want to report a bug: [[Image_acquisition_package#Reporting_bugs]] | ||
== Example session == | == Example session == | ||
Lines starting with | Lines starting with octave> are executed on the octave prompt. | ||
=== Load the package and list available hardware === | === Load the package and list available hardware === | ||
octave | octave> pkg load image-acquisition | ||
octave | octave> 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) | ||
Line 29: | Line 29: | ||
=== Open the v4l2 device and output the result === | === Open the v4l2 device and output the result === | ||
octave | octave> obj = videoinput("v4l2", "/dev/video0") | ||
obj = videoinput for v4l2 | obj = videoinput for v4l2 | ||
device | device = /dev/video0 | ||
driver | driver = uvcvideo | ||
card | card = UVC Camera (046d:0825) | ||
VideoInput | VideoInput = 0 | ||
VideoResolution | VideoResolution = 320 x 240 px | ||
VideoFrameInterval = 1/30 s (30.0 fps) | |||
=== Query which properties are available for the used device === | === Query which properties are available for the used device === | ||
The first 6 ones, starting with an upper letter are fixed, the other specific to the used v4l2 device. | |||
The first | octave> get(obj) | ||
octave | |||
ans = | ans = | ||
{ | { | ||
[1,1] = SelectedSourceName | [1,1] = SelectedSourceName | ||
[2,1] = | [2,1] = DeviceCapabilities | ||
[3,1] = | [3,1] = VideoInput | ||
[4,1] = | [4,1] = VideoResolution | ||
[5,1] = | [5,1] = VideoFrameInterval | ||
[6,1] = | [6,1] = VideoFormat | ||
[7,1] = | [7,1] = brightness | ||
[8,1] = | [8,1] = contrast | ||
[9,1] = | [9,1] = saturation | ||
[10,1] = | [10,1] = white_balance_temperature_auto | ||
[11,1] = | [11,1] = gain | ||
[12,1] = | [12,1] = power_line_frequency | ||
[13,1] = | [13,1] = white_balance_temperature | ||
[14,1] = | [14,1] = sharpness | ||
[15,1] = | [15,1] = backlight_compensation | ||
[16,1] = | [16,1] = exposure_auto | ||
[17,1] = | [17,1] = exposure_absolute | ||
[18 | [18,1] = exposure_auto_priority | ||
} | } | ||
=== | === Get device capabilities === | ||
octave> get(obj, "DeviceCapabilities") | |||
octave | ans = | ||
scalar structure containing the fields: | |||
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 === | === List available video resolutions === | ||
octave> set(obj, "VideoResolution") | |||
octave | |||
ans = | ans = | ||
Line 97: | Line 101: | ||
=== Set the video resolution to 320x240px === | === Set the video resolution to 320x240px === | ||
octave | octave> set(obj, "VideoResolution", [320 240]) | ||
=== Get the current brightness value === | === Get the current brightness value === | ||
octave> get(obj, "brightness") | |||
octave | |||
ans = 100 | ans = 100 | ||
=== Query possible range for brightness === | === Query possible range for brightness === | ||
octave> set(obj, "brightness") | |||
octave | |||
ans = | ans = | ||
Line 117: | Line 119: | ||
=== Set a new value for brightness === | === Set a new value for brightness === | ||
octave> set(obj, "brightness", 100) | |||
octave | |||
=== Start preview === | === Start preview === | ||
octave> preview(obj) | |||
octave | |||
Close it with CTRL+C or with [X] on the preview window | Close it with CTRL+C or with [X] on the preview window | ||
=== Use higher resolution and start streaming with 2 buffers === | === Use higher resolution and start streaming with 2 buffers === | ||
octave> set(obj, "VideoResolution", [640 480]); | |||
octave | octave> start(obj, 2) | ||
octave | |||
=== Get an image from the buffers, view and save it === | === Get an image from the buffers, view and save it === | ||
octave> img = getsnapshot(obj); | |||
octave | octave> image(img) | ||
octave | octave> imwrite(img, "ex1_a.png") | ||
octave | octave> [img, seq, t] = getsnapshot(obj); | ||
octave> seq | |||
octave | seq = 1 | ||
octave | octave> t | ||
t = | |||
octave | |||
scalar structure containing the fields: | scalar structure containing the fields: | ||
tv_sec = | tv_sec = 19618 | ||
tv_usec = | tv_usec = 346553 | ||
=== Stop streaming === | === Stop streaming === | ||
octave> stop(obj) | |||
octave | |||
== Using v4l2loopback for tests == | == Using v4l2loopback for tests == | ||
Line 176: | Line 171: | ||
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 | Exit octave and add libv4l2_debug.log to your bug report | ||
Consider running the included tests: | Consider running the included tests: | ||
Line 184: | Line 179: | ||
octave> test @videoinput/set | octave> test @videoinput/set | ||
octave> test @videoinput/getsnapshot | octave> test @videoinput/getsnapshot | ||
== Build source from mercurial repository == | == Build source from mercurial repository == | ||
Line 193: | Line 184: | ||
'''Warning: You really should use the <pkg install -forge> method described above if you are not sure what you are doing here.''' | '''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 | Get the source here [http://sourceforge.net/p/octave/image-acquisition/ci/default/tree/] and build it yourself. The build dependencies for Debian GNU/Linux wheezy 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 | $ hg clone http://hg.code.sf.net/p/octave/image-acquisition octave-image-acquisition | ||
$ cd octave-image-acquisition/ | $ cd octave-image-acquisition/src/ && ./bootstrap | ||
$ | $ cd ../.. | ||
$ tar czf image-acquisition.tar.gz octave-image-acquisition | |||
octave:>> pkg install -verbose image-acquisition.tar.gz | |||
== make check == | == make check == | ||
Line 205: | Line 198: | ||
$ cd octave-image-acquisition/devel | $ cd octave-image-acquisition/devel | ||
$ make check | $ make check | ||
octave -q run_tests.m | octave -q run_tests.m | ||
../src/__v4l2_handler__.cc........................ PASS 3/3 | ../src/__v4l2_handler__.cc........................ PASS 3/3 | ||
Line 213: | Line 206: | ||
@videoinput/getsnapshot........................... PASS 4/4 | @videoinput/getsnapshot........................... PASS 4/4 | ||
imaqhwinfo........................................ PASS 1/1 | imaqhwinfo........................................ PASS 1/1 | ||
Summary: | Summary: | ||
PASS 20 | PASS 20 | ||
FAIL 0 | 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. | If there are tests which FAIL, then please have a look at the generated fntest.log and add it to your bug report. | ||