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>
45 namespace firevision {
60 V4LCamera::V4LCamera(
const char *device_name)
63 _device_name = strdup(device_name);
76 if (cap->
has(
"device")) _device_name = strdup(cap->
get(
"device").c_str());
81 V4LCamera::~V4LCamera()
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();
160 V4LCamera::print_info()
162 if (_v4l_cam) _v4l_cam->print_info();
168 return (_v4l_cam ? _v4l_cam->ready() :
false);
174 return (_v4l_cam ? _v4l_cam->buffer() : NULL);
178 V4LCamera::buffer_size()
180 return (_v4l_cam ? _v4l_cam->buffer_size() : 0);
184 V4LCamera::dispose_buffer()
186 if (_v4l_cam) _v4l_cam->dispose_buffer();
190 V4LCamera::pixel_width()
192 if (!_v4l_cam)
throw fawkes::Exception(
"V4LCam::pixel_width(): Camera not opened");
194 return _v4l_cam->pixel_width();
198 V4LCamera::pixel_height()
200 if (!_v4l_cam)
throw fawkes::Exception(
"V4LCam::pixel_height(): Camera not opened");
202 return _v4l_cam->pixel_height();
206 V4LCamera::colorspace()
208 return (_v4l_cam ? _v4l_cam->colorspace() : CS_UNKNOWN);
212 V4LCamera::set_image_number(
unsigned int n)
214 if (_v4l_cam) _v4l_cam->set_image_number(n);
std::string get(std::string s) const
Get the value of the given parameter.
Video4Linux 2 camera access implementation.
Base class for exceptions in Fawkes.
Video4Linux 1 camera implementation.
Expected parameter is missing.
bool has(std::string s) const
Check if an parameter was given.