diff --git a/samples/tapi/clahe.cpp b/samples/tapi/clahe.cpp index 0b7de45a60..ebef65f4e4 100644 --- a/samples/tapi/clahe.cpp +++ b/samples/tapi/clahe.cpp @@ -63,8 +63,9 @@ int main(int argc, char** argv) setTrackbarPos("Tile Size", "CLAHE", cur_tilesize.width); setTrackbarPos("Clip Limit", "CLAHE", cur_clip); - if(infile != "") + if(!infile.empty()) { + infile = samples::findFile(infile); imread(infile).copyTo(frame); if(frame.empty()) { @@ -87,7 +88,10 @@ int main(int argc, char** argv) else imread(infile).copyTo(frame); if(frame.empty()) - continue; + { + waitKey(); + break; + } cvtColor(frame, frame, COLOR_BGR2GRAY); pFilter->apply(frame, outframe); diff --git a/samples/tapi/hog.cpp b/samples/tapi/hog.cpp index 4753c19312..eee200588c 100644 --- a/samples/tapi/hog.cpp +++ b/samples/tapi/hog.cpp @@ -61,7 +61,7 @@ int main(int argc, char** argv) "{ h help | | print help message }" "{ i input | | specify input image}" "{ c camera | -1 | enable camera capturing }" - "{ v video | ../data/vtest.avi | use video as input }" + "{ v video | vtest.avi | use video as input }" "{ g gray | | convert image to gray one or not}" "{ s scale | 1.0 | resize the image before detect}" "{ o output | | specify output path when input is images}"; @@ -107,7 +107,7 @@ App::App(CommandLineParser& cmd) make_gray = cmd.has("gray"); resize_scale = cmd.get("s"); - vdo_source = cmd.get("v"); + vdo_source = samples::findFileOrKeep(cmd.get("v")); img_source = cmd.get("i"); output = cmd.get("o"); camera_id = cmd.get("c"); diff --git a/samples/tapi/opencl_custom_kernel.cpp b/samples/tapi/opencl_custom_kernel.cpp index 2395061a9a..c4e893a8a8 100644 --- a/samples/tapi/opencl_custom_kernel.cpp +++ b/samples/tapi/opencl_custom_kernel.cpp @@ -72,7 +72,7 @@ int main(int argc, char** argv) string image_file = args.get("i"); if (!image_file.empty()) { - Mat image = imread(image_file); + Mat image = imread(samples::findFile(image_file)); if (image.empty()) { cout << "error read image: " << image_file << endl; diff --git a/samples/tapi/pyrlk_optical_flow.cpp b/samples/tapi/pyrlk_optical_flow.cpp index bb426cbf76..9c1364d180 100644 --- a/samples/tapi/pyrlk_optical_flow.cpp +++ b/samples/tapi/pyrlk_optical_flow.cpp @@ -96,8 +96,8 @@ int main(int argc, const char* argv[]) } bool defaultPicturesFail = true; - string fname0 = cmd.get("left"); - string fname1 = cmd.get("right"); + string fname0 = samples::findFile(cmd.get("left")); + string fname1 = samples::findFile(cmd.get("right")); string vdofile = cmd.get("video"); string outfile = cmd.get("output"); int points = cmd.get("points"); @@ -105,9 +105,9 @@ int main(int argc, const char* argv[]) int inputName = cmd.get("c"); UMat frame0; - imread(fname0, cv::IMREAD_GRAYSCALE).copyTo(frame0); + imread(fname0, IMREAD_GRAYSCALE).copyTo(frame0); UMat frame1; - imread(fname1, cv::IMREAD_GRAYSCALE).copyTo(frame1); + imread(fname1, IMREAD_GRAYSCALE).copyTo(frame1); vector pts(points); vector nextPts(points); diff --git a/samples/tapi/squares.cpp b/samples/tapi/squares.cpp index 42a40c3f6f..4cdce2251b 100644 --- a/samples/tapi/squares.cpp +++ b/samples/tapi/squares.cpp @@ -156,7 +156,7 @@ int main(int argc, char** argv) cout << "OpenCL was disabled" << endl; } - string inputName = cmd.get("i"); + string inputName = samples::findFile(cmd.get("i")); string outfile = cmd.get("o"); int iterations = 10; @@ -164,7 +164,7 @@ int main(int argc, char** argv) vector > squares; UMat image; - imread(inputName, 1).copyTo(image); + imread(inputName, IMREAD_COLOR).copyTo(image); if( image.empty() ) { cout << "Couldn't load " << inputName << endl; diff --git a/samples/tapi/ufacedetect.cpp b/samples/tapi/ufacedetect.cpp index 3eeddb94b1..0a6d91c3d6 100644 --- a/samples/tapi/ufacedetect.cpp +++ b/samples/tapi/ufacedetect.cpp @@ -28,9 +28,6 @@ void detectAndDraw( UMat& img, Mat& canvas, CascadeClassifier& cascade, CascadeClassifier& nestedCascade, double scale, bool tryflip ); -string cascadeName = "../../data/haarcascades/haarcascade_frontalface_alt.xml"; -string nestedCascadeName = "../../data/haarcascades/haarcascade_eye_tree_eyeglasses.xml"; - int main( int argc, const char** argv ) { VideoCapture capture; @@ -44,8 +41,8 @@ int main( int argc, const char** argv ) double scale; cv::CommandLineParser parser(argc, argv, - "{cascade|../../data/haarcascades/haarcascade_frontalface_alt.xml|}" - "{nested-cascade|../../data/haarcascades/haarcascade_eye_tree_eyeglasses.xml|}" + "{cascade|data/haarcascades/haarcascade_frontalface_alt.xml|}" + "{nested-cascade|data/haarcascades/haarcascade_eye_tree_eyeglasses.xml|}" "{help h ||}{scale|1|}{try-flip||}{@filename||}" ); if (parser.has("help")) @@ -53,8 +50,8 @@ int main( int argc, const char** argv ) help(); return 0; } - cascadeName = parser.get("cascade"); - nestedCascadeName = parser.get("nested-cascade"); + string cascadeName = samples::findFile(parser.get("cascade")); + string nestedCascadeName = samples::findFileOrKeep(parser.get("nested-cascade")); scale = parser.get("scale"); tryflip = parser.has("try-flip"); inputName = parser.get("@filename"); @@ -66,10 +63,10 @@ int main( int argc, const char** argv ) } if ( !nestedCascade.load( nestedCascadeName ) ) - cerr << "WARNING: Could not load classifier cascade for nested objects" << endl; + cerr << "WARNING: Could not load classifier cascade for nested objects: " << nestedCascadeName << endl; if( !cascade.load( cascadeName ) ) { - cerr << "ERROR: Could not load classifier cascade" << endl; + cerr << "ERROR: Could not load classifier cascade: " << cascadeName << endl; help(); return -1; } @@ -84,9 +81,8 @@ int main( int argc, const char** argv ) } else { - if( inputName.empty() ) - inputName = "../data/lena.jpg"; - image = imread( inputName, 1 ).getUMat(ACCESS_READ); + inputName = samples::findFileOrKeep(inputName); + imread(inputName, IMREAD_COLOR).copyTo(image); if( image.empty() ) { if(!capture.open( inputName )) @@ -133,7 +129,7 @@ int main( int argc, const char** argv ) len--; buf[len] = '\0'; cout << "file " << buf << endl; - image = imread( buf, 1 ).getUMat(ACCESS_READ); + imread(samples::findFile(buf), IMREAD_COLOR).copyTo(image); if( !image.empty() ) { detectAndDraw( image, canvas, cascade, nestedCascade, scale, tryflip );