| 197 | } |
| 198 | |
| 199 | virtual void start_element ( |
| 200 | const unsigned long line_number, |
| 201 | const std::string& name, |
| 202 | const dlib::attribute_list& atts |
| 203 | ) |
| 204 | { |
| 205 | try |
| 206 | { |
| 207 | if (ts.size() == 0) |
| 208 | { |
| 209 | if (name != "dataset") |
| 210 | { |
| 211 | std::ostringstream sout; |
| 212 | sout << "Invalid XML document. Root tag must be <dataset>. Found <" << name << "> instead."; |
| 213 | throw dlib::error(sout.str()); |
| 214 | } |
| 215 | else |
| 216 | { |
| 217 | ts.push_back(name); |
| 218 | return; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | |
| 223 | if (name == "box") |
| 224 | { |
| 225 | if (atts.is_in_list("top")) temp_box.rect.top() = sa = atts["top"]; |
| 226 | else throw dlib::error("<box> missing required attribute 'top'"); |
| 227 | |
| 228 | if (atts.is_in_list("left")) temp_box.rect.left() = sa = atts["left"]; |
| 229 | else throw dlib::error("<box> missing required attribute 'left'"); |
| 230 | |
| 231 | if (atts.is_in_list("width")) temp_box.rect.right() = sa = atts["width"]; |
| 232 | else throw dlib::error("<box> missing required attribute 'width'"); |
| 233 | |
| 234 | if (atts.is_in_list("height")) temp_box.rect.bottom() = sa = atts["height"]; |
| 235 | else throw dlib::error("<box> missing required attribute 'height'"); |
| 236 | |
| 237 | if (atts.is_in_list("difficult")) temp_box.difficult = sa = atts["difficult"]; |
| 238 | if (atts.is_in_list("truncated")) temp_box.truncated = sa = atts["truncated"]; |
| 239 | if (atts.is_in_list("occluded")) temp_box.occluded = sa = atts["occluded"]; |
| 240 | if (atts.is_in_list("ignore")) temp_box.ignore = sa = atts["ignore"]; |
| 241 | if (atts.is_in_list("angle")) temp_box.angle = sa = atts["angle"]; |
| 242 | if (atts.is_in_list("age")) temp_box.age = sa = atts["age"]; |
| 243 | if (atts.is_in_list("gender")) |
| 244 | { |
| 245 | if (atts["gender"] == "male") |
| 246 | temp_box.gender = MALE; |
| 247 | else if (atts["gender"] == "female") |
| 248 | temp_box.gender = FEMALE; |
| 249 | else if (atts["gender"] == "unknown") |
| 250 | temp_box.gender = UNKNOWN; |
| 251 | else |
| 252 | throw dlib::error("Invalid gender string in box attribute."); |
| 253 | } |
| 254 | if (atts.is_in_list("pose")) temp_box.pose = sa = atts["pose"]; |
| 255 | if (atts.is_in_list("detection_score")) temp_box.detection_score = sa = atts["detection_score"]; |
| 256 |
no test coverage detected