30 #include <opencv2/core/core.hpp>
31 #include <opencv2/imgproc/imgproc.hpp>
32 #include <opencv2/core/core_c.h>
40 struct timeval epochtime;
41 struct timespec vsTime;
43 gettimeofday(&epochtime,
nullptr);
44 clock_gettime(CLOCK_MONOTONIC, &vsTime);
46 double uptime = vsTime.tv_sec + vsTime.tv_nsec / 1000000000.0;
47 double epoch = epochtime.tv_sec + epochtime.tv_usec / 1000000.0;
48 return epoch - uptime;
54 if (config.
check(key)) {
61 #define NOT_PRESENT -1
62 int V4L_camera::convertYARP_to_V4L(
int feature)
66 return V4L2_CID_BRIGHTNESS;
69 return V4L2_CID_EXPOSURE;
71 return V4L2_CID_SHARPNESS;
75 return V4L2_CID_SATURATION;
77 return V4L2_CID_GAMMA;
81 return V4L2_CID_IRIS_ABSOLUTE;
135 use_exposure_absolute =
false;
145 configIntrins =
false;
149 pixel_fmt_leo = V4L2_PIX_FMT_SGRBG8;
159 int V4L_camera::convertV4L_to_YARP_format(
int format)
162 case V4L2_PIX_FMT_GREY:
164 case V4L2_PIX_FMT_Y16:
166 case V4L2_PIX_FMT_RGB24:
169 case V4L2_PIX_FMT_BGR24:
171 case V4L2_PIX_FMT_SGRBG8:
173 case V4L2_PIX_FMT_SBGGR8:
175 case V4L2_PIX_FMT_SBGGR16:
177 case V4L2_PIX_FMT_SGBRG8:
179 case V4L2_PIX_FMT_SRGGB8:
181 case V4L2_PIX_FMT_YUV420:
183 case V4L2_PIX_FMT_YUV444:
185 case V4L2_PIX_FMT_YYUV:
187 case V4L2_PIX_FMT_YUV411P:
193 void V4L_camera::populateConfigurations()
195 struct v4l2_fmtdesc fmt;
196 struct v4l2_frmsizeenum frmsize;
197 struct v4l2_frmivalenum frmival;
200 fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
202 while (ioctl(param.
fd, VIDIOC_ENUM_FMT, &fmt) >= 0) {
203 memset(&frmsize, 0,
sizeof(v4l2_frmsizeenum));
204 frmsize.pixel_format = fmt.pixelformat;
206 frmsize.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
207 while (xioctl(param.
fd, VIDIOC_ENUM_FRAMESIZES, &frmsize) >= 0) {
208 if (frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
209 memset(&frmival, 0,
sizeof(v4l2_frmivalenum));
211 frmival.pixel_format = fmt.pixelformat;
212 frmival.width = frmsize.discrete.width;
213 frmival.height = frmsize.discrete.height;
214 frmsize.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
215 while (xioctl(param.
fd, VIDIOC_ENUM_FRAMEINTERVALS, &frmival) >= 0) {
218 c.
width = frmival.width;
219 c.
height = frmival.height;
220 c.
framerate = (1.0 * frmival.discrete.denominator) / frmival.discrete.numerator;
240 if (!fromConfig(config)) {
251 if (!S_ISCHR(st.st_mode)) {
257 param.
fd = v4l2_open(param.
deviceId.c_str(), O_RDWR | O_NONBLOCK, 0);
260 if (-1 == param.
fd) {
268 v4l2_close(param.
fd);
272 param.
fd = v4l2_open(param.
deviceId.c_str(), O_RDWR | O_NONBLOCK, 0);
275 if (-1 == param.
fd) {
284 enumerate_controls();
286 if (!check_V4L2_control(V4L2_CID_EXPOSURE)) {
287 use_exposure_absolute = check_V4L2_control(V4L2_CID_EXPOSURE_ABSOLUTE);
293 populateConfigurations();
301 if (!white_balance.
isNull()) {
342 bool res = deviceInit();
352 return configFx && configFy;
364 return configIntrins;
370 mirror = (ioctl(param.
fd, V4L2_CID_HFLIP) != 0);
376 int ret = ioctl(param.
fd, V4L2_CID_HFLIP, &mirror);
378 yCError(
USBCAMERA) <<
"V4L2_CID_HFLIP - Unable to mirror image-" << strerror(errno);
386 if (config.
check(
"verbose")) {
390 if (!config.
check(
"width")) {
397 if (!config.
check(
"height")) {
404 if (!config.
check(
"framerate")) {
411 if (!config.
check(
"d")) {
412 yCError(
USBCAMERA) <<
"No camera identifier was specified! (e.g. '--d /dev/video0' on Linux OS)";
419 if (!config.
check(
"camModel")) {
420 yCInfo(
USBCAMERA) <<
"No 'camModel' was specified, working with 'standard' uvc";
423 std::map<std::string, supported_cams>::iterator it = camMap.find(config.
find(
"camModel").
asString());
424 if (it != camMap.end()) {
430 for (it = camMap.begin(); it != camMap.end(); it++) {
439 yCDebug(
USBCAMERA) <<
"-------------------------------\nusbCamera: Using leopard camera!!";
440 bit_shift = config.
check(
"shift",
Value(bit_shift),
"right shift of <n> bits").asInt32();
441 bit_bayer = config.
check(
"bit_bayer",
Value(bit_bayer),
"uses <n> bits bayer conversion").asInt32();
444 pixel_fmt_leo = V4L2_PIX_FMT_SGRBG8;
448 pixel_fmt_leo = V4L2_PIX_FMT_SGRBG10;
452 pixel_fmt_leo = V4L2_PIX_FMT_SGRBG12;
456 yCError(
USBCAMERA) <<
"bayer conversion with " << bit_bayer <<
"not supported";
461 yCDebug(
USBCAMERA) << bit_shift <<
"bits of right shift applied to raw data";
466 if (config.
check(
"crop")) {
473 Value isDual = config.
check(
"dual",
Value(0),
"Is this a dual camera? Two cameras merged into a single frame");
483 if (!config.
check(
"pixelType")) {
494 param.
pixelType = convertV4L_to_YARP_format(param.
src_fmt.fmt.pix.pixelformat);
503 yCError(
USBCAMERA,
"no valid pixel format found!! This should not happen!!");
508 retM = Value::makeList(
"1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0");
509 configFx = config.
check(
"horizontalFov");
510 configFy = config.
check(
"verticalFov");
511 configPPx = config.
check(
"principalPointX");
512 configPPy = config.
check(
"principalPointY");
513 configRet = config.
check(
"retificationMatrix");
514 configDistM = config.
check(
"distortionModel");
516 bt = config.
findGroup(
"cameraDistortionModelGroup");
522 "fields k1, k2, k3, t1, t2, name are required when using cameraDistortionModelGroup";
523 configIntrins =
false;
527 configIntrins =
true;
530 configIntrins =
false;
532 param.
horizontalFov = config.
check(
"horizontalFov",
Value(0.0),
"desired horizontal fov of test image").asFloat64();
533 param.
verticalFov = config.
check(
"verticalFov",
Value(0.0),
"desired vertical fov of test image").asFloat64();
534 if (config.
check(
"mirror")) {
537 "mirroring disabled by default")
544 param.
intrinsic.
put(
"focalLengthX", config.
check(
"focalLengthX",
Value(0.0),
"Horizontal component of the focal lenght").asFloat64());
545 param.
intrinsic.
put(
"focalLengthY", config.
check(
"focalLengthY",
Value(0.0),
"Vertical component of the focal lenght").asFloat64());
546 param.
intrinsic.
put(
"principalPointX", config.
check(
"principalPointX",
Value(0.0),
"X coordinate of the principal point").asFloat64());
547 param.
intrinsic.
put(
"principalPointY", config.
check(
"principalPointY",
Value(0.0),
"Y coordinate of the principal point").asFloat64());
548 param.
intrinsic.
put(
"retificationMatrix", config.
check(
"retificationMatrix", *retM,
"Matrix that describes the lens' distortion"));
549 param.
intrinsic.
put(
"distortionModel", config.
check(
"distortionModel",
Value(
""),
"Reference to group of parameters describing the distortion model of the camera").asString());
559 param.
intrinsic.
put(
"k1", bt.
check(
"k1",
Value(0.0),
"Radial distortion coefficient of the lens").asFloat64());
560 param.
intrinsic.
put(
"k2", bt.
check(
"k2",
Value(0.0),
"Radial distortion coefficient of the lens").asFloat64());
561 param.
intrinsic.
put(
"k3", bt.
check(
"k3",
Value(0.0),
"Radial distortion coefficient of the lens").asFloat64());
571 int V4L_camera::getfd()
576 bool V4L_camera::threadInit()
585 void V4L_camera::run()
587 if (full_FrameRead()) {
594 if ((timeElapsed = timeNow - timeStart) > 1.0f) {
595 yCInfo(
USBCAMERA,
"frames acquired %d in %f sec", frameCounter, timeElapsed);
601 void V4L_camera::threadRelease()
610 bool V4L_camera::deviceInit()
612 struct v4l2_capability cap;
613 struct v4l2_cropcap cropcap;
614 struct v4l2_crop crop;
615 struct v4l2_streamparm frameint;
618 if (-1 == xioctl(param.
fd, VIDIOC_QUERYCAP, &cap)) {
619 if (EINVAL == errno) {
629 if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
638 if (!(cap.capabilities & V4L2_CAP_READWRITE)) {
646 if (!(cap.capabilities & V4L2_CAP_STREAMING)) {
659 cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
661 if (0 == xioctl(param.
fd, VIDIOC_CROPCAP, &cropcap)) {
662 crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
663 crop.c = cropcap.defrect;
668 xioctl(param.
fd, VIDIOC_S_CROP, &crop);
674 _v4lconvert_data = v4lconvert_create(param.
fd);
675 if (_v4lconvert_data ==
nullptr) {
676 yCError(
USBCAMERA) <<
"Failed to initialize v4lconvert. Conversion to required format may not work";
695 param.
dst_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
698 param.
dst_fmt.fmt.pix.field = V4L2_FIELD_NONE;
701 if (v4lconvert_try_format(_v4lconvert_data, &(param.
dst_fmt), &(param.
src_fmt)) != 0) {
702 yCError(
USBCAMERA,
"v4lconvert_try_format -> Error is: %s", v4lconvert_get_error_message(_v4lconvert_data));
710 yCWarning(
USBCAMERA) <<
"Conversion from HW supported configuration into user requested format will require addictional step.\n"
711 <<
"Performance issue may arise.";
717 double inputFF = (double)param.
dst_fmt.fmt.pix.width / (
double)param.
dst_fmt.fmt.pix.height;
720 if (outputFF < inputFF) {
754 if (-1 == xioctl(param.
fd, VIDIOC_S_FMT, ¶m.
src_fmt)) {
760 if (param.
fps != -1) {
764 frameint.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
765 frameint.parm.capture.timeperframe.numerator = 1;
766 frameint.parm.capture.timeperframe.denominator = param.
fps;
767 if (-1 == xioctl(param.
fd, VIDIOC_S_PARM, &frameint)) {
795 readInit(param.
src_fmt.fmt.pix.sizeimage);
803 userptrInit(param.
src_fmt.fmt.pix.sizeimage);
815 bool V4L_camera::deviceUninit()
836 param.
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
837 param.
req.memory = V4L2_MEMORY_MMAP;
838 if (xioctl(param.
fd, VIDIOC_REQBUFS, ¶m.
req) < 0) {
839 yCError(
USBCAMERA,
"VIDIOC_REQBUFS - Failed to delete buffers: %s (errno %d)", strerror(errno), errno);
852 if (param.
buffers !=
nullptr) {
872 v4lconvert_destroy(_v4lconvert_data);
888 if (param.
fd != -1) {
892 if (-1 == v4l2_close(param.
fd)) {
982 int V4L_camera::xioctl(
int fd,
int request,
void* argp)
987 r = v4l2_ioctl(fd, request, argp);
988 }
while (-1 == r && EINTR == errno);
1000 void V4L_camera::enumerate_menu()
1008 if (0 == ioctl(param.
fd, VIDIOC_QUERYMENU, &
querymenu)) {
1018 bool V4L_camera::enumerate_controls()
1023 if (0 == ioctl(param.
fd, VIDIOC_QUERYCTRL, &
queryctrl)) {
1024 if (
queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
1030 if (
queryctrl.type == V4L2_CTRL_TYPE_MENU) {
1034 if (errno == EINVAL) {
1044 if (0 == ioctl(param.
fd, VIDIOC_QUERYCTRL, &
queryctrl)) {
1045 if (
queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
1051 if (
queryctrl.type == V4L2_CTRL_TYPE_MENU) {
1055 if (errno == EINVAL) {
1069 bool V4L_camera::full_FrameRead()
1071 bool got_it =
false;
1072 void* image_ret =
nullptr;
1074 unsigned int numberOfTimeouts;
1080 numberOfTimeouts = 0;
1084 for (
unsigned int i = 0; i < count; i++) {
1086 FD_SET(param.
fd, &fds);
1092 r = select(param.
fd + 1, &fds,
nullptr,
nullptr, &tv);
1095 if (EINTR == errno) {
1099 return image_ret !=
nullptr;
1104 yCWarning(
USBCAMERA,
"timeout while reading image [%d/%d]", numberOfTimeouts, count);
1107 }
else if ((r > 0) && (FD_ISSET(param.
fd, &fds))) {
1127 bool V4L_camera::frameRead()
1130 struct v4l2_buffer buf;
1140 timeStamp.
update(toEpochOffset + buf.timestamp.tv_sec + buf.timestamp.tv_usec / 1000000.0);
1148 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1149 buf.memory = V4L2_MEMORY_MMAP;
1151 if (-1 == xioctl(param.
fd, VIDIOC_DQBUF, &buf)) {
1164 timeStamp.
update(toEpochOffset + buf.timestamp.tv_sec + buf.timestamp.tv_usec / 1000000.0);
1166 if (-1 == xioctl(param.
fd, VIDIOC_QBUF, &buf)) {
1177 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1178 buf.memory = V4L2_MEMORY_USERPTR;
1180 if (-1 == xioctl(param.
fd, VIDIOC_DQBUF, &buf)) {
1198 timeStamp.
update(toEpochOffset + buf.timestamp.tv_sec + buf.timestamp.tv_usec / 1000000.0);
1201 if (-1 == xioctl(param.
fd, VIDIOC_QBUF, &buf)) {
1218 void V4L_camera::imagePreProcess()
1225 const uint _pixelNum = param.
src_fmt.fmt.pix.width * param.
src_fmt.fmt.pix.height;
1227 uint16_t* raw_p = (uint16_t*)param.
raw_image;
1228 for (uint i = 0; i < _pixelNum; i++) {
1229 param.
src_image[i] = (
unsigned char)(raw_p[i] >> bit_shift);
1233 param.
src_fmt.fmt.pix.bytesperline = param.
src_fmt.fmt.pix.width;
1234 param.
src_fmt.fmt.pix.pixelformat = pixel_fmt_leo;
1247 void V4L_camera::imageProcess()
1249 static bool initted =
false;
1258 if (v4lconvert_convert((v4lconvert_data*)_v4lconvert_data,
1266 if ((err % 20) == 0) {
1267 yCError(
USBCAMERA,
"error converting \n\t Error message is: %s", v4lconvert_get_error_message(_v4lconvert_data));
1287 cv::resize(img(crop2), img_right, cvSize(param.
user_width / 2, param.
user_height), 0, 0, cv::INTER_CUBIC);
1303 timeTot += timeElapsed;
1305 if ((myCounter % 60) == 0) {
1317 void V4L_camera::captureStop()
1320 int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1328 ret = xioctl(param.
fd, VIDIOC_STREAMOFF, &type);
1331 yCError(
USBCAMERA,
"VIDIOC_STREAMOFF - Unable to stop capture: %d, %s", errno, strerror(errno));
1341 void V4L_camera::captureStart()
1344 enum v4l2_buf_type type;
1353 struct v4l2_buffer buf;
1356 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1357 buf.memory = V4L2_MEMORY_MMAP;
1360 if (-1 == xioctl(param.
fd, VIDIOC_QBUF, &buf)) {
1365 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1367 if (-1 == xioctl(param.
fd, VIDIOC_STREAMON, &type)) {
1375 struct v4l2_buffer buf;
1379 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1380 buf.memory = V4L2_MEMORY_USERPTR;
1385 if (-1 == xioctl(param.
fd, VIDIOC_QBUF, &buf)) {
1390 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1392 if (-1 == xioctl(param.
fd, VIDIOC_STREAMON, &type)) {
1401 bool V4L_camera::readInit(
unsigned int buffer_size)
1405 if (param.
buffers ==
nullptr) {
1420 bool V4L_camera::mmapInit()
1426 param.
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1427 param.
req.memory = V4L2_MEMORY_MMAP;
1429 if (-1 == xioctl(param.
fd, VIDIOC_REQBUFS, ¶m.
req)) {
1430 if (EINVAL == errno) {
1438 if (param.
req.count < 1) {
1443 if (param.
req.count == 1) {
1444 yCError(
USBCAMERA,
"Only 1 buffer was available, you may encounter performance issue acquiring images from device %s", param.
deviceId.c_str());
1449 if (param.
buffers ==
nullptr) {
1454 struct v4l2_buffer buf;
1459 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1460 buf.memory = V4L2_MEMORY_MMAP;
1463 if (-1 == xioctl(param.
fd, VIDIOC_QUERYBUF, &buf)) {
1468 param.
buffers[param.
n_buffers].
start = v4l2_mmap(
nullptr, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, param.
fd, buf.m.offset);
1477 bool V4L_camera::userptrInit(
unsigned int buffer_size)
1479 unsigned int page_size;
1481 page_size = getpagesize();
1482 buffer_size = (buffer_size + page_size - 1) & ~(page_size - 1);
1487 param.
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1488 param.
req.memory = V4L2_MEMORY_USERPTR;
1490 if (-1 == xioctl(param.
fd, VIDIOC_REQBUFS, ¶m.
req)) {
1491 if (EINVAL == errno) {
1501 if (param.
buffers ==
nullptr) {
1518 bool V4L_camera::set_V4L2_control(uint32_t
id,
double value,
bool verbatim)
1525 struct v4l2_control control;
1530 if (-1 == ioctl(param.
fd, VIDIOC_QUERYCTRL, &
queryctrl)) {
1531 if (errno != EINVAL) {
1539 if (
queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
1543 memset(&control, 0,
sizeof(control));
1546 control.value = value;
1549 if ((V4L2_CID_EXPOSURE ==
id) || (V4L2_CID_EXPOSURE_ABSOLUTE ==
id) || (V4L2_CID_EXPOSURE_AUTO ==
id)) {
1556 if (-1 == ioctl(param.
fd, VIDIOC_S_CTRL, &control)) {
1558 if (errno == ERANGE) {
1559 yCError(
USBCAMERA,
"Normalized input value %f ( equivalent to raw value of %d) was out of range for control %s: Min and Max are: %d - %d", value, control.value,
queryctrl.name,
queryctrl.minimum,
queryctrl.maximum);
1570 bool V4L_camera::check_V4L2_control(uint32_t
id)
1574 struct v4l2_control control;
1576 memset(&control, 0,
sizeof(control));
1582 if (-1 == ioctl(param.
fd, VIDIOC_QUERYCTRL, &
queryctrl)) {
1583 if (errno != EINVAL) {
1591 double V4L_camera::get_V4L2_control(uint32_t
id,
bool verbatim)
1594 struct v4l2_control control;
1596 memset(&control, 0,
sizeof(control));
1602 if (-1 == ioctl(param.
fd, VIDIOC_QUERYCTRL, &
queryctrl)) {
1603 if (errno != EINVAL) {
1610 if (
queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
1613 if (-1 == ioctl(param.
fd, VIDIOC_G_CTRL, &control)) {
1619 return control.value;
1623 if ((V4L2_CID_EXPOSURE ==
id) || (V4L2_CID_EXPOSURE_ABSOLUTE ==
id) || (V4L2_CID_EXPOSURE_AUTO ==
id)) {
1641 bool tmpAuto(
false);
1642 bool tmpOnce(
false);
1646 tmpMan = check_V4L2_control(V4L2_CID_RED_BALANCE) && check_V4L2_control(V4L2_CID_BLUE_BALANCE);
1647 tmpOnce = check_V4L2_control(V4L2_CID_DO_WHITE_BALANCE);
1648 tmpAuto = check_V4L2_control(V4L2_CID_AUTO_WHITE_BALANCE);
1652 tmpMan = check_V4L2_control(V4L2_CID_EXPOSURE) || check_V4L2_control(V4L2_CID_EXPOSURE_ABSOLUTE);
1653 tmpAuto = check_V4L2_control(V4L2_CID_EXPOSURE_AUTO);
1657 tmpMan = check_V4L2_control(convertYARP_to_V4L(feature));
1661 *_hasFeature = tmpMan || tmpOnce || tmpAuto;
1670 if (use_exposure_absolute) {
1671 ret = set_V4L2_control(V4L2_CID_EXPOSURE_ABSOLUTE, value);
1673 ret = set_V4L2_control(V4L2_CID_EXPOSURE, value);
1678 ret = set_V4L2_control(convertYARP_to_V4L(feature), value);
1689 if (use_exposure_absolute) {
1690 tmp = get_V4L2_control(V4L2_CID_EXPOSURE_ABSOLUTE);
1692 tmp = get_V4L2_control(V4L2_CID_EXPOSURE);
1697 tmp = get_V4L2_control(convertYARP_to_V4L(feature));
1713 ret &= set_V4L2_control(V4L2_CID_AUTO_WHITE_BALANCE,
false);
1714 ret &= set_V4L2_control(V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE, V4L2_WHITE_BALANCE_MANUAL);
1715 ret &= set_V4L2_control(V4L2_CID_RED_BALANCE, value1);
1716 ret &= set_V4L2_control(V4L2_CID_BLUE_BALANCE, value2);
1725 *value1 = get_V4L2_control(V4L2_CID_RED_BALANCE);
1726 *value2 = get_V4L2_control(V4L2_CID_BLUE_BALANCE);
1727 return !((*value1 == -1) || (*value2 == -1));
1740 if (
hasAuto(feature, &_hasAuto)) {
1766 tmp = set_V4L2_control(V4L2_CID_AUTO_WHITE_BALANCE, onoff);
1768 isActive_vector[feature] = onoff;
1774 set_V4L2_control(V4L2_LOCK_EXPOSURE,
false);
1778 tmp = set_V4L2_control(V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_AUTO);
1780 tmp = set_V4L2_control(V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL);
1784 isActive_vector[feature] = onoff;
1787 bool man = set_V4L2_control(V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL);
1789 man = set_V4L2_control(V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_SHUTTER_PRIORITY,
true);
1794 set_V4L2_control(V4L2_LOCK_EXPOSURE,
true);
1795 isActive_vector[feature] = onoff;
1801 isActive_vector[feature] =
true;
1804 isActive_vector[feature] =
false;
1815 double tmp = get_V4L2_control(V4L2_CID_AUTO_WHITE_BALANCE);
1826 bool _hasMan(
false);
1827 bool _hasMan2(
false);
1829 double _hasAuto = get_V4L2_control(V4L2_CID_EXPOSURE_AUTO,
true);
1831 *_isActive = (_hasAuto == V4L2_EXPOSURE_AUTO) || _hasMan || _hasMan2;
1847 *_hasAuto = check_V4L2_control(V4L2_CID_AUTO_WHITE_BALANCE);
1851 *_hasAuto = check_V4L2_control(V4L2_CID_AUTOBRIGHTNESS);
1855 *_hasAuto = check_V4L2_control(V4L2_CID_AUTOGAIN);
1859 *_hasAuto = check_V4L2_control(V4L2_CID_EXPOSURE_AUTO);
1863 *_hasAuto = check_V4L2_control(V4L2_CID_HUE_AUTO);
1876 *_hasManual = check_V4L2_control(V4L2_CID_RED_BALANCE) && check_V4L2_control(V4L2_CID_BLUE_BALANCE);
1881 *_hasManual = check_V4L2_control(V4L2_CID_EXPOSURE) || check_V4L2_control(V4L2_CID_EXPOSURE_ABSOLUTE);
1892 *_hasOnePush = check_V4L2_control(V4L2_CID_DO_WHITE_BALANCE);
1896 *_hasOnePush =
false;
1908 ret = set_V4L2_control(V4L2_CID_AUTO_WHITE_BALANCE,
true);
1910 ret = set_V4L2_control(V4L2_CID_AUTO_WHITE_BALANCE,
false);
1916 hasAuto(V4L2_CID_EXPOSURE_AUTO, &_tmpAuto);
1920 ret = set_V4L2_control(V4L2_CID_EXPOSURE_AUTO,
true);
1922 ret = set_V4L2_control(V4L2_CID_EXPOSURE_AUTO,
false);
1932 ret = set_V4L2_control(V4L2_CID_AUTOGAIN,
true);
1935 ret = set_V4L2_control(V4L2_CID_AUTOGAIN,
false);
1946 ret = set_V4L2_control(V4L2_CID_AUTOBRIGHTNESS,
true);
1948 ret = set_V4L2_control(V4L2_CID_AUTOBRIGHTNESS,
false);
1958 ret = set_V4L2_control(V4L2_CID_HUE_AUTO,
true);
1960 ret = set_V4L2_control(V4L2_CID_HUE_AUTO,
false);
1965 yCError(
USBCAMERA) <<
"Feature " << feature <<
" does not support auto mode";
1977 double ret = get_V4L2_control(V4L2_CID_AUTO_WHITE_BALANCE);
1984 double ret = get_V4L2_control(V4L2_CID_EXPOSURE_AUTO);
1990 if (
ret == V4L2_EXPOSURE_MANUAL) {
2004 double ret = get_V4L2_control(V4L2_CID_AUTOBRIGHTNESS);
2015 double ret = get_V4L2_control(V4L2_CID_AUTOGAIN);
2026 double ret = get_V4L2_control(V4L2_CID_HUE_AUTO);
2042 return set_V4L2_control(V4L2_CID_DO_WHITE_BALANCE,
true);