8.3.0.2.0. Video Mode Constants
|
(packages/video4linux/v4l.lsh) |
VIDEO_MODE_PAL 0
VIDEO_MODE_NTSC 1
VIDEO_MODE_SECAM 2
VIDEO_MODE_AUTO 3
8.3.0.2.1. Video Palette Constants
|
(packages/video4linux/v4l.lsh) |
VIDEO_PALETTE_GREY 1
VIDEO_PALETTE_HI240 2
VIDEO_PALETTE_RGB565 3
VIDEO_PALETTE_RGB24 4
VIDEO_PALETTE_RGB32 5
VIDEO_PALETTE_RGB555 6
VIDEO_PALETTE_YUV422 7
VIDEO_PALETTE_YUYV 8
VIDEO_PALETTE_UYVY 9
VIDEO_PALETTE_YUV420 10
VIDEO_PALETTE_YUV411 11
VIDEO_PALETTE_RAW 12
VIDEO_PALETTE_YUV422P 13
VIDEO_PALETTE_YUV411P 14
VIDEO_PALETTE_YUV420P 15
VIDEO_PALETTE_YUV410P 16
VIDEO_PALETTE_PLANAR 13
VIDEO_PALETTE_COMPONENT 7
8.3.0.2.2. v4ldevice
|
(packages/video4linux/v4l.lsh) |
the v4l device is the main class through which video frames can be
grabbed using the Video4Linux device. This requires a v4l compatible
video grabbing card or webcam.
Here is an example of code that repeatedly grabs an image from the
composite video input and displays it on the screen:
(de v4l-demo (swidth sheight)
(let* ((bg (ubyte-matrix sheight swidth 3)) ; make image buffer
;; open video device NTSC standard, composite input (channel 1).
(vdev (new v4ldevice "/dev/video0" "NTSC" 1 swidth sheight)))
;; open window
(setq screen (new-window))
(while t
;; grab frame
(==> vdev grab-into-rgbx bg)
;; display frame
(rgb-draw-matrix 10 10 bg))))
8.3.0.2.2.0. (==> v4ldevice cleanup)
|
[MSG] (packages/video4linux/v4l.lsh) |
deallocate all malloced slots and close device. This is a private method
called by the destructor and various error handlers, but rarely called
directly.
8.3.0.2.2.1. (==> v4ldevice set-format f w h)
|
[MSG] (packages/video4linux/v4l.lsh) |
set the video format/palette (@@VIDEO_PALETTE_RGB24,
@@VIDEO_PALETTE_RGB32, @@VIDEO_PALETTE_YUV422 etc...), and the width and
the height of the image to be grabbed (see "Video Palette
Constants" for a list of formats). Returns 0 on success and -1 if
the format requested is not supported by the device. This method rarely
called directly, unless the low-level grab
method is to be used. The various grab-into-rgb
and grab-into-rgba methods determine
the appropriate format automatically, and all the
grab-xxx-into-xxx methods set the desired format before
grabbing, therefore a prior call to set-format
is unnecessary if these high-level methods are used.
8.3.0.2.2.2. (new v4ldevice devname n c w h)
|
[CLASS] (packages/video4linux/v4l.lsh) |
opens a new v4ldevice for video grabbing. Arguments are: device name
(e.g. "/dev/video0"), norm, channel, width, and height. norm can be
"NTSC", "PAL", "SECAM", "AUTO". The "channel" c
determines which video source the card will listen to. On most bttv
cards, 0 means TV tuner, 1 means composite video input, and 2 means
S-video input (if present). Tuning to a particular broadcast or cable
channel is done with the "tune" method.
example: open device to grab 320x240 NTSC video from S-video on
BTTV/avermedia card (channel 2):
(setq a (new v4ldevice "/dev/video0" "NTSC" 2 320 240))
8.3.0.2.2.3. (==> v4ldevice tune freq)
|
[MSG] (packages/video4linux/v4l.lsh) |
tune the tuner to frequency n ,
expressed in 1/16th of a MHz. Tables that map channels to frequencies
are available in file freq-table.lsh .
Tuning to a channel can only be done is the device was opened to listen
to the TV tuner (as opposed to the composite video or S-video).
8.3.0.2.2.4. (==> v4ldevice grab-into-rgb img)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device into a preexisting image (a
ubyte-matrix of size heightxwidthxdepth, where depth must be at least
3). Consecutive elements in the last dimension are interpreted as RGB
values. Only those elements are modified. If the video image format has
not been previously set, this method automatically determines which
format is supported by the current device (among RGB24, RGB32 and
YUV420P). This allows to support videocards and webcams transparently
without having to worry about which formats are supported. Some webcams
(like the Logitech Quickcam 3000 pro) only support YUV420 and YUV420P.
8.3.0.2.2.5. (==> v4ldevice grab-into-rgbx img)
|
[MSG] (packages/video4linux/v4l.lsh) |
same as grab-into-rgb .
8.3.0.2.2.6. (==> v4ldevice grab-into-rgba img alpha)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device into a preexisting image (a
ubyte-matrix of size heightxwidthxdepth, where depth must be at least
3). Consecutive elements in the last dimension are interpreted as RGBA
values. Only those 4 elements are modified. The A components are filled
with alpha . If the video image format
has not been previously set, this method automatically determines which
format is supported by the current device (among RGB24, RGB32 and
YUV420P). This allows to support videocards and webcams transparently
without having to worry about which formats are supported. Some webcams
(like the Logitech Quickcam 3000 pro) only support YUV420 and YUV420P.
8.3.0.2.2.7. (==> v4ldevice grab-rgb24-into-rgbx img)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device in RGB24 format into a preexisting
image (a ubyte-matrix of size heightxwidthxdepth, where depth must be at
least 3). Consecutive elements in the last dimension are interpreted as
RGB values. Only those elements are modified.
8.3.0.2.2.8. (==> v4ldevice grab-rgb32-into-rgbx img)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device in RGB32 format into a preexisting
image (a ubyte-matrix of size heightxwidthxdepth, where depth must be at
least 3). Consecutive elements in the last dimension are interpreted as
RGB values. Only those elements are modified.
8.3.0.2.2.9. (==> v4ldevice grab-rgb24-into-rgba img alpha)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device in RGB32 format into a preexisting
image (a ubyte-matrix of size heightxwidthxdepth with depth equal to at
least 4), Consecutive elements in the last dimension are interpreted as
RGBA values. The A values are filled with alpha
.
8.3.0.2.2.10. (==> v4ldevice grab-rgb32-into-rgba img alpha)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device in RGB32 format into a preexisting
image (a ubyte-matrix of size heightxwidthxdepth with depth equal to at
least 4), Consecutive elements in the last dimension are interpreted as
RGBA values. The A values are filled with alpha
.
8.3.0.2.2.11. (==> v4ldevice grab-yuv422-into-yuv422 img)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device in YUV422 format into a preexisting
image (a ubyte-matrix of size heightxwidthx2. Consecutive elements are
interpreted as YUYVYUYV..... according to the YUV422 definition. so
(img y x 0) is the luminance component of pixel (x, y).
8.3.0.2.2.12. (==> v4ldevice grab-yuv420p-into-rgbx img)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device in YUV420P (planar) format into a
preexisting image (a ubyte-matrix of size heightxwidthxdepth with depth
at least equal to 3). Consecutive elements are interpreted as RGB
components. This mode is useful for certain webcam that do not support
RGB grabbing (e.g. Logitech Quickam 3000 Pro).
8.3.0.2.2.13. (==> v4ldevice grab-yuv420p-into-yuv img)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device in YUV420P (planar) format into a
preexisting image (a ubyte-matrix of size heightxwidthxdepth with depth
at least equal to 3). Consecutive elements are interpreted as YUV
components. This mode is useful for certain webcam that support YUV
grabbing (e.g. Logitech Quickam 3000 Pro).
8.3.0.2.2.14. (==> v4ldevice grab-yuv420p-into-rgba img alpha)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device in YUV420P (planar) format into a
preexisting image (a ubyte-matrix of size heightxwidthxdepth with depth
at least equal to 4). Consecutive elements are interpreted as RGBA
components. the A components are filled with
alpha . This mode is useful for certain webcam that do not
support RGB grabbing (e.g. Logitech Quickam 3000 Pro).
8.3.0.2.2.15. (==> v4ldevice grab-grey-into-y img)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device in GREY (monocrhome) format into a
preexisting image (a ubyte-matrix of size heightxwidth.
8.3.0.2.2.16. (==> v4ldevice record-into-rgb movie s)
|
[MSG] (packages/video4linux/v4l.lsh) |
record successive frames from the v4l device into a preexisting movie (a
4-dimensional ubyte-matrix of size nframesxheightxwidthx3). Consecutive
elements in the last dimension are interpreted as RGBA values.
Consecutive slices in the first dimension are individual frames. The
s parameter controls the temporal subsampling: every
s video frame is saved in movie
.
8.3.0.2.2.17. (==> v4ldevice monitor x y z n w h)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab video frames and display them in the current Lush window at
position x , y
, with zoom factor z . The number of
frames grabbed is n , and their
widht/height is w /
h . return the last grabbed frame.
8.3.0.2.2.18. (==> v4ldevice grab-rgb24-acc-rgbx img)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device in RGB24 format and accumulate the
result into a preexisting image (an int-matrix of size
height x width x
depth where height and
width are the dimensions of the
v4ldevice ) and depth must
be at least 3. Consecutive elements in the last dimension are
interpreted as RGB values.
8.3.0.2.2.19. (==> v4ldevice grab-rgb24-acc-rgba img alpha)
|
[MSG] (packages/video4linux/v4l.lsh) |
grab an image from the v4l device and accumulate the result into a
preexisting image (an int-matrix of size height
x width x depth
where height and
width are the dimensions of the
v4ldevice , and with depth equal to at least 4). Consecutive
elements in the last dimension are interpreted as RGBA values. The alpha
channel is filled with value alpha .
8.3.0.2.2.20. (==> v4ldevice grab)
|
[MSG] (packages/video4linux/v4l.lsh) |
low-level grab of an image from the v4l device. This is a low-level
function that simply performs a frame grab in the video format and image
size (as set with set-format) with no format conversion. Most users will
prefer to use the other grab methods which perform appropriate
conversions and write their result into an idx. The present function
simply provides a pointer to the frame buffer. The grabbed data can be
accessed through the framebuffer slot
of the v4ldevice (a gptr). The number
of bytes in the grab frame is given by the product of the
width , height , and
depth slots. The format depends on what parameter was passed
to set-format prior to calling
grab . Please note that the RGB24 and RGB32 formats of
video4linux are really BGR formats from Lush's point of view.
(libload "video4linux/v4l")
(libload "libc/libc")
(new-window)
;; these parameters are for Quickcam 3000 pro webcam
(setq v (new v4ldevice "/dev/video" "AUTO" 0 320 240))
(setq m (ubyte-matrix 240 320))
;; set format to YUV420P (planar).
(==> v set-format @@VIDEO_PALETTE_YUV420P 320 240)
(==> v grab)
;; copy the Y component into the matrix m
(memcpy (idx-ptr m) :v:framebuffer (* 240 320))
(rgb-draw-matrix 0 0 m)