|
|
|
@ -67,10 +67,11 @@ class CvCapture_Images : public CvCapture |
|
|
|
|
public: |
|
|
|
|
CvCapture_Images() |
|
|
|
|
{ |
|
|
|
|
filename = 0; |
|
|
|
|
filename = NULL; |
|
|
|
|
currentframe = firstframe = 0; |
|
|
|
|
length = 0; |
|
|
|
|
frame = 0; |
|
|
|
|
frame = NULL; |
|
|
|
|
grabbedInOpen = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual ~CvCapture_Images() |
|
|
|
@ -92,6 +93,7 @@ protected: |
|
|
|
|
unsigned length; // length of sequence
|
|
|
|
|
|
|
|
|
|
IplImage* frame; |
|
|
|
|
bool grabbedInOpen; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -100,7 +102,7 @@ void CvCapture_Images::close() |
|
|
|
|
if( filename ) |
|
|
|
|
{ |
|
|
|
|
free(filename); |
|
|
|
|
filename = 0; |
|
|
|
|
filename = NULL; |
|
|
|
|
} |
|
|
|
|
currentframe = firstframe = 0; |
|
|
|
|
length = 0; |
|
|
|
@ -113,17 +115,25 @@ bool CvCapture_Images::grabFrame() |
|
|
|
|
char str[_MAX_PATH]; |
|
|
|
|
sprintf(str, filename, firstframe + currentframe); |
|
|
|
|
|
|
|
|
|
if (grabbedInOpen) |
|
|
|
|
{ |
|
|
|
|
grabbedInOpen = false; |
|
|
|
|
++currentframe; |
|
|
|
|
|
|
|
|
|
return frame != NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cvReleaseImage(&frame); |
|
|
|
|
frame = cvLoadImage(str, CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR); |
|
|
|
|
if( frame ) |
|
|
|
|
currentframe++; |
|
|
|
|
|
|
|
|
|
return frame != 0; |
|
|
|
|
return frame != NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IplImage* CvCapture_Images::retrieveFrame(int) |
|
|
|
|
{ |
|
|
|
|
return frame; |
|
|
|
|
return grabbedInOpen ? NULL : frame; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
double CvCapture_Images::getProperty(int id) |
|
|
|
@ -166,6 +176,8 @@ bool CvCapture_Images::setProperty(int id, double value) |
|
|
|
|
value = length - 1; |
|
|
|
|
} |
|
|
|
|
currentframe = cvRound(value); |
|
|
|
|
if (currentframe != 0) |
|
|
|
|
grabbedInOpen = false; // grabbed frame is not valid anymore
|
|
|
|
|
return true; |
|
|
|
|
case CV_CAP_PROP_POS_AVI_RATIO: |
|
|
|
|
if(value > 1) { |
|
|
|
@ -176,6 +188,8 @@ bool CvCapture_Images::setProperty(int id, double value) |
|
|
|
|
value = 0; |
|
|
|
|
} |
|
|
|
|
currentframe = cvRound((length - 1) * value); |
|
|
|
|
if (currentframe != 0) |
|
|
|
|
grabbedInOpen = false; // grabbed frame is not valid anymore
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
CV_WARN("unknown/unhandled property\n"); |
|
|
|
@ -278,7 +292,13 @@ bool CvCapture_Images::open(const char * _filename) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
firstframe = offset; |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
// grab frame to enable properties retrieval
|
|
|
|
|
bool grabRes = grabFrame(); |
|
|
|
|
grabbedInOpen = true; |
|
|
|
|
currentframe = 0; |
|
|
|
|
|
|
|
|
|
return grabRes; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -290,7 +310,7 @@ CvCapture* cvCreateFileCapture_Images(const char * filename) |
|
|
|
|
return capture; |
|
|
|
|
|
|
|
|
|
delete capture; |
|
|
|
|
return 0; |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|