diff --git a/modules/highgui/src/cap_libv4l.cpp b/modules/highgui/src/cap_libv4l.cpp index 04b07bb744..54cc351128 100644 --- a/modules/highgui/src/cap_libv4l.cpp +++ b/modules/highgui/src/cap_libv4l.cpp @@ -1261,9 +1261,11 @@ static IplImage* icvRetrieveFrameCAM_V4L( CvCaptureCAM_V4L* capture, int) { if (capture->is_v4l2_device == 1) { - memcpy((char *)capture->frame.imageData, - (char *)capture->buffers[capture->bufferIndex].start, - capture->frame.imageSize); + if(capture->buffers[capture->bufferIndex].start){ + memcpy((char *)capture->frame.imageData, + (char *)capture->buffers[capture->bufferIndex].start, + capture->frame.imageSize); + } } else #endif /* HAVE_CAMV4L2 */ diff --git a/samples/cpp/calibration.cpp b/samples/cpp/calibration.cpp index 6de2b0ea9d..cbcd5b0408 100644 --- a/samples/cpp/calibration.cpp +++ b/samples/cpp/calibration.cpp @@ -404,22 +404,27 @@ int main( int argc, char** argv ) flip( view, view, 0 ); vector pointbuf; - bool found = findChessboardCorners( view, boardSize, pointbuf, CV_CALIB_CB_ADAPTIVE_THRESH ); - - // improve the found corners' coordinate accuracy - cvtColor(view, viewGray, CV_BGR2GRAY); - if(found) cornerSubPix( viewGray, pointbuf, Size(11,11), - Size(-1,-1), TermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1 )); - - if( mode == CAPTURING && found && - (!capture.isOpened() || clock() - prevTimestamp > delay*1e-3*CLOCKS_PER_SEC) ) - { - imagePoints.push_back(pointbuf); - prevTimestamp = clock(); - blink = capture.isOpened(); - } - - if(found) drawChessboardCorners( view, boardSize, Mat(pointbuf), found ); + + + cvtColor(view, viewGray, CV_BGR2GRAY); + + + bool found = findChessboardCorners( view, boardSize, pointbuf, CV_CALIB_CB_ADAPTIVE_THRESH & CV_CALIB_CB_FAST_CHECK & CV_CALIB_CB_NORMALIZE_IMAGE); + + // improve the found corners' coordinate accuracy + if(found) cornerSubPix( viewGray, pointbuf, Size(11,11), + Size(-1,-1), TermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1 )); + + if( mode == CAPTURING && found && + (!capture.isOpened() || clock() - prevTimestamp > delay*1e-3*CLOCKS_PER_SEC) ) + { + imagePoints.push_back(pointbuf); + prevTimestamp = clock(); + blink = capture.isOpened(); + } + if(found) drawChessboardCorners( view, boardSize, Mat(pointbuf), found ); + + string msg = mode == CAPTURING ? "100/100" : mode == CALIBRATED ? "Calibrated" : "Press 'g' to start";