24 #include <fvcams/v4l.h> 29 #include <sys/ioctl.h> 32 #include <linux/videodev.h> 33 #include <fvcams/v4l1.h> 37 #include <linux/videodev2.h> 38 #include <fvcams/v4l2.h> 41 #include <fvutils/system/camargp.h> 42 #include <core/exception.h> 43 #include <core/exceptions/software.h> 63 _device_name = strdup(device_name);
76 if (cap->
has(
"device")) _device_name = strdup(cap->
get(
"device").c_str());
84 if (_v4l_cam)
delete _v4l_cam;
90 if (_v4l_cam)
delete _v4l_cam;
92 int dev =
::open(_device_name, O_RDWR);
96 struct video_capability caps1;
99 struct v4l2_capability caps2;
103 if (ioctl(dev, VIDIOC_QUERYCAP, &caps2))
107 if (ioctl(dev, VIDIOCGCAP, &caps1))
144 if (_v4l_cam) _v4l_cam->
close();
150 if (_v4l_cam) _v4l_cam->
flush();
156 if (_v4l_cam) _v4l_cam->
capture();
168 return (_v4l_cam ? _v4l_cam->
ready() :
false);
174 return (_v4l_cam ? _v4l_cam->
buffer() : NULL);
192 if (!_v4l_cam)
throw fawkes::Exception(
"V4LCam::pixel_width(): Camera not opened");
200 if (!_v4l_cam)
throw fawkes::Exception(
"V4LCam::pixel_height(): Camera not opened");
208 return (_v4l_cam ? _v4l_cam->
colorspace() : CS_UNKNOWN);
virtual unsigned int buffer_size()=0
Size of buffer.
virtual void stop()=0
Stop image transfer from the camera.
virtual unsigned int pixel_width()=0
Width of image in pixels.
Video4Linux 2 camera access implementation.
virtual unsigned int buffer_size()
Size of buffer.
virtual unsigned int pixel_width()
Width of image in pixels.
virtual void open()
Open the camera.
virtual colorspace_t colorspace()=0
Colorspace of returned image.
virtual void dispose_buffer()
Dispose current buffer.
virtual void capture()
Capture an image.
virtual void print_info()=0
Print out camera information.
virtual bool ready()=0
Camera is ready for taking pictures.
virtual void stop()
Stop image transfer from the camera.
V4LCamera(const char *device_name="/dev/video0")
Constructor.
virtual colorspace_t colorspace()
Colorspace of returned image.
bool has(std::string s) const
Check if an parameter was given.
Base class for exceptions in Fawkes.
virtual void set_image_number(unsigned int n)
Set image number to retrieve.
virtual void capture()=0
Capture an image.
virtual void set_image_number(unsigned int n)=0
Set image number to retrieve.
virtual void flush()=0
Flush image queue.
virtual ~V4LCamera()
Destructor.
Video4Linux 1 camera implementation.
virtual void print_info()
Print out camera information.
virtual unsigned int pixel_height()
Height of image in pixels.
virtual void close()
Close camera.
virtual void close()=0
Close camera.
virtual unsigned char * buffer()=0
Get access to current image buffer.
virtual void start()
Start image transfer from the camera.
virtual unsigned int pixel_height()=0
Height of image in pixels.
virtual void start()=0
Start image transfer from the camera.
virtual unsigned char * buffer()
Get access to current image buffer.
std::string get(std::string s) const
Get the value of the given parameter.
Expected parameter is missing.
virtual bool ready()
Camera is ready for taking pictures.
virtual void flush()
Flush image queue.
virtual void dispose_buffer()=0
Dispose current buffer.