May 2020
Intermediate to advanced
530 pages
17h 8m
English
We used the ReadClasses function in this example to load the map of objects. Here, the key was an image class index and the value was a textual class description. This function is trivial and reads the synset file line by line. In such a file, each line contains a number and a class description string, separated with the space character. The following code shows its definition:
using Classes = std::map<size_t, std::string>;Classes ReadClasses(const std::string& file_name) { Classes classes; std::ifstream file(file_name); if (file) { std::string line; std::string id; std::string label; std::string token; size_t idx = 1; while (std::getline(file, line)) { std::stringstream line_stream(line); size_t i = 0;Read now
Unlock full access