-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.cpp
49 lines (41 loc) · 1.22 KB
/
main.cpp
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
41
42
43
44
45
46
47
48
49
#include <fstream>
#include <sstream>
#include <iostream>
#include <stdexcept>
#include "VideoPipeline.hpp"
class JsonReader {
public:
JsonReader(const std::string& filePath): input(filePath) {
if (!input.is_open()) {
throw std::runtime_error("Failed to open configure file");
}
contents = { std::istreambuf_iterator<char>(input), std::istreambuf_iterator<char>() };
}
Json::Value parseJson() {
Json::Reader reader;
Json::Value value;
if (!reader.parse(contents, value)) {
throw std::runtime_error("Failed parsing json");
}
return value;
}
private:
std::ifstream input;
std::string contents;
};
int main(int argc, char **argv) {
try {
JsonReader configReader("/root/trip2-snpe/cfg/config.json");
Json::Value value = configReader.parseJson();
VideoPipeline m_vp(value);
if (!m_vp.create(value["model"]["path"])) {
std::cerr << "[error] failed to create video pipeline instance." << std::endl;
return 1;
}
m_vp.start();
} catch (const std::exception& ex) {
std::cerr << "[error] " << ex.what() << std::endl;
return 1;
}
return 0;
}