8.3.0.1.0. v4l2device
|
(packages/video4linux/v4l2.lsh) |
the v4l2 device is the main class through which video frames can be
grabbed using the Video4Linux v2 API. This requires a v4l2 compatible
video grabbing card or webcam.
Although the v4l2 API supports a variety of video formats for grabbing,
this interface only grabs images in the YUV422 format (also known as
YUYV). The image can be converted to RGB is required using the
convert-yuv422-to-rgb found in
libimage/img-util
Here is an example of code that repeatedly grabs an image from the
composite video input and displays it on the screen:
(de v4l2-test (d width height fps)
(libload "libimage/img-util")
(let ((z (new v4l2device d width height fps 4))
(frame-rgb (ubyte-matrix height width 3)))
(when (not window) (new-window 0 0 (+ width 20) (+ height 20) "v4l2"))
(cls)
(repeat 1000
(==> z get-frame-rgb frame-rgb)
(rgb-draw-matrix 10 10 frame-rgb)) ))
(v4l2-test "/dev/video0" 640 480 30)
8.3.0.1.0.0. (new v4l2device devname w h fps nb)
|
[CLASS] (packages/video4linux/v4l2.lsh) |
Open video device (webcam etc) devname
(e.g. "/dev/video0" ) preparing to
grab images of resoltion w by
h . fps is the number of
frames per seconds that the v4l2 subsystem will grab. The period between
two frames obtained from the device may be longer the
1/fps if Lush spends too much time between calls to one of
the get-frame-XXX methods.
nb is the number of v4l2 buffers requested. Typical numbers
are 2 or 4.
8.3.0.1.0.1. (==> v4l2device set-input n)
|
[MSG] (packages/video4linux/v4l2.lsh) |
Set active input to n . return 0 on
success, -1 on failure.
8.3.0.1.0.2. (==> v4l2device set-exposure n)
|
[MSG] (packages/video4linux/v4l2.lsh) |
Set exposure to n . a Negative number
sets to auto exposure, while a positive number sets to absolute
exposure. return 0 on success, -1 on failure.
8.3.0.1.0.3. (==> v4l2device set-gain n)
|
[MSG] (packages/video4linux/v4l2.lsh) |
Set exposure to n . a Negative number
sets to auto gain, while a positive number sets to absolute gain. return
0 on success, -1 on failure.
8.3.0.1.0.4. (==> v4l2device set-brightness n)
|
[MSG] (packages/video4linux/v4l2.lsh) |
Set brightness to n . return 0 on
success, -1 on failure.
8.3.0.1.0.5. (==> v4l2device set-contrast n)
|
[MSG] (packages/video4linux/v4l2.lsh) |
Set brightness to n . return 0 on
success, -1 on failure.
8.3.0.1.0.6. (==> v4l2device get-frame-rgb frame)
|
[MSG] (packages/video4linux/v4l2.lsh) |
Get the next available frame from the v4l2 device and place it in
frame in RGB format. frame
must be an idx3 of ubytes of size height
by width by bpp
, where bpp must be at least 3. The
underlying frame is actually grabbed in YUYV and converted to RGB.
8.3.0.1.0.7. (==> v4l2device get-frame-grey frame)
|
[MSG] (packages/video4linux/v4l2.lsh) |
Get the next available frame from the v4l2 device and place it in
frame in greyscale format. frame
must be an idx2 of ubytes of size height
by width .
8.3.0.1.0.8. (==> v4l2device get-frame-yuv frame)
|
[MSG] (packages/video4linux/v4l2.lsh) |
Get the next available frame from the v4l2 device and place it in
frame in YUV format. Unlike with YUV422, the U and V
components are not subsampled. frame
must be an idx3 of ubytes of size height
by width by bpp
, where bpp must be at least 3. The
underlying frame is actually grabbed in YUYV (aka YUV422) and converted
to YUV.
8.3.0.1.0.9. (==> v4l2device get-frame-yuv422 frame)
|
[MSG] (packages/video4linux/v4l2.lsh) |
Get the next available frame from the v4l2 device and place it in
frame in yuv422 format (also known as YUYV).
frame must be an idx3 of ubytes of size
height by width by
2 . This is the most efficient of the
get-frame-XXX functions as YUYV is the native format of many
devices.
8.3.0.1.0.10. (==> v4l2device start)
|
[MSG] (packages/video4linux/v4l2.lsh) |
Tells the v4l2 device to start grabbing frames. There is no need to call
this method explicitely as it is called automatically when the first
call to one of the get-frame-XXX" methods is
performed.
8.3.0.1.0.11. (==> v4l2device start)
|
[MSG] (packages/video4linux/v4l2.lsh) |
Tells the v4l2 device to start grabbing frames. There is no need to call
this method explicitely as it is called automatically when the first
call to one of the get-frame-XXX" methods is
performed.
8.3.0.1.0.12. (==> v4l2device cleanup)
|
[MSG] (packages/video4linux/v4l2.lsh) |
private method to cleanup allocated objects in a v4l2 device.
8.3.0.1.0.13. v4l2 utilities
|
(packages/video4linux/v4l2.lsh) |
8.3.0.1.0.13.0. (find-video-devices)
|
(packages/video4linux/v4l2.lsh) |
return a list of all available video devices, i.e. files of the form
/dev/videoXX .
8.3.0.1.0.14. v4l2 demos
|
(packages/video4linux/v4l2.lsh) |
8.3.0.1.0.14.0. (v4l2-demo [device] [width] [height] [input] [nbuf] [fps] [mode])
|
(packages/video4linux/v4l2.lsh) |
Testing/demo function for v4l2device :
grabs 1000 video frames and simultaneously displays them in a Lush
graphic window. All arguments are optional:
device : video device (default:
"/dev/video0" ). width ,
height : dimensions of the images to be grabbed (default: 320
by 240). input : input number from
which frames will be grabbed (generally 0, 1, or 2). Default is -1,
which leaves the input unchanged from the last time the device was used.
nbuf : number of frame buffers (default: 2).
mode : 0 for RGB, 1 for grayscale, 2 for YUYV with "manual"
conversion to RGB before display (default: 0).
fps : frame rate at which v4l2 will grab frames. The actual
frame rate is displayed on the screen. It may be lower than the one
requested in fps (generally half).
Example:
(v4l2-demo "/dev/video0" 960 720 0 2 30 0)