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