| 167 | } |
| 168 | |
| 169 | int main(int argc, char* argv[]) |
| 170 | { |
| 171 | int ret = -1; |
| 172 | const std::string root_path = get_root_path(); |
| 173 | std::string proto_file; |
| 174 | std::string model_file; |
| 175 | std::string image_file; |
| 176 | std::string save_name = "save.jpg"; |
| 177 | |
| 178 | int res; |
| 179 | while((res = getopt(argc, argv, "p:m:i:")) != -1) |
| 180 | { |
| 181 | switch(res) |
| 182 | { |
| 183 | case 'p': |
| 184 | proto_file = optarg; |
| 185 | break; |
| 186 | case 'm': |
| 187 | model_file = optarg; |
| 188 | break; |
| 189 | case 'i': |
| 190 | image_file = optarg; |
| 191 | break; |
| 192 | default: |
| 193 | break; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | // init tengine |
| 198 | if(init_tengine() < 0) |
| 199 | { |
| 200 | std::cout << " init tengine failed\n"; |
| 201 | return 1; |
| 202 | } |
| 203 | if(request_tengine_version("0.9") != 1) |
| 204 | { |
| 205 | std::cout << " request tengine version failed\n"; |
| 206 | return 1; |
| 207 | } |
| 208 | |
| 209 | // load model |
| 210 | if(proto_file.empty()) |
| 211 | { |
| 212 | proto_file = root_path + DEF_PROTO; |
| 213 | std::cout << "proto file not specified,using " << proto_file << " by default\n"; |
| 214 | } |
| 215 | if(model_file.empty()) |
| 216 | { |
| 217 | model_file = root_path + DEF_MODEL; |
| 218 | std::cout << "model file not specified,using " << model_file << " by default\n"; |
| 219 | } |
| 220 | if(image_file.empty()) |
| 221 | { |
| 222 | image_file = root_path + DEF_IMAGE; |
| 223 | std::cout << "image file not specified,using " << image_file << " by default\n"; |
| 224 | } |
| 225 | // check file |
| 226 | if(!check_file_exist(proto_file) or (!check_file_exist(model_file) or !check_file_exist(image_file))) |
nothing calls this directly
no test coverage detected