reverted the original VideoCapture::read() code; moved frame index check to where it should belong: ffmpeg wrapper; applied patch by Rob Reilink (ticket #1971)
This commit is contained in:
parent
586d5a6024
commit
677680d82d
@ -494,15 +494,8 @@ bool VideoCapture::retrieve(Mat& image, int channel)
|
|||||||
|
|
||||||
bool VideoCapture::read(Mat& image)
|
bool VideoCapture::read(Mat& image)
|
||||||
{
|
{
|
||||||
double frame_pos = get(CV_CAP_PROP_POS_FRAMES);
|
if(grab())
|
||||||
double frame_count = get(CV_CAP_PROP_FRAME_COUNT);
|
retrieve(image);
|
||||||
if (frame_pos < frame_count || frame_pos < 0 || frame_count < 0)
|
|
||||||
{
|
|
||||||
if(grab())
|
|
||||||
retrieve(image);
|
|
||||||
else
|
|
||||||
image.release();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
image.release();
|
image.release();
|
||||||
return !image.empty();
|
return !image.empty();
|
||||||
|
@ -438,6 +438,10 @@ bool CvCapture_FFMPEG::grabFrame()
|
|||||||
const int max_number_of_attempts = 1 << 16;
|
const int max_number_of_attempts = 1 << 16;
|
||||||
|
|
||||||
if( !ic || !video_st ) return false;
|
if( !ic || !video_st ) return false;
|
||||||
|
|
||||||
|
if( ic->streams[video_stream]->nb_frames > 0 &&
|
||||||
|
frame_number > ic->streams[video_stream]->nb_frames )
|
||||||
|
return false;
|
||||||
|
|
||||||
av_free_packet (&packet);
|
av_free_packet (&packet);
|
||||||
|
|
||||||
|
@ -316,7 +316,9 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) {
|
|||||||
capture = [[CaptureDelegate alloc] init];
|
capture = [[CaptureDelegate alloc] init];
|
||||||
|
|
||||||
QTCaptureDevice *device;
|
QTCaptureDevice *device;
|
||||||
NSArray* devices = [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo];
|
NSArray* devices = [[[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo]
|
||||||
|
arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]] retain];
|
||||||
|
|
||||||
if ([devices count] == 0) {
|
if ([devices count] == 0) {
|
||||||
cout << "QTKit didn't find any attached Video Input Devices!" << endl;
|
cout << "QTKit didn't find any attached Video Input Devices!" << endl;
|
||||||
[localpool drain];
|
[localpool drain];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user