| 83 | } |
| 84 | |
| 85 | virtual void characters ( |
| 86 | const std::string& data |
| 87 | ) |
| 88 | { |
| 89 | if (ts.size() == 2 && ts[1] == "filename") |
| 90 | { |
| 91 | temp_image.filename = trim(data); |
| 92 | } |
| 93 | else if (ts.size() == 3 && ts[2] == "database" && ts[1] == "source") |
| 94 | { |
| 95 | dataset_name = trim(data); |
| 96 | } |
| 97 | else if (ts.size() >= 3) |
| 98 | { |
| 99 | if (ts[ts.size()-2] == "bndbox" && ts[ts.size()-3] == "object") |
| 100 | { |
| 101 | if (ts.back() == "xmin") temp_box.rect.left() = string_cast<double>(data); |
| 102 | else if (ts.back() == "ymin") temp_box.rect.top() = string_cast<double>(data); |
| 103 | else if (ts.back() == "xmax") temp_box.rect.right() = string_cast<double>(data); |
| 104 | else if (ts.back() == "ymax") temp_box.rect.bottom() = string_cast<double>(data); |
| 105 | } |
| 106 | else if (ts.back() == "name" && ts[ts.size()-2] == "object") |
| 107 | { |
| 108 | temp_box.label = trim(data); |
| 109 | } |
| 110 | else if (ts.back() == "difficult" && ts[ts.size()-2] == "object") |
| 111 | { |
| 112 | if (trim(data) == "0" || trim(data) == "false") |
| 113 | { |
| 114 | temp_box.difficult = false; |
| 115 | } |
| 116 | else |
| 117 | { |
| 118 | temp_box.difficult = true; |
| 119 | } |
| 120 | } |
| 121 | else if (ts.back() == "truncated" && ts[ts.size()-2] == "object") |
| 122 | { |
| 123 | if (trim(data) == "0" || trim(data) == "false") |
| 124 | { |
| 125 | temp_box.truncated = false; |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | temp_box.truncated = true; |
| 130 | } |
| 131 | } |
| 132 | else if (ts.back() == "occluded" && ts[ts.size()-2] == "object") |
| 133 | { |
| 134 | if (trim(data) == "0" || trim(data) == "false") |
| 135 | { |
| 136 | temp_box.occluded = false; |
| 137 | } |
| 138 | else |
| 139 | { |
| 140 | temp_box.occluded = true; |
| 141 | } |
| 142 | } |