Return the trackedObject's properties as a JSON string
| 278 | #ifdef USE_OPENCV |
| 279 | // Return the trackedObject's properties as a JSON string |
| 280 | std::string Timeline::GetTrackedObjectValues(std::string id, int64_t frame_number) const { |
| 281 | |
| 282 | // Initialize the JSON object |
| 283 | Json::Value trackedObjectJson; |
| 284 | |
| 285 | // Search for the tracked object on the map |
| 286 | auto iterator = tracked_objects.find(id); |
| 287 | |
| 288 | if (iterator != tracked_objects.end()) |
| 289 | { |
| 290 | // Id found, Get the object pointer and cast it as a TrackedObjectBBox |
| 291 | std::shared_ptr<TrackedObjectBBox> trackedObject = std::static_pointer_cast<TrackedObjectBBox>(iterator->second); |
| 292 | |
| 293 | // Get the trackedObject values for it's first frame |
| 294 | if (trackedObject->ExactlyContains(frame_number)){ |
| 295 | BBox box = trackedObject->GetBox(frame_number); |
| 296 | float x1 = box.cx - (box.width/2); |
| 297 | float y1 = box.cy - (box.height/2); |
| 298 | float x2 = box.cx + (box.width/2); |
| 299 | float y2 = box.cy + (box.height/2); |
| 300 | float rotation = box.angle; |
| 301 | |
| 302 | trackedObjectJson["x1"] = x1; |
| 303 | trackedObjectJson["y1"] = y1; |
| 304 | trackedObjectJson["x2"] = x2; |
| 305 | trackedObjectJson["y2"] = y2; |
| 306 | trackedObjectJson["rotation"] = rotation; |
| 307 | |
| 308 | } else { |
| 309 | BBox box = trackedObject->BoxVec.begin()->second; |
| 310 | float x1 = box.cx - (box.width/2); |
| 311 | float y1 = box.cy - (box.height/2); |
| 312 | float x2 = box.cx + (box.width/2); |
| 313 | float y2 = box.cy + (box.height/2); |
| 314 | float rotation = box.angle; |
| 315 | |
| 316 | trackedObjectJson["x1"] = x1; |
| 317 | trackedObjectJson["y1"] = y1; |
| 318 | trackedObjectJson["x2"] = x2; |
| 319 | trackedObjectJson["y2"] = y2; |
| 320 | trackedObjectJson["rotation"] = rotation; |
| 321 | } |
| 322 | |
| 323 | } |
| 324 | else { |
| 325 | // Id not found, return all 0 values |
| 326 | trackedObjectJson["x1"] = 0; |
| 327 | trackedObjectJson["y1"] = 0; |
| 328 | trackedObjectJson["x2"] = 0; |
| 329 | trackedObjectJson["y2"] = 0; |
| 330 | trackedObjectJson["rotation"] = 0; |
| 331 | } |
| 332 | |
| 333 | return trackedObjectJson.toStyledString(); |
| 334 | } |
| 335 | #endif |
| 336 | |
| 337 | // Add an openshot::Clip to the timeline |
nothing calls this directly
no test coverage detected