mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 05:29:54 +08:00
return 0 from VideoCapture::read() when cannot connect to camera
This commit is contained in:
parent
fd1b66b37d
commit
688b4d9d7a
@ -1113,7 +1113,7 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
|
||||
default:
|
||||
/* display the error and stop processing */
|
||||
perror ("VIDIOC_DQBUF");
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1141,7 +1141,7 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void mainloop_v4l2(CvCaptureCAM_V4L* capture) {
|
||||
static int mainloop_v4l2(CvCaptureCAM_V4L* capture) {
|
||||
unsigned int count;
|
||||
|
||||
count = 1;
|
||||
@ -1175,10 +1175,14 @@ static void mainloop_v4l2(CvCaptureCAM_V4L* capture) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (read_frame_v4l2 (capture))
|
||||
break;
|
||||
int returnCode=read_frame_v4l2(capture);
|
||||
if (returnCode == -1)
|
||||
return -1;
|
||||
if (returnCode == 1)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) {
|
||||
@ -1246,7 +1250,7 @@ static int icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) {
|
||||
if (capture->is_v4l2_device == 1)
|
||||
{
|
||||
|
||||
mainloop_v4l2(capture);
|
||||
if(mainloop_v4l2(capture) == -1) return 0;
|
||||
|
||||
} else
|
||||
{
|
||||
|
@ -830,7 +830,7 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
|
||||
default:
|
||||
/* display the error and stop processing */
|
||||
perror ("VIDIOC_DQBUF");
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -852,7 +852,7 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void mainloop_v4l2(CvCaptureCAM_V4L* capture) {
|
||||
static int mainloop_v4l2(CvCaptureCAM_V4L* capture) {
|
||||
unsigned int count;
|
||||
|
||||
count = 1;
|
||||
@ -886,10 +886,14 @@ static void mainloop_v4l2(CvCaptureCAM_V4L* capture) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (read_frame_v4l2 (capture))
|
||||
int returnCode = read_frame_v4l2 (capture);
|
||||
if(returnCode == -1)
|
||||
return -1;
|
||||
if(returnCode == 1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) {
|
||||
@ -931,14 +935,15 @@ static bool icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) {
|
||||
#if defined(V4L_ABORT_BADJPEG)
|
||||
// skip first frame. it is often bad -- this is unnotied in traditional apps,
|
||||
// but could be fatal if bad jpeg is enabled
|
||||
mainloop_v4l2(capture);
|
||||
if(mainloop_v4l2(capture) == -1)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
/* preparation is ok */
|
||||
capture->FirstCapture = 0;
|
||||
}
|
||||
|
||||
mainloop_v4l2(capture);
|
||||
if(mainloop_v4l2(capture) == -1) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user