24 #include <fvcams/v4l2.h> 26 #include <core/exception.h> 27 #include <core/exceptions/software.h> 28 #include <logging/liblogger.h> 29 #include <fvutils/system/camargp.h> 32 #include <sys/ioctl.h> 38 #include <linux/version.h> 52 # define v4l2_fd_open(fd, flags) (fd) 53 # define v4l2_close ::close 55 # define v4l2_ioctl ioctl 56 # define v4l2_read read 57 # define v4l2_mmap mmap 58 # define v4l2_munmap munmap 89 V4L2Camera::V4L2Camera(
const char *device_name)
91 _opened = _started =
false;
92 _nao_hacks = _switch_u_v =
false;
93 _width = _height = _bytes_per_line = _fps = _buffers_length = 0;
97 _brightness.set = _contrast.set = _saturation.set = _hue.set =
98 _red_balance.set = _blue_balance.set = _exposure.set = _gain.set =
99 _lens_x.set = _lens_y.set =
false;
100 _awb = _agc = _h_flip = _v_flip = NOT_SET;
101 _exposure_auto_priority = NOT_SET;
102 _exposure_auto.set =
false;
103 _white_balance_temperature.set =
false;
104 _exposure_absolute.set =
false;
105 _white_balance_temperature.set =
false;
106 _sharpness.set =
false;
108 memset(_format, 0, 5);
109 _frame_buffers = NULL;
110 _capture_time = NULL;
111 _device_name = strdup(device_name);
112 _data =
new V4L2CameraData();
151 _opened = _started =
false;
153 _width = _height = _bytes_per_line = _buffers_length = 0;
154 _current_buffer = -1;
155 _frame_buffers = NULL;
156 _capture_time = NULL;
159 _data =
new V4L2CameraData();
161 if (cap->
has(
"device")) _device_name = strdup(cap->
get(
"device").c_str());
164 if (cap->
has(
"nao")) {
168 if (cap->
has(
"read_method")) {
169 string rm = cap->
get(
"read_method");
170 if (rm.compare(
"READ") == 0) _read_method = READ;
171 else if (rm.compare(
"MMAP") == 0) _read_method = MMAP;
172 else if (rm.compare(
"UPTR") == 0) _read_method = UPTR;
173 else throw Exception(
"V4L2Cam: Invalid read method");
178 if (cap->
has(
"format")) {
179 string fmt = cap->
get(
"format");
180 if (fmt.length() != 4)
throw Exception(
"V4L2Cam: Invalid format fourcc");
181 strncpy(_format, fmt.c_str(), 4);
184 memset(_format, 0, 5);
187 if (cap->
has(
"standard")) {
188 _standard = strdup(cap->
get(
"standard").c_str());
191 if (cap->
has(
"input")) {
192 _input = strdup(cap->
get(
"input").c_str());
195 if (cap->
has(
"size")) {
196 string size = cap->
get(
"size");
197 string::size_type pos;
198 if ((pos = size.find(
'x')) == string::npos)
throw Exception(
"V4L2Cam: invalid image size string");
199 if (pos == (size.length() - 1))
throw Exception(
"V4L2Cam: invalid image size string");
201 unsigned int mult = 1;
202 for (string::size_type i = pos - 1; i != string::npos; --i) {
203 _width += (size.at(i) -
'0') * mult;
208 for (string::size_type i = size.length() - 1; i > pos; --i) {
209 _height += (size.at(i) -
'0') * mult;
214 if (cap->
has(
"switch_u_v")) {
215 _switch_u_v = (cap->
get(
"switch_u_v").compare(
"true") == 0);
220 if (cap->
has(
"fps")) {
221 if ((_fps = atoi(cap->
get(
"fps").c_str())) == 0)
throw Exception(
"V4L2Cam: invalid fps string");
226 if (cap->
has(
"awb")) {
227 _awb = (cap->
get(
"awb").compare(
"true") == 0 ? TRUE : FALSE);
232 if (cap->
has(
"agc")) {
233 _agc = (cap->
get(
"agc").compare(
"true") == 0 ? TRUE : FALSE);
238 if (cap->
has(
"h_flip")) {
239 _h_flip = (cap->
get(
"h_flip").compare(
"true") == 0 ? TRUE : FALSE);
244 if (cap->
has(
"v_flip")) {
245 _v_flip = (cap->
get(
"v_flip").compare(
"true") == 0 ? TRUE : FALSE);
250 if (cap->
has(
"brightness")) {
251 _brightness.set =
true;
252 _brightness.value = atoi(cap->
get(
"brightness").c_str());
254 _brightness.set =
false;
257 if (cap->
has(
"contrast")) {
258 _contrast.set =
true;
259 _contrast.value = atoi(cap->
get(
"contrast").c_str());
261 _contrast.set =
false;
264 if (cap->
has(
"saturation")) {
265 _saturation.set =
true;
266 _saturation.value = atoi(cap->
get(
"saturation").c_str());
268 _saturation.set =
false;
271 if (cap->
has(
"hue")) {
273 _hue.value = atoi(cap->
get(
"hue").c_str());
278 if (cap->
has(
"red_balance")) {
279 _red_balance.set =
true;
280 _red_balance.value = atoi(cap->
get(
"red_balance").c_str());
282 _red_balance.set =
false;
285 if (cap->
has(
"blue_balance")) {
286 _blue_balance.set =
true;
287 _blue_balance.value = atoi(cap->
get(
"blue_balance").c_str());
289 _blue_balance.set =
false;
292 if (cap->
has(
"exposure")) {
293 _exposure.set =
true;
294 _exposure.value = atoi(cap->
get(
"exposure").c_str());
296 _exposure.set =
false;
299 if (cap->
has(
"gain")) {
301 _gain.value = atoi(cap->
get(
"gain").c_str());
306 if (cap->
has(
"lens_x")) {
308 _lens_x.value = atoi(cap->
get(
"lens_x").c_str());
313 if (cap->
has(
"lens_y")) {
315 _lens_y.value = atoi(cap->
get(
"lens_y").c_str());
320 if (cap->
has(
"exposure_auto_priority")) {
321 _exposure_auto_priority = (cap->
get(
"exposure_auto_priority").compare(
"true") == 0 ? TRUE : FALSE);
323 _exposure_auto_priority = NOT_SET;
326 if (cap->
has(
"exposure_auto")) {
327 _exposure_auto.set =
true;
328 _exposure_auto.value = atoi(cap->
get(
"exposure_auto").c_str());
330 _exposure_auto.set =
false;
333 if (cap->
has(
"exposure_absolute")) {
334 _exposure_absolute.set =
true;
335 _exposure_absolute.value = atoi(cap->
get(
"exposure_absolute").c_str());
337 _exposure_absolute.set =
false;
341 if (cap->
has(
"white_balance_temperature")) {
342 _white_balance_temperature.set =
true;
343 _white_balance_temperature.value = atoi(cap->
get(
"white_balance_temperature").c_str());
345 _white_balance_temperature.set =
false;
348 if (cap->
has(
"sharpness")) {
349 _sharpness.set =
true;
350 _sharpness.value = atoi(cap->
get(
"sharpness").c_str());
352 _sharpness.set =
false;
364 V4L2Camera::V4L2Camera(
const char *device_name,
int dev)
368 _nao_hacks = _switch_u_v =
false;
369 _width = _height = _bytes_per_line = _buffers_length = _fps = 0;
370 _current_buffer = -1;
371 _brightness.set = _contrast.set = _saturation.set = _hue.set =
372 _red_balance.set = _blue_balance.set = _exposure.set = _gain.set =
373 _lens_x.set = _lens_y.set =
false;
374 _awb = _agc = _h_flip = _v_flip = NOT_SET;
375 _exposure_auto_priority = NOT_SET;
376 _white_balance_temperature.set =
false;
377 _exposure_auto.set =
false;
378 _exposure_absolute.set =
false;
379 _sharpness.set =
false;
381 memset(_format, 0, 5);
382 _frame_buffers = NULL;
383 _capture_time = NULL;
384 _device_name = strdup(device_name);
387 _data =
new V4L2CameraData();
392 if (v4l2_ioctl(_dev, VIDIOC_QUERYCAP, &_data->caps)) {
394 throw Exception(
"V4L2Cam: Could not get capabilities - probably not a v4l2 device");
401 V4L2Camera::~V4L2Camera()
403 if (_started) stop();
404 if (_opened) close();
407 if (_standard) free(_standard);
408 if (_input) free(_input);
415 if (_started) stop();
418 _dev = ::open(_device_name, O_RDWR);
419 int libv4l2_fd = v4l2_fd_open(_dev, 0);
420 if (libv4l2_fd != -1) _dev = libv4l2_fd;
427 if (_dev < 0)
throw Exception(
"V4L2Cam: Could not open device");
432 if (v4l2_ioctl(_dev, VIDIOC_QUERYCAP, &_data->caps)) {
434 throw Exception(
"V4L2Cam: Could not get capabilities - probably not a v4l2 device");
446 V4L2Camera::post_open()
450 select_read_method();
465 V4L2Camera::select_read_method()
468 if (!(_data->caps.capabilities &
469 (_read_method == READ ? V4L2_CAP_READWRITE : V4L2_CAP_STREAMING)))
472 _read_method = (_read_method == READ ? MMAP : READ);
473 if (!(_data->caps.capabilities &
474 (_read_method == READ ? V4L2_CAP_READWRITE : V4L2_CAP_STREAMING)))
477 throw Exception(
"V4L2Cam: Neither read() nor streaming IO supported");
481 if (_read_method != READ) {
482 v4l2_requestbuffers buf;
485 if (_read_method == MMAP) {
486 _buffers_length = MMAP_NUM_BUFFERS;
487 buf.count = _buffers_length;
488 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
489 buf.memory = V4L2_MEMORY_MMAP;
490 }
else if (_read_method == UPTR) {
493 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
494 buf.memory = V4L2_MEMORY_USERPTR;
497 if (v4l2_ioctl(_dev, VIDIOC_REQBUFS, &buf)) {
499 throw Exception(
"V4L2Cam: REQBUFS query failed");
502 if (_read_method == MMAP) {
503 if (buf.count < _buffers_length) {
505 throw Exception(
"V4L2Cam: Not enough memory for the buffers");
513 switch (_read_method)
516 LibLogger::log_debug(
"V4L2Cam",
"Using read() method");
520 LibLogger::log_debug(
"V4L2Cam",
"Using memory mapping method");
524 LibLogger::log_debug(
"V4L2Cam",
"Using user pointer method");
526 throw Exception(
"V4L2Cam: user pointer method not supported yet");
533 V4L2Camera::select_standard()
536 if (! _standard)
return;
540 memset(&
std, 0,
sizeof(
std));
541 for (
std.index = 0; v4l2_ioctl(_dev, VIDIOC_ENUMSTD, &
std) == 0;
std.index++) {
542 if (strcmp(_standard, (
const char *)
std.name) == 0) {
549 throw Exception(
"Requested standard %s is not supported by the device",
553 v4l2_std_id current_std_id;
554 if (v4l2_ioctl(_dev, VIDIOC_G_STD, ¤t_std_id) != 0) {
555 throw Exception(
"Failed to read current standard");
557 if (
std.id != current_std_id) {
559 v4l2_std_id set_std_id =
std.id;
560 if (v4l2_ioctl(_dev, VIDIOC_S_STD, &set_std_id) != 0) {
561 throw Exception(errno,
"Failed to set standard %s", _standard);
568 V4L2Camera::select_input()
571 if (! _input)
return;
575 memset(&inp, 0,
sizeof(inp));
576 for (inp.index = 0; v4l2_ioctl(_dev, VIDIOC_ENUMINPUT, &inp) == 0; inp.index++) {
577 if (strcmp(_input, (
const char *)inp.name) == 0) {
584 throw Exception(
"Requested input %s is not supported by the device",
589 if (v4l2_ioctl(_dev, VIDIOC_G_INPUT, ¤t_inp_ind) != 0) {
590 throw Exception(
"Failed to read current input index");
592 if ((
int)inp.index != current_inp_ind) {
594 int set_inp_ind = inp.index;
595 if (v4l2_ioctl(_dev, VIDIOC_S_INPUT, &set_inp_ind) != 0) {
596 throw Exception(errno,
"Failed to set input %s", _input);
610 V4L2Camera::select_format()
612 bool preferred_found =
false;
613 v4l2_fmtdesc format_desc;
615 char fourcc[5] =
" ";
618 if (strcmp(_format,
"") == 0) {
620 strcpy(_format,
"YU12");
624 if (strcmp(_format,
"")) {
626 memset(&format_desc, 0,
sizeof(format_desc));
627 format_desc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
628 for (format_desc.index = 0; v4l2_ioctl(_dev, VIDIOC_ENUM_FMT, &format_desc) == 0; format_desc.index++)
630 fourcc[0] =
static_cast<char>(format_desc.pixelformat & 0xFF);
631 fourcc[1] =
static_cast<char>((format_desc.pixelformat >> 8) & 0xFF);
632 fourcc[2] =
static_cast<char>((format_desc.pixelformat >> 16) & 0xFF);
633 fourcc[3] =
static_cast<char>((format_desc.pixelformat >> 24) & 0xFF);
635 if (strcmp(_format, fourcc) == 0) {
636 preferred_found =
true;
642 if (!preferred_found) {
645 memset(&format_desc, 0,
sizeof(format_desc));
646 format_desc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
647 format_desc.index = 0;
648 if (v4l2_ioctl(_dev, VIDIOC_ENUM_FMT, &format_desc)) {
650 throw Exception(
"V4L2Cam: No image format found");
653 fourcc[0] =
static_cast<char>(format_desc.pixelformat & 0xFF);
654 fourcc[1] =
static_cast<char>((format_desc.pixelformat >> 8) & 0xFF);
655 fourcc[2] =
static_cast<char>((format_desc.pixelformat >> 16) & 0xFF);
656 fourcc[3] =
static_cast<char>((format_desc.pixelformat >> 24) & 0xFF);
661 memset(&format, 0,
sizeof(format));
662 format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
663 if (v4l2_ioctl(_dev, VIDIOC_G_FMT, &format)) {
665 throw Exception(
"V4L2Cam: Format query failed");
670 format.fmt.pix.pixelformat = v4l2_fourcc(fourcc[0], fourcc[1], fourcc[2], fourcc[3]);
671 format.fmt.pix.field = V4L2_FIELD_ANY;
673 format.fmt.pix.width = _width;
675 format.fmt.pix.height = _height;
677 int s_fmt_rv = v4l2_ioctl(_dev, VIDIOC_S_FMT, &format);
678 if (s_fmt_rv != 0 && errno != EBUSY && _nao_hacks) {
683 LibLogger::log_warn(
"V4L2Cam",
"Format setting failed (driver sucks) - %d: %s", errno, strerror(errno));
684 LibLogger::log_info(
"V4L2Cam",
"Trying workaround");
687 if (v4l2_ioctl(_dev, VIDIOC_G_STD, &
std)) {
689 throw Exception(
"V4L2Cam: Standard query (workaround) failed");
692 if ((_width == 320) && (_height == 240)) {
699 if (v4l2_ioctl(_dev, VIDIOC_S_STD, &
std)) {
701 throw Exception(
"V4L2Cam: Standard setting (workaround) failed");
704 format.fmt.pix.width = _width;
705 format.fmt.pix.height = _height;
706 format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
707 format.fmt.pix.field = V4L2_FIELD_ANY;
709 if (v4l2_ioctl(_dev, VIDIOC_S_FMT, &format)) {
711 throw Exception(
"V4L2Cam: Format setting (workaround) failed");
714 if (_switch_u_v) _colorspace = YVY2;
718 _format[0] =
static_cast<char>(format.fmt.pix.pixelformat & 0xFF);
719 _format[1] =
static_cast<char>((format.fmt.pix.pixelformat >> 8) & 0xFF);
720 _format[2] =
static_cast<char>((format.fmt.pix.pixelformat >> 16) & 0xFF);
721 _format[3] =
static_cast<char>((format.fmt.pix.pixelformat >> 24) & 0xFF);
723 if (!_nao_hacks || !_switch_u_v) {
724 if (strcmp(_format,
"RGB3") == 0) _colorspace = RGB;
725 else if (strcmp(_format,
"Y41P") == 0) _colorspace = YUV411_PACKED;
726 else if (strcmp(_format,
"411P") == 0) _colorspace = YUV411_PLANAR;
727 else if (strcmp(_format,
"YUYV") == 0) _colorspace = YUY2;
728 else if (strcmp(_format,
"BGR3") == 0) _colorspace = BGR;
729 else if (strcmp(_format,
"UYVY") == 0) _colorspace = YUV422_PACKED;
730 else if (strcmp(_format,
"422P") == 0) _colorspace = YUV422_PLANAR;
731 else if (strcmp(_format,
"GREY") == 0) _colorspace = GRAY8;
732 else if (strcmp(_format,
"RGB4") == 0) _colorspace = RGB_WITH_ALPHA;
733 else if (strcmp(_format,
"BGR4") == 0) _colorspace = BGR_WITH_ALPHA;
734 else if (strcmp(_format,
"BA81") == 0) _colorspace = BAYER_MOSAIC_BGGR;
735 else if (strcmp(_format,
"Y16 ") == 0) _colorspace = MONO16;
736 else if (strcmp(_format,
"YU12") == 0) _colorspace = YUV420_PLANAR;
737 else _colorspace = CS_UNKNOWN;
741 _width = format.fmt.pix.width;
742 _height = format.fmt.pix.height;
745 _bytes_per_line = format.fmt.pix.bytesperline;
748 if (_bytes_per_line == 0) {
749 LibLogger::log_warn(
"V4L2Cam",
"bytesperline is 0 (driver sucks)");
750 _bytes_per_line = colorspace_buffer_size(_colorspace, _width, _height) / _height;
753 LibLogger::log_debug(
"V4L2Cam",
"w%d h%d bpl%d cs%d fmt%s", _width, _height, _bytes_per_line, _colorspace, _format);
760 V4L2Camera::set_fps()
762 v4l2_streamparm param;
763 param.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
764 if (v4l2_ioctl(_dev, VIDIOC_G_PARM, ¶m)) {
766 throw Exception(
"V4L2Cam: Streaming parameter query failed");
769 if (!(param.parm.capture.capability & V4L2_CAP_TIMEPERFRAME)) {
770 LibLogger::log_warn(
"V4L2Cam",
"FPS change not supported");
774 param.parm.capture.timeperframe.numerator = 1;
775 param.parm.capture.timeperframe.denominator = _fps;
776 if (v4l2_ioctl(_dev, VIDIOC_S_PARM, ¶m)) {
778 throw Exception(
"V4L2Cam: Streaming parameter setting failed");
780 LibLogger::log_debug(
"V4L2Cam",
"FPS set - %d/%d",
781 param.parm.capture.timeperframe.numerator,
782 param.parm.capture.timeperframe.denominator);
790 V4L2Camera::set_controls()
792 if (_exposure_auto_priority != NOT_SET) set_exposure_auto_priority(_exposure_auto_priority == TRUE);
793 if (_exposure_auto.set) set_exposure_auto(_exposure_auto.value);
795 if (_awb != NOT_SET) set_auto_white_balance(_awb == TRUE);
796 if (_agc != NOT_SET) set_auto_gain(_agc == TRUE);
798 if (_h_flip != NOT_SET) set_horiz_mirror(_h_flip == TRUE);
799 if (_v_flip != NOT_SET) set_vert_mirror(_v_flip == TRUE);
801 if (_brightness.set) set_brightness(_brightness.value);
802 if (_contrast.set) set_contrast(_contrast.value);
803 if (_saturation.set) set_saturation(_saturation.value);
804 if (_hue.set) set_hue(_hue.value);
805 if (_red_balance.set) set_red_balance(_red_balance.value);
806 if (_blue_balance.set) set_blue_balance(_blue_balance.value);
807 if (_exposure.set) set_exposure(_exposure.value);
808 if (_gain.set) set_gain(_gain.value);
809 if (_lens_x.set) set_lens_x_corr(_lens_x.value);
810 if (_lens_y.set) set_lens_y_corr(_lens_y.value);
812 if (_exposure_absolute.set) set_exposure_absolute(_exposure_absolute.value);
813 if (_white_balance_temperature.set) set_white_balance_temperature(_white_balance_temperature.value);
814 if (_sharpness.set) set_sharpness(_sharpness.value);
824 V4L2Camera::set_one_control(
const char *ctrl,
unsigned int id,
int value)
826 v4l2_queryctrl queryctrl;
827 v4l2_control control;
829 memset(&queryctrl, 0,
sizeof(queryctrl));
832 if (v4l2_ioctl(_dev, VIDIOC_QUERYCTRL, &queryctrl)) {
833 if (errno == EINVAL) {
834 LibLogger::log_error(
"V4L2Cam",
"Control %s not supported", ctrl);
839 throw Exception(
"V4L2Cam: %s Control query failed", ctrl);
841 if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
842 LibLogger::log_error(
"V4L2Cam",
"Control %s disabled", ctrl);
846 memset(&control, 0,
sizeof(control));
848 control.value = value;
850 if (v4l2_ioctl(_dev, VIDIOC_S_CTRL, &control)) {
852 throw Exception(
"V4L2Cam: %s Control setting failed", ctrl);
863 V4L2Camera::get_one_control(
const char *ctrl,
unsigned int id)
865 v4l2_queryctrl queryctrl;
866 v4l2_control control;
868 memset(&queryctrl, 0,
sizeof(queryctrl));
871 if (v4l2_ioctl(_dev, VIDIOC_QUERYCTRL, &queryctrl)) {
872 if (errno == EINVAL) {
873 LibLogger::log_error(
"V4L2Cam",
"Control %s not supported", ctrl);
878 throw Exception(
"V4L2Cam: %s Control query failed", ctrl);
880 if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
881 LibLogger::log_error(
"V4L2Cam",
"Control %s disabled", ctrl);
885 memset(&control, 0,
sizeof(control));
888 if (v4l2_ioctl(_dev, VIDIOC_G_CTRL, &control)) {
890 throw Exception(
"V4L2Cam: %s Control value reading failed", ctrl);
893 return control.value;
906 V4L2Camera::create_buffer()
908 _frame_buffers =
new FrameBuffer[_buffers_length];
910 switch (_read_method)
914 _frame_buffers[0].size = _bytes_per_line * _height;
915 _frame_buffers[0].buffer =
static_cast<unsigned char *
>(malloc(_frame_buffers[0].size));
916 if (_frame_buffers[0].buffer == NULL)
919 throw Exception(
"V4L2Cam: Out of memory");
926 for (
unsigned int i = 0; i < _buffers_length; ++i)
931 memset(&buffer, 0,
sizeof (buffer));
932 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
933 buffer.memory = V4L2_MEMORY_MMAP;
936 if (v4l2_ioctl(_dev, VIDIOC_QUERYBUF, &buffer))
939 throw Exception(
"V4L2Cam: Buffer query failed");
942 _frame_buffers[i].size = buffer.length;
943 _frame_buffers[i].buffer =
static_cast<unsigned char *
>(
944 v4l2_mmap(NULL, buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED, _dev, buffer.m.offset)
946 if (_frame_buffers[i].buffer == MAP_FAILED)
949 throw Exception(
"V4L2Cam: Memory mapping failed");
966 V4L2Camera::reset_cropping()
968 v4l2_cropcap cropcap;
971 memset(&cropcap, 0,
sizeof(cropcap));
972 cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
974 if (v4l2_ioctl(_dev, VIDIOC_CROPCAP, &cropcap)) {
975 if (errno == ENOTTY) {
979 LibLogger::log_warn(
"V4L2Cam",
"cropcap query failed (driver sucks) - %d: %s", errno, strerror(errno));
982 memset(&crop, 0,
sizeof(crop));
983 crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
984 crop.c = cropcap.defrect;
987 if (v4l2_ioctl(_dev, VIDIOC_S_CROP, &crop) && errno != EINVAL) {
988 LibLogger::log_warn(
"V4L2Cam",
"cropping query failed (driver sucks) - %d: %s", errno, strerror(errno));
997 if (_started) stop();
999 if (_frame_buffers) {
1000 switch (_read_method) {
1003 free(_frame_buffers[0].buffer);
1009 for (
unsigned int i = 0; i < _buffers_length; ++i) {
1010 v4l2_munmap(_frame_buffers[i].buffer, _frame_buffers[i].size);
1019 delete[] _frame_buffers;
1020 _frame_buffers = NULL;
1021 _current_buffer = -1;
1030 if (_capture_time) {
1031 delete _capture_time;
1039 if (!_opened)
throw Exception(
"VL42Cam: Camera not opened");
1041 if (_started) stop();
1043 switch (_read_method) {
1051 for (
unsigned int i = 0; i < _buffers_length; ++i) {
1053 memset(&buffer, 0,
sizeof(buffer));
1054 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1055 buffer.memory = V4L2_MEMORY_MMAP;
1058 if (v4l2_ioctl(_dev, VIDIOC_QBUF, &buffer)) {
1060 throw Exception(
"V4L2Cam: Enqueuing buffer failed");
1065 int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1066 if (v4l2_ioctl(_dev, VIDIOC_STREAMON, &type)) {
1068 throw Exception(
"V4L2Cam: Starting stream failed");
1087 if (!_started)
return;
1089 switch (_read_method) {
1098 int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1099 if (v4l2_ioctl(_dev, VIDIOC_STREAMOFF, &type)) {
1100 throw Exception(
"V4L2Cam: Stopping stream failed");
1106 _current_buffer = -1;
1124 V4L2Camera::capture()
1126 if (!_started)
return;
1128 switch (_read_method) {
1131 _current_buffer = 0;
1132 if (v4l2_read(_dev, _frame_buffers[_current_buffer].buffer, _frame_buffers[_current_buffer].size) == -1) {
1133 LibLogger::log_warn(
"V4L2Cam",
"read() failed with code %d: %s", errno, strerror(errno));
1137 if (_capture_time) {
1138 _capture_time->stamp();
1150 memset(&buffer, 0,
sizeof(buffer));
1151 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1152 buffer.memory = V4L2_MEMORY_MMAP;
1154 if (v4l2_ioctl(_dev, VIDIOC_DQBUF, &buffer)) {
1156 throw Exception(
"V4L2Cam: Dequeuing buffer failed");
1159 _current_buffer = buffer.index;
1161 if (_capture_time) {
1162 _capture_time->set_time(&buffer.timestamp);
1176 V4L2Camera::buffer()
1180 return (_current_buffer == -1 ? NULL : _frame_buffers[_current_buffer].buffer);
1184 V4L2Camera::buffer_size()
1188 return (_opened && (_current_buffer != -1) ? _frame_buffers[_current_buffer].size : 0);
1192 V4L2Camera::dispose_buffer()
1196 if (!_opened)
return;
1198 switch (_read_method) {
1207 memset(&buffer, 0,
sizeof(buffer));
1208 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1209 buffer.memory = V4L2_MEMORY_MMAP;
1210 buffer.index = _current_buffer;
1213 if (v4l2_ioctl(_dev, VIDIOC_QBUF, &buffer)) {
1214 int errno_save = errno;
1216 throw Exception(errno_save,
"V4L2Cam: Enqueuing buffer failed");
1226 _current_buffer = -1;
1230 V4L2Camera::pixel_width()
1238 V4L2Camera::pixel_height()
1246 V4L2Camera::colorspace()
1257 V4L2Camera::capture_time()
1259 return _capture_time;
1263 V4L2Camera::set_image_number(
unsigned int n)
1278 V4L2Camera::exposure_auto_priority()
1280 return get_one_control(
"exposure_auto_priority", V4L2_CID_EXPOSURE_AUTO_PRIORITY);
1288 V4L2Camera::set_exposure_auto_priority(
bool enabled)
1290 LibLogger::log_debug(
"V4L2Cam", (enabled ?
"enabling exposure_auto_priority" :
"disabling exposure_auto_priority"));
1291 set_one_control(
"AGC", V4L2_CID_EXPOSURE_AUTO_PRIORITY, (enabled ? 1 : 0));
1299 V4L2Camera::white_balance_temperature()
1301 return get_one_control(
"white_balance_temperature", V4L2_CID_WHITE_BALANCE_TEMPERATURE);
1309 V4L2Camera::set_white_balance_temperature(
unsigned int white_balance_temperature)
1311 LibLogger::log_debug(
"V4L2Cam",
"setting white_balance_temperature to %d", white_balance_temperature);
1312 set_one_control(
"white_balance_temperature", V4L2_CID_WHITE_BALANCE_TEMPERATURE, white_balance_temperature);
1320 V4L2Camera::exposure_absolute()
1322 return get_one_control(
"exposure_absolute", V4L2_CID_EXPOSURE_ABSOLUTE);
1330 V4L2Camera::set_exposure_absolute(
unsigned int exposure_absolute)
1332 LibLogger::log_debug(
"V4L2Cam",
"setting exposure_absolute to %d", exposure_absolute);
1333 set_one_control(
"exposure_absolute", V4L2_CID_EXPOSURE_ABSOLUTE, exposure_absolute);
1341 V4L2Camera::sharpness()
1343 return get_one_control(
"sharpness", V4L2_CID_SHARPNESS);
1351 V4L2Camera::set_sharpness(
unsigned int sharpness)
1353 LibLogger::log_debug(
"V4L2Cam",
"setting sharpness to %d", sharpness);
1354 set_one_control(
"sharpness", V4L2_CID_SHARPNESS, sharpness);
1358 V4L2Camera::auto_gain()
1360 return get_one_control(
"AGC", V4L2_CID_AUTOGAIN);
1364 V4L2Camera::set_auto_gain(
bool enabled)
1366 LibLogger::log_debug(
"V4L2Cam", (enabled ?
"enabling AGC" :
"disabling AGC"));
1367 set_one_control(
"AGC", V4L2_CID_AUTOGAIN, (enabled ? 1 : 0));
1371 V4L2Camera::auto_white_balance()
1373 return get_one_control(
"AWB", V4L2_CID_AUTO_WHITE_BALANCE);
1377 V4L2Camera::set_auto_white_balance(
bool enabled)
1379 LibLogger::log_debug(
"V4L2Cam", (enabled ?
"enabling AWB" :
"disabling AWB"));
1380 set_one_control(
"AWB", V4L2_CID_AUTO_WHITE_BALANCE, (enabled ? 1 : 0));
1384 V4L2Camera::exposure_auto()
1386 return get_one_control(
"exposure_auto", V4L2_CID_EXPOSURE_AUTO);
1390 V4L2Camera::set_exposure_auto(
unsigned int exposure_auto)
1392 LibLogger::log_debug(
"V4L2Cam",
"setting exposure_auto to %d", exposure_auto);
1393 set_one_control(
"exposure_auto", V4L2_CID_EXPOSURE_AUTO, exposure_auto);
1397 V4L2Camera::red_balance()
1399 return get_one_control(
"red balance", V4L2_CID_RED_BALANCE);
1403 V4L2Camera::set_red_balance(
int red_balance)
1405 LibLogger::log_debug(
"V4L2Cam",
"Setting red balance to %d", red_balance);
1406 set_one_control(
"red balance", V4L2_CID_RED_BALANCE, red_balance);
1410 V4L2Camera::blue_balance()
1412 return get_one_control(
"blue balance", V4L2_CID_BLUE_BALANCE);
1416 V4L2Camera::set_blue_balance(
int blue_balance)
1418 LibLogger::log_debug(
"V4L2Cam",
"Setting blue balance to %d", blue_balance);
1419 set_one_control(
"blue balance", V4L2_CID_BLUE_BALANCE, blue_balance);
1423 V4L2Camera::u_balance()
1429 V4L2Camera::set_u_balance(
int u_balance)
1435 V4L2Camera::v_balance()
1441 V4L2Camera::set_v_balance(
int v_balance)
1447 V4L2Camera::brightness()
1449 return get_one_control(
"brightness", V4L2_CID_BRIGHTNESS);
1453 V4L2Camera::set_brightness(
unsigned int brightness)
1455 LibLogger::log_debug(
"V4L2Cam",
"Setting brighness to %d", brightness);
1456 set_one_control(
"brightness", V4L2_CID_BRIGHTNESS, brightness);
1460 V4L2Camera::contrast()
1462 return get_one_control(
"contrast", V4L2_CID_CONTRAST);
1466 V4L2Camera::set_contrast(
unsigned int contrast)
1468 LibLogger::log_debug(
"V4L2Cam",
"Setting contrast to %d", contrast);
1469 set_one_control(
"contrast", V4L2_CID_CONTRAST, contrast);
1473 V4L2Camera::saturation()
1475 return get_one_control(
"saturation", V4L2_CID_SATURATION);
1479 V4L2Camera::set_saturation(
unsigned int saturation)
1481 LibLogger::log_debug(
"V4L2Cam",
"Setting saturation to %d", saturation);
1482 set_one_control(
"saturation", V4L2_CID_SATURATION, saturation);
1488 return get_one_control(
"hue", V4L2_CID_HUE);
1492 V4L2Camera::set_hue(
int hue)
1494 LibLogger::log_debug(
"V4L2Cam",
"Setting hue to %d", hue);
1495 set_one_control(
"hue", V4L2_CID_HUE, hue);
1499 V4L2Camera::exposure()
1501 return get_one_control(
"exposure", V4L2_CID_EXPOSURE);
1505 V4L2Camera::set_exposure(
unsigned int exposure)
1507 LibLogger::log_debug(
"V4L2Cam",
"Setting exposure to %d", exposure);
1508 set_one_control(
"exposure", V4L2_CID_EXPOSURE, exposure);
1514 return get_one_control(
"gain", V4L2_CID_GAIN);
1518 V4L2Camera::set_gain(
unsigned int gain)
1520 LibLogger::log_debug(
"V4L2Cam",
"Setting gain to %u", gain);
1521 set_one_control(
"gain", V4L2_CID_GAIN, gain);
1526 V4L2Camera::format()
1532 V4L2Camera::set_format(
const char *format)
1534 strncpy(_format, format, 4);
1542 return pixel_width();
1546 V4L2Camera::height()
1548 return pixel_height();
1552 V4L2Camera::set_size(
unsigned int width,
1553 unsigned int height)
1561 V4L2Camera::horiz_mirror()
1563 return (get_one_control(
"hflip", V4L2_CID_HFLIP) != 0);
1567 V4L2Camera::vert_mirror()
1569 return (get_one_control(
"vflip", V4L2_CID_VFLIP) != 0);
1573 V4L2Camera::set_horiz_mirror(
bool enabled)
1575 LibLogger::log_debug(
"V4L2Cam", (enabled ?
"enabling horizontal flip" :
"disabling horizontal flip"));
1576 set_one_control(
"hflip", V4L2_CID_HFLIP, (enabled ? 1 : 0));
1580 V4L2Camera::set_vert_mirror(
bool enabled)
1582 LibLogger::log_debug(
"V4L2Cam", (enabled ?
"enabling vertical flip" :
"disabling vertical flip"));
1583 set_one_control(
"vflip", V4L2_CID_VFLIP, (enabled ? 1 : 0));
1597 V4L2Camera::set_fps(
unsigned int fps)
1604 V4L2Camera::lens_x_corr()
1606 return get_one_control(
"lens x", V4L2_CID_PAN_RESET);
1610 V4L2Camera::lens_y_corr()
1612 return get_one_control(
"lens y", V4L2_CID_TILT_RESET);
1616 V4L2Camera::set_lens_x_corr(
unsigned int x_corr)
1618 LibLogger::log_debug(
"V4L2Cam",
"Setting horizontal lens correction to %d", x_corr);
1619 set_one_control(
"lens x", V4L2_CID_PAN_RESET, x_corr);
1623 V4L2Camera::set_lens_y_corr(
unsigned int y_corr)
1625 LibLogger::log_debug(
"V4L2Cam",
"Setting vertical lens correction to %d", y_corr);
1626 set_one_control(
"lens x", V4L2_CID_TILT_RESET, y_corr);
1631 V4L2Camera::print_info()
1635 "==========================================================================" 1636 << endl << _device_name <<
" (" << _data->caps.card <<
") - " << _data->caps.bus_info
1637 << endl <<
"Driver: " << _data->caps.driver <<
" (ver " <<
1638 ((_data->caps.version >> 16) & 0xFF) <<
"." <<
1639 ((_data->caps.version >> 8) & 0xFF) <<
"." <<
1640 (_data->caps.version & 0xFF) <<
")" << endl <<
1641 "--------------------------------------------------------------------------" 1645 cout <<
"Capabilities:" << endl;
1646 if (_data->caps.capabilities & V4L2_CAP_VIDEO_CAPTURE)
1647 cout <<
" + Video capture interface supported" << endl;
1648 if (_data->caps.capabilities & V4L2_CAP_VIDEO_OUTPUT)
1649 cout <<
" + Video output interface supported" << endl;
1650 if (_data->caps.capabilities & V4L2_CAP_VIDEO_OVERLAY)
1651 cout <<
" + Video overlay interface supported" << endl;
1652 if (_data->caps.capabilities & V4L2_CAP_VBI_CAPTURE)
1653 cout <<
" + Raw VBI capture interface supported" << endl;
1654 if (_data->caps.capabilities & V4L2_CAP_VBI_OUTPUT)
1655 cout <<
" + Raw VBI output interface supported" << endl;
1656 if (_data->caps.capabilities & V4L2_CAP_SLICED_VBI_CAPTURE)
1657 cout <<
" + Sliced VBI capture interface supported" << endl;
1658 if (_data->caps.capabilities & V4L2_CAP_SLICED_VBI_OUTPUT)
1659 cout <<
" + Sliced VBI output interface supported" << endl;
1660 if (_data->caps.capabilities & V4L2_CAP_RDS_CAPTURE)
1661 cout <<
" + RDS_CAPTURE set" << endl;
1665 if (_data->caps.capabilities & V4L2_CAP_TUNER)
1666 cout <<
" + Has some sort of tuner" << endl;
1667 if (_data->caps.capabilities & V4L2_CAP_AUDIO)
1668 cout <<
" + Has audio inputs or outputs" << endl;
1669 if (_data->caps.capabilities & V4L2_CAP_RADIO)
1670 cout <<
" + Has a radio receiver" << endl;
1671 if (_data->caps.capabilities & V4L2_CAP_READWRITE)
1672 cout <<
" + read() and write() IO supported" << endl;
1673 if (_data->caps.capabilities & V4L2_CAP_ASYNCIO)
1674 cout <<
" + asynchronous IO supported" << endl;
1675 if (_data->caps.capabilities & V4L2_CAP_STREAMING)
1676 cout <<
" + streaming IO supported" << endl;
1677 if (_data->caps.capabilities & V4L2_CAP_TIMEPERFRAME)
1678 cout <<
" + timeperframe field is supported" << endl;
1682 cout <<
"Inputs:" << endl;
1684 memset(&input, 0,
sizeof(input));
1686 for (input.index = 0; v4l2_ioctl(_dev, VIDIOC_ENUMINPUT, &input) == 0; input.index++)
1688 cout <<
"Input " << input.index <<
": " << input.name << endl;
1690 cout <<
" |- Type: ";
1693 case V4L2_INPUT_TYPE_TUNER:
1697 case V4L2_INPUT_TYPE_CAMERA:
1706 cout <<
" |- Supported standards:";
1709 cout <<
" Unknown" << endl;
1715 v4l2_standard standard;
1716 memset (&standard, 0,
sizeof(standard));
1719 for (standard.index = 0; v4l2_ioctl(_dev, VIDIOC_ENUMSTD, &standard) == 0; standard.index++)
1721 if (standard.id & input.std) cout <<
" + " << standard.name << endl;
1725 if (input.index == 0) cout <<
"None" << endl;
1729 cout <<
"Outputs:" << endl;
1731 memset (&output, 0,
sizeof(output));
1733 for (output.index = 0; v4l2_ioctl(_dev, VIDIOC_ENUMOUTPUT, &output) == 0; output.index++)
1735 cout <<
" + Output " << output.index <<
": " << output.name << endl;
1737 cout <<
" |- Type: ";
1738 switch (output.type)
1740 case V4L2_OUTPUT_TYPE_MODULATOR:
1741 cout <<
"TV Modulator";
1744 case V4L2_OUTPUT_TYPE_ANALOG:
1745 cout <<
"Analog output";
1753 cout <<
" |- Supported standards:";
1754 if (output.std == 0)
1756 cout <<
" Unknown" << endl;
1762 v4l2_standard standard;
1763 memset (&standard, 0,
sizeof (standard));
1766 for (standard.index = 0; v4l2_ioctl(_dev, VIDIOC_ENUMSTD, &standard) == 0; standard.index++)
1768 if (standard.id & output.std) cout <<
" + " << standard.name << endl;
1772 if (output.index == 0) cout <<
"None" << endl;
1776 cout <<
"Formats:" << endl;
1777 v4l2_fmtdesc format_desc;
1778 memset(&format_desc, 0,
sizeof(format_desc));
1779 format_desc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1781 char fourcc[5] =
" ";
1782 for (format_desc.index = 0; v4l2_ioctl(_dev, VIDIOC_ENUM_FMT, &format_desc) == 0; format_desc.index++)
1784 fourcc[0] =
static_cast<char>(format_desc.pixelformat & 0xFF);
1785 fourcc[1] =
static_cast<char>((format_desc.pixelformat >> 8) & 0xFF);
1786 fourcc[2] =
static_cast<char>((format_desc.pixelformat >> 16) & 0xFF);
1787 fourcc[3] =
static_cast<char>((format_desc.pixelformat >> 24) & 0xFF);
1789 colorspace_t cs = CS_UNKNOWN;
1790 if (strcmp(fourcc,
"RGB3") == 0) cs = RGB;
1791 else if (strcmp(fourcc,
"Y41P") == 0) cs = YUV411_PACKED;
1792 else if (strcmp(fourcc,
"411P") == 0) cs = YUV411_PLANAR;
1793 else if (strcmp(fourcc,
"YUYV") == 0) cs = YUY2;
1794 else if (strcmp(fourcc,
"BGR3") == 0) cs = BGR;
1795 else if (strcmp(fourcc,
"UYVY") == 0) cs = YUV422_PACKED;
1796 else if (strcmp(fourcc,
"422P") == 0) cs = YUV422_PLANAR;
1797 else if (strcmp(fourcc,
"GREY") == 0) cs = GRAY8;
1798 else if (strcmp(fourcc,
"RGB4") == 0) cs = RGB_WITH_ALPHA;
1799 else if (strcmp(fourcc,
"BGR4") == 0) cs = BGR_WITH_ALPHA;
1800 else if (strcmp(fourcc,
"BA81") == 0) cs = BAYER_MOSAIC_BGGR;
1801 else if (strcmp(fourcc,
"Y16 ") == 0) cs = MONO16;
1803 cout <<
" + Format " << format_desc.index <<
": " << fourcc <<
1804 " (" << format_desc.description <<
")";
1805 if (format_desc.flags & V4L2_FMT_FLAG_COMPRESSED) cout <<
" [Compressed]";
1806 cout << endl <<
" |- Colorspace: " << colorspace_to_string(cs) << endl;
1812 memset(&format, 0,
sizeof(format));
1813 format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1814 if (v4l2_ioctl(_dev, VIDIOC_G_FMT, &format))
throw Exception(
"V4L2Cam: Format query failed");
1815 fourcc[0] =
static_cast<char>(format.fmt.pix.pixelformat & 0xFF);
1816 fourcc[1] =
static_cast<char>((format.fmt.pix.pixelformat >> 8) & 0xFF);
1817 fourcc[2] =
static_cast<char>((format.fmt.pix.pixelformat >> 16) & 0xFF);
1818 fourcc[3] =
static_cast<char>((format.fmt.pix.pixelformat >> 24) & 0xFF);
1820 cout <<
" Current Format:" << endl <<
1821 " " << format.fmt.pix.width <<
"x" << format.fmt.pix.height <<
1822 " (" << fourcc <<
")" << endl <<
1823 " " << format.fmt.pix.bytesperline <<
" bytes per line" << endl <<
1824 " Total size: " << format.fmt.pix.sizeimage << endl;
1827 cout <<
"Controls:" << endl;
1828 v4l2_queryctrl queryctrl;
1829 v4l2_querymenu querymenu;
1831 memset(&queryctrl, 0,
sizeof(queryctrl));
1833 for (queryctrl.id = V4L2_CID_BASE; queryctrl.id < V4L2_CID_LASTP1;
1836 if (v4l2_ioctl(_dev, VIDIOC_QUERYCTRL, &queryctrl))
1838 if (errno == EINVAL)
continue;
1840 cout <<
"Control query failed" << endl;
1843 if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)
continue;
1845 cout <<
" + " << queryctrl.name <<
" [" <<
1846 (queryctrl.id - V4L2_CID_BASE) <<
"] (";
1847 switch (queryctrl.type)
1849 case V4L2_CTRL_TYPE_INTEGER:
1850 cout <<
"int [" << queryctrl.minimum <<
"-" << queryctrl.maximum <<
1851 " /" << queryctrl.step <<
" def " << queryctrl.default_value <<
1855 case V4L2_CTRL_TYPE_MENU:
1856 cout <<
"menu [def " << queryctrl.default_value <<
"]";
1859 case V4L2_CTRL_TYPE_BOOLEAN:
1860 cout <<
"bool [def " << queryctrl.default_value <<
"]";
1863 case V4L2_CTRL_TYPE_BUTTON:
1867 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) 1868 case V4L2_CTRL_TYPE_INTEGER64:
1872 case V4L2_CTRL_TYPE_CTRL_CLASS:
1873 cout <<
"ctrl_class";
1876 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) 1877 case V4L2_CTRL_TYPE_STRING:
1881 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,41) 1882 case V4L2_CTRL_TYPE_BITMASK:
1887 cout <<
")" << endl;
1889 if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
1891 cout <<
" |- Menu items:" << endl;
1893 memset(&querymenu, 0,
sizeof(querymenu));
1894 querymenu.id = queryctrl.id;
1896 for (querymenu.index = queryctrl.minimum;
1897 querymenu.index <= static_cast<unsigned long int>(queryctrl.maximum);
1900 if (v4l2_ioctl(_dev, VIDIOC_QUERYMENU, &querymenu))
1902 cout <<
"Getting menu items failed" << endl;
1905 cout <<
" | + " << querymenu.name << endl;
1909 if (queryctrl.id == V4L2_CID_BASE) cout <<
"None" << endl;
1913 cout <<
"Private Controls:" << endl;
1914 for (queryctrl.id = V4L2_CID_PRIVATE_BASE; ; queryctrl.id++)
1916 if (v4l2_ioctl(_dev, VIDIOC_QUERYCTRL, &queryctrl))
1918 if (errno == EINVAL)
break;
1920 cout <<
"Private Control query failed" << endl;
1924 if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)
continue;
1926 cout <<
" + " << queryctrl.name <<
" [" <<
1927 (queryctrl.id - V4L2_CID_PRIVATE_BASE) <<
"] (";
1928 switch (queryctrl.type)
1930 case V4L2_CTRL_TYPE_INTEGER:
1931 cout <<
"int [" << queryctrl.minimum <<
"-" << queryctrl.maximum <<
1932 " /" << queryctrl.step <<
" def " << queryctrl.default_value <<
1936 case V4L2_CTRL_TYPE_MENU:
1937 cout <<
"menu [def " << queryctrl.default_value <<
"]";
1940 case V4L2_CTRL_TYPE_BOOLEAN:
1941 cout <<
"bool [def " << queryctrl.default_value <<
"]";
1944 case V4L2_CTRL_TYPE_BUTTON:
1948 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) 1949 case V4L2_CTRL_TYPE_INTEGER64:
1953 case V4L2_CTRL_TYPE_CTRL_CLASS:
1954 cout <<
"ctrl_class";
1957 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) 1958 case V4L2_CTRL_TYPE_STRING:
1962 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,41) 1963 case V4L2_CTRL_TYPE_BITMASK:
1968 cout <<
")" << endl;
1970 if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
1972 cout <<
" |- Menu items:" << endl;
1974 memset(&querymenu, 0,
sizeof(querymenu));
1975 querymenu.id = queryctrl.id;
1977 for (querymenu.index = queryctrl.minimum;
1978 querymenu.index <= static_cast<unsigned long int>(queryctrl.maximum);
1981 if (v4l2_ioctl(_dev, VIDIOC_QUERYMENU, &querymenu))
1983 cout <<
"Getting menu items failed" << endl;
1986 cout <<
" | + " << querymenu.name << endl;
1990 if (queryctrl.id == V4L2_CID_PRIVATE_BASE) cout <<
"None" << endl;
1993 "=========================================================================="
Called method has not been implemented.
A class for handling time.
bool has(std::string s) const
Check if an parameter was given.
Base class for exceptions in Fawkes.
std::string get(std::string s) const
Get the value of the given parameter.
Expected parameter is missing.