Skip to content

Commit 17ece58

Browse files
umbraclet16sovrasov
authored andcommitted
Solve issue opencv#8264
Fix bug in camera_calibration.cpp that the program tries to parse input of type VIDEO_FILE as IMAGE_LIST which causes the program to crash.
1 parent 220d1f0 commit 17ece58

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Settings
109109
}
110110
else
111111
{
112-
if (readStringList(input, imageList))
112+
if (isListOfImages(input) && readStringList(input, imageList))
113113
{
114114
inputType = IMAGE_LIST;
115115
nrFrames = (nrFrames < (int)imageList.size()) ? nrFrames : (int)imageList.size();
@@ -190,6 +190,16 @@ class Settings
190190
l.push_back((string)*it);
191191
return true;
192192
}
193+
194+
static bool isListOfImages( const string& filename)
195+
{
196+
string s(filename);
197+
// Look for file extension
198+
if( s.find(".xml") == string::npos && s.find(".yaml") == string::npos && s.find(".yml") == string::npos )
199+
return false;
200+
else
201+
return true;
202+
}
193203
public:
194204
Size boardSize; // The size of the board -> Number of items by width and height
195205
Pattern calibrationPattern; // One of the Chessboard, circles, or asymmetric circle pattern

0 commit comments

Comments
 (0)