Load protobuf data file
| 448 | |
| 449 | // Load protobuf data file |
| 450 | bool CVTracker::_LoadTrackedData(){ |
| 451 | using std::ios; |
| 452 | |
| 453 | // Create tracker message |
| 454 | pb_tracker::Tracker trackerMessage; |
| 455 | |
| 456 | { |
| 457 | // Read the existing tracker message. |
| 458 | std::fstream input(protobuf_data_path, ios::in | ios::binary); |
| 459 | if (!trackerMessage.ParseFromIstream(&input)) { |
| 460 | std::cerr << "Failed to parse protobuf message." << std::endl; |
| 461 | return false; |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | // Make sure the trackedData is empty |
| 466 | trackedDataById.clear(); |
| 467 | |
| 468 | // Iterate over all frames of the saved message |
| 469 | for (size_t i = 0; i < trackerMessage.frame_size(); i++) { |
| 470 | const pb_tracker::Frame& pbFrameData = trackerMessage.frame(i); |
| 471 | |
| 472 | // Load frame and rotation data |
| 473 | size_t id = pbFrameData.id(); |
| 474 | float rotation = pbFrameData.rotation(); |
| 475 | |
| 476 | // Load bounding box data |
| 477 | const pb_tracker::Frame::Box& box = pbFrameData.bounding_box(); |
| 478 | float x1 = box.x1(); |
| 479 | float y1 = box.y1(); |
| 480 | float x2 = box.x2(); |
| 481 | float y2 = box.y2(); |
| 482 | |
| 483 | // Assign data to tracker map |
| 484 | trackedDataById[id] = FrameData(id, rotation, x1, y1, x2, y2); |
| 485 | } |
| 486 | |
| 487 | // Delete all global objects allocated by libprotobuf. |
| 488 | google::protobuf::ShutdownProtobufLibrary(); |
| 489 | |
| 490 | return true; |
| 491 | } |
no test coverage detected