opencv_example/example.cpp

35 lines
746 B
C++

#include <iostream>
#include <opencv2/core.hpp>
#include <sys/stat.h>
using namespace std;
using namespace cv;
inline bool file_exists (const std::string& name) {
struct stat buffer;
return (stat (name.c_str(), &buffer) == 0);
}
int main(int argc, char** argv)
{
string input;
if (argc == 2) {
input = argv[1];
} else if (argc < 2) {
cerr << "Please provide one image." << endl;
return -1;
} else if (argc > 2) {
cerr << "Please provide only one image." << endl;
return -2;
}
if (!file_exists(input)) {
cerr << "File " << input << " does not exist." << endl;
return -3;
}
cout << "Using image " << input << "." << endl;
return 0;
}