24 #include <fvcams/v4l.h>
25 #include <sys/ioctl.h>
32 # include <fvcams/v4l1.h>
33 # include <linux/videodev.h>
37 # include <fvcams/v4l2.h>
38 # include <linux/videodev2.h>
41 #include <core/exception.h>
42 #include <core/exceptions/software.h>
43 #include <fvutils/system/camargp.h>
45 namespace firevision {
60 _device_name = strdup(device_name);
72 if (cap->
has(
"device"))
73 _device_name = strdup(cap->
get(
"device").c_str());
92 int dev =
::open(_device_name, O_RDWR);
97 struct video_capability caps1;
100 struct v4l2_capability caps2;
104 if (ioctl(dev, VIDIOC_QUERYCAP, &caps2)) {
107 if (ioctl(dev, VIDIOCGCAP, &caps1)) {
170 return (_v4l_cam ? _v4l_cam->
ready() :
false);
176 return (_v4l_cam ? _v4l_cam->
buffer() : NULL);
213 return (_v4l_cam ? _v4l_cam->
colorspace() : CS_UNKNOWN);
Base class for exceptions in Fawkes.
Expected parameter is missing.
bool has(std::string s) const
Check if an parameter was given.
std::string get(std::string s) const
Get the value of the given parameter.
virtual void stop()=0
Stop image transfer from the camera.
virtual void set_image_number(unsigned int n)=0
Set image number to retrieve.
virtual void close()=0
Close camera.
virtual unsigned int pixel_height()=0
Height of image in pixels.
virtual unsigned int buffer_size()=0
Size of buffer.
virtual void flush()=0
Flush image queue.
virtual void dispose_buffer()=0
Dispose current buffer.
virtual void print_info()=0
Print out camera information.
virtual unsigned int pixel_width()=0
Width of image in pixels.
virtual void capture()=0
Capture an image.
virtual colorspace_t colorspace()=0
Colorspace of returned image.
virtual unsigned char * buffer()=0
Get access to current image buffer.
virtual void start()=0
Start image transfer from the camera.
virtual bool ready()=0
Camera is ready for taking pictures.
Video4Linux 1 camera implementation.
Video4Linux 2 camera access implementation.
virtual unsigned int pixel_width()
Width of image in pixels.
virtual void set_image_number(unsigned int n)
Set image number to retrieve.
virtual void dispose_buffer()
Dispose current buffer.
virtual void flush()
Flush image queue.
virtual colorspace_t colorspace()
Colorspace of returned image.
virtual unsigned int buffer_size()
Size of buffer.
virtual void print_info()
Print out camera information.
virtual ~V4LCamera()
Destructor.
virtual void close()
Close camera.
virtual bool ready()
Camera is ready for taking pictures.
virtual unsigned char * buffer()
Get access to current image buffer.
virtual void start()
Start image transfer from the camera.
virtual unsigned int pixel_height()
Height of image in pixels.
V4LCamera(const char *device_name="/dev/video0")
Constructor.
virtual void open()
Open the camera.
virtual void capture()
Capture an image.
virtual void stop()
Stop image transfer from the camera.