178 |
kaklik |
1 |
#ifndef IMAGE_V4LINPUT_H |
|
|
2 |
#define IMAGE_V4LINPUT_H |
|
|
3 |
|
|
|
4 |
#include "image_input.h" |
|
|
5 |
#include <linux/videodev.h> |
|
|
6 |
#include "rgba.h" |
|
|
7 |
|
|
|
8 |
namespace mimas { |
|
|
9 |
|
|
|
10 |
/** @addtogroup imageIO |
|
|
11 |
@{ */ |
|
|
12 |
/** @addtogroup imageInput |
|
|
13 |
@{ */ |
|
|
14 |
/** Class for reading images from a video4linux device. |
|
|
15 |
The class has been successfully tested for colour-images (i.e. |
|
|
16 |
T = rgba< unsigned char >) and the following devices: |
|
|
17 |
\li Logitech QuickCam Pro 4000 |
|
|
18 |
\li BT848A video (Imagenation PXC20) |
|
|
19 |
\li BT878 (Unknown generic) |
|
|
20 |
|
|
|
21 |
See <A HREF="file:///usr/src/linux/Documentation/video4linux/API.html">V4L-API</A> |
|
|
22 |
for more information about video4linux. |
|
|
23 |
|
|
|
24 |
Here is a minimal example program on how to grab and display images |
|
|
25 |
with this class: |
|
|
26 |
\include webcam/minimal.cc |
|
|
27 |
|
|
|
28 |
@author Bala Amavasai (bala@amavasai.org) |
|
|
29 |
@author Jan Wedekind (jan@wedesoft.de) |
|
|
30 |
@date Wed Mar 2 14:58:34 GMT 2005 */ |
|
|
31 |
template< typename T > |
|
|
32 |
class image_v4linput: public image_input< T > |
|
|
33 |
{ |
|
|
34 |
public: |
|
|
35 |
image_v4linput( const std::string &_device, |
|
|
36 |
int channel = 0, |
|
|
37 |
int width = -1, int height = -1, |
|
|
38 |
int channel_norm = VIDEO_MODE_PAL ) throw (mimasexception); |
|
|
39 |
~image_v4linput(void); |
|
|
40 |
virtual void read( image<T> &img ) throw (mimasexception); |
|
|
41 |
int getWidth(void) const { return win.width; } |
|
|
42 |
int getHeight(void) const { return win.height; } |
|
|
43 |
void setSensivity( __u16 brightness, |
|
|
44 |
__u16 hue, |
|
|
45 |
__u16 colour, |
|
|
46 |
__u16 contrast ) throw (mimasexception); |
|
|
47 |
protected: |
|
|
48 |
int xioctl( int request, void *arg ); |
|
|
49 |
void selectPalette(void) throw (mimasexception); |
|
|
50 |
std::string device; |
|
|
51 |
int fd; |
|
|
52 |
void *map; |
|
|
53 |
struct video_channel chan; |
|
|
54 |
struct video_picture pic; |
|
|
55 |
struct video_window win; |
|
|
56 |
struct video_mbuf buf; |
|
|
57 |
}; |
|
|
58 |
|
|
|
59 |
///@} |
|
|
60 |
|
|
|
61 |
///@} |
|
|
62 |
|
|
|
63 |
}; |
|
|
64 |
|
|
|
65 |
#include "image_v4linput.tcc" |
|
|
66 |
|
|
|
67 |
#endif |
|
|
68 |
|