samples: use findFile() in T-API samples

This commit is contained in:
Alexander Alekhin 2018-11-11 13:26:24 +00:00
parent e8e2197032
commit 9ea8c775f8
6 changed files with 24 additions and 24 deletions

View File

@ -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);

View File

@ -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<double>("s");
vdo_source = cmd.get<string>("v");
vdo_source = samples::findFileOrKeep(cmd.get<string>("v"));
img_source = cmd.get<string>("i");
output = cmd.get<string>("o");
camera_id = cmd.get<int>("c");

View File

@ -72,7 +72,7 @@ int main(int argc, char** argv)
string image_file = args.get<string>("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;

View File

@ -96,8 +96,8 @@ int main(int argc, const char* argv[])
}
bool defaultPicturesFail = true;
string fname0 = cmd.get<string>("left");
string fname1 = cmd.get<string>("right");
string fname0 = samples::findFile(cmd.get<string>("left"));
string fname1 = samples::findFile(cmd.get<string>("right"));
string vdofile = cmd.get<string>("video");
string outfile = cmd.get<string>("output");
int points = cmd.get<int>("points");
@ -105,9 +105,9 @@ int main(int argc, const char* argv[])
int inputName = cmd.get<int>("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<cv::Point2f> pts(points);
vector<cv::Point2f> nextPts(points);

View File

@ -156,7 +156,7 @@ int main(int argc, char** argv)
cout << "OpenCL was disabled" << endl;
}
string inputName = cmd.get<string>("i");
string inputName = samples::findFile(cmd.get<string>("i"));
string outfile = cmd.get<string>("o");
int iterations = 10;
@ -164,7 +164,7 @@ int main(int argc, char** argv)
vector<vector<Point> > squares;
UMat image;
imread(inputName, 1).copyTo(image);
imread(inputName, IMREAD_COLOR).copyTo(image);
if( image.empty() )
{
cout << "Couldn't load " << inputName << endl;

View File

@ -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<string>("cascade");
nestedCascadeName = parser.get<string>("nested-cascade");
string cascadeName = samples::findFile(parser.get<string>("cascade"));
string nestedCascadeName = samples::findFileOrKeep(parser.get<string>("nested-cascade"));
scale = parser.get<double>("scale");
tryflip = parser.has("try-flip");
inputName = parser.get<string>("@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 );