mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 19:20:28 +08:00
videoio: fix CAP_IMAGES with non-numbered file
This commit is contained in:
parent
b8e3bc9dd8
commit
8931f08362
@ -302,23 +302,22 @@ bool CvCapture_Images::open(const std::string& _filename)
|
||||
if (filename_pattern.empty())
|
||||
{
|
||||
filename_pattern = _filename;
|
||||
cv::String filename = _filename.c_str();
|
||||
if (!utils::fs::exists(filename))
|
||||
if (!utils::fs::exists(filename_pattern))
|
||||
{
|
||||
CV_LOG_INFO(NULL, "CAP_IMAGES: File does not exist: " << filename_pattern);
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
if (!haveImageReader(filename))
|
||||
if (!haveImageReader(filename_pattern))
|
||||
{
|
||||
CV_LOG_INFO(NULL, "CAP_IMAGES: Stop scanning. Can't read image file: " << filename);
|
||||
CV_LOG_INFO(NULL, "CAP_IMAGES: File is not an image: " << filename_pattern);
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
length = 1;
|
||||
// grab frame to enable properties retrieval
|
||||
bool grabRes = grabFrame();
|
||||
grabbedInOpen = true;
|
||||
currentframe = 0;
|
||||
return grabRes;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// determine the length of the sequence
|
||||
for (length = 0; ;)
|
||||
{
|
||||
@ -330,12 +329,13 @@ bool CvCapture_Images::open(const std::string& _filename)
|
||||
offset++;
|
||||
continue;
|
||||
}
|
||||
CV_LOG_INFO(NULL, "CAP_IMAGES: File does not exist: " << filename);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!haveImageReader(filename))
|
||||
{
|
||||
CV_LOG_INFO(NULL, "CAP_IMAGES: Stop scanning. Can't read image file: " << filename);
|
||||
CV_LOG_INFO(NULL, "CAP_IMAGES: File is not an image: " << filename);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -349,12 +349,11 @@ bool CvCapture_Images::open(const std::string& _filename)
|
||||
}
|
||||
|
||||
firstframe = offset;
|
||||
|
||||
}
|
||||
// grab frame to enable properties retrieval
|
||||
bool grabRes = grabFrame();
|
||||
bool grabRes = CvCapture_Images::grabFrame();
|
||||
grabbedInOpen = true;
|
||||
currentframe = 0;
|
||||
|
||||
return grabRes;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user