-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (34 loc) · 1.01 KB
/
Copy pathmain.cpp
File metadata and controls
40 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <cstdlib>
#include <iostream>
#include <string>
#include <boost/program_options.hpp>
#include <opencv2/opencv.hpp>
#include "LeNet.h"
using namespace std;
using namespace boost::program_options;
using namespace cv;
int main(int argc,char ** argv)
{
string img_path;
options_description desc;
desc.add_options()
("help,h","打印当前使用方法")
("input,i",value<string>(&img_path),"输入图片路径");
variables_map vm;
store(parse_command_line(argc,argv,desc),vm);
notify(vm);
if(1 == argc || 1 != vm.count("input") || 1 == vm.count("help")) {
cout<<desc;
return EXIT_SUCCESS;
}
Mat img = imread(img_path,IMREAD_GRAYSCALE);
if(true == img.empty()) {
cerr<<"图片无法打开!"<<endl;
return EXIT_FAILURE;
}
LeNet lenet("deploy_models/mnist_init_net.pbtxt","deploy_models/mnist_predict_net.pbtxt");
vector<float> result = lenet.predict(img);
vector<float>::iterator max_iter = max_element(result.begin(),result.end());
cout<<max_iter - result.begin()<<endl;
return EXIT_SUCCESS;
}