From b8e3d3f79163b7758d23ae51263d64371a69b638 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 12 Nov 2013 16:15:41 +0400 Subject: [PATCH] In the image sequence capture, only search for the ordinal in the file name. Searching in directory names can yield confusing results; e.g. if the input is "jpeg2000/image1.jp2", it will infer the pattern "jpeg%04d/image1.jp2", which is likely not what the user intended. If the user really desires for the variable part to be in the directory name, it can always use an explicit pattern. --- modules/highgui/src/cap_images.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/highgui/src/cap_images.cpp b/modules/highgui/src/cap_images.cpp index e2feb0d27..e1a8b8b1c 100644 --- a/modules/highgui/src/cap_images.cpp +++ b/modules/highgui/src/cap_images.cpp @@ -200,8 +200,18 @@ static char* icvExtractPattern(const char *filename, unsigned *offset) } else // no pattern filename was given - extract the pattern { - for(at = name; *at && !isdigit(*at); at++) - ; + at = name; + + // ignore directory names + char *slash = strrchr(at, '/'); + if (slash) at = slash + 1; + +#ifdef _WIN32 + slash = strrchr(at, '\\'); + if (slash) at = slash + 1; +#endif + + while (*at && !isdigit(*at)) at++; if(!*at) return 0;