mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -359,7 +359,7 @@ struct CvCaptureCAM_V4L CV_FINAL : public CvCapture
|
||||
bool initCapture();
|
||||
bool streaming(bool startStream);
|
||||
bool setFps(int value);
|
||||
bool tryIoctl(unsigned long ioctlCode, void *parameter) const;
|
||||
bool tryIoctl(unsigned long ioctlCode, void *parameter, bool failIfBusy = true, int attempts = 10) const;
|
||||
bool controlInfo(int property_id, __u32 &v4l2id, cv::Range &range) const;
|
||||
bool icvControl(__u32 v4l2id, int &value, bool isSet) const;
|
||||
|
||||
@@ -415,10 +415,10 @@ bool CvCaptureCAM_V4L::try_palette_v4l2()
|
||||
form.fmt.pix.field = V4L2_FIELD_ANY;
|
||||
form.fmt.pix.width = width;
|
||||
form.fmt.pix.height = height;
|
||||
|
||||
if (!tryIoctl(VIDIOC_S_FMT, &form))
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
return palette == form.fmt.pix.pixelformat;
|
||||
}
|
||||
|
||||
@@ -490,6 +490,8 @@ bool CvCaptureCAM_V4L::autosetup_capture_mode_v4l2()
|
||||
//in case palette is already set and works, no need to setup.
|
||||
if (palette != 0 && try_palette_v4l2()) {
|
||||
return true;
|
||||
} else if (errno == EBUSY) {
|
||||
return false;
|
||||
}
|
||||
__u32 try_order[] = {
|
||||
V4L2_PIX_FMT_BGR24,
|
||||
@@ -646,7 +648,9 @@ bool CvCaptureCAM_V4L::initCapture()
|
||||
}
|
||||
|
||||
if (!autosetup_capture_mode_v4l2()) {
|
||||
fprintf(stderr, "VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV\n");
|
||||
if (errno != EBUSY) {
|
||||
fprintf(stderr, "VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV\n");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -866,11 +870,22 @@ bool CvCaptureCAM_V4L::read_frame_v4l2()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CvCaptureCAM_V4L::tryIoctl(unsigned long ioctlCode, void *parameter) const
|
||||
bool CvCaptureCAM_V4L::tryIoctl(unsigned long ioctlCode, void *parameter, bool failIfBusy, int attempts) const
|
||||
{
|
||||
CV_LOG_DEBUG(NULL, "tryIoctl(handle=" << deviceHandle << ", ioctl=0x" << std::hex << ioctlCode << ", ...)")
|
||||
CV_LOG_DEBUG(NULL, "tryIoctl(handle=" << deviceHandle << ", ioctl=0x" << std::hex << ioctlCode << ", ...)");
|
||||
if (attempts == 0) {
|
||||
return false;
|
||||
}
|
||||
while (-1 == ioctl(deviceHandle, ioctlCode, parameter)) {
|
||||
if (!(errno == EBUSY || errno == EAGAIN))
|
||||
const bool isBusy = (errno == EBUSY);
|
||||
if (isBusy & failIfBusy) {
|
||||
return false;
|
||||
}
|
||||
if ((attempts > 0) && (--attempts == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(isBusy || errno == EAGAIN))
|
||||
return false;
|
||||
|
||||
fd_set fds;
|
||||
|
||||
Reference in New Issue
Block a user