Get QTransform from keyframes
| 1448 | |
| 1449 | // Get QTransform from keyframes |
| 1450 | QTransform Clip::get_transform(std::shared_ptr<Frame> frame, int width, int height) |
| 1451 | { |
| 1452 | // Get image from clip |
| 1453 | std::shared_ptr<QImage> source_image = frame->GetImage(); |
| 1454 | |
| 1455 | /* RESIZE SOURCE IMAGE - based on scale type */ |
| 1456 | QSize source_size = scale_size(source_image->size(), scale, width, height); |
| 1457 | |
| 1458 | // Initialize parent object's properties (Clip or Tracked Object) |
| 1459 | float parentObject_location_x = 0.0; |
| 1460 | float parentObject_location_y = 0.0; |
| 1461 | float parentObject_scale_x = 1.0; |
| 1462 | float parentObject_scale_y = 1.0; |
| 1463 | float parentObject_shear_x = 0.0; |
| 1464 | float parentObject_shear_y = 0.0; |
| 1465 | float parentObject_rotation = 0.0; |
| 1466 | |
| 1467 | // Get the parentClipObject properties |
| 1468 | if (GetParentClip()){ |
| 1469 | // Get the start trim position of the parent clip |
| 1470 | long parent_start_offset = parentClipObject->Start() * info.fps.ToDouble(); |
| 1471 | long parent_frame_number = frame->number + parent_start_offset; |
| 1472 | |
| 1473 | // Get parent object's properties (Clip) |
| 1474 | parentObject_location_x = parentClipObject->location_x.GetValue(parent_frame_number); |
| 1475 | parentObject_location_y = parentClipObject->location_y.GetValue(parent_frame_number); |
| 1476 | parentObject_scale_x = parentClipObject->scale_x.GetValue(parent_frame_number); |
| 1477 | parentObject_scale_y = parentClipObject->scale_y.GetValue(parent_frame_number); |
| 1478 | parentObject_shear_x = parentClipObject->shear_x.GetValue(parent_frame_number); |
| 1479 | parentObject_shear_y = parentClipObject->shear_y.GetValue(parent_frame_number); |
| 1480 | parentObject_rotation = parentClipObject->rotation.GetValue(parent_frame_number); |
| 1481 | } |
| 1482 | |
| 1483 | // Get the parentTrackedObject properties |
| 1484 | if (GetParentTrackedObject()){ |
| 1485 | // Get the attached object's parent clip's properties |
| 1486 | Clip* parentClip = (Clip*) parentTrackedObject->ParentClip(); |
| 1487 | if (parentClip) |
| 1488 | { |
| 1489 | // Get the start trim position of the parent clip |
| 1490 | long parent_start_offset = parentClip->Start() * info.fps.ToDouble(); |
| 1491 | long parent_frame_number = frame->number + parent_start_offset; |
| 1492 | |
| 1493 | // Access the parentTrackedObject's properties |
| 1494 | std::map<std::string, float> trackedObjectProperties = parentTrackedObject->GetBoxValues(parent_frame_number); |
| 1495 | |
| 1496 | // Get actual scaled parent size |
| 1497 | QSize parent_size = scale_size(QSize(parentClip->info.width, parentClip->info.height), |
| 1498 | parentClip->scale, width, height); |
| 1499 | |
| 1500 | // Get actual scaled tracked object size |
| 1501 | int trackedWidth = trackedObjectProperties["w"] * trackedObjectProperties["sx"] * parent_size.width() * |
| 1502 | parentClip->scale_x.GetValue(parent_frame_number); |
| 1503 | int trackedHeight = trackedObjectProperties["h"] * trackedObjectProperties["sy"] * parent_size.height() * |
| 1504 | parentClip->scale_y.GetValue(parent_frame_number); |
| 1505 | |
| 1506 | // Scale the clip source_size based on the actual tracked object size |
| 1507 | source_size = scale_size(source_size, scale, trackedWidth, trackedHeight); |
nothing calls this directly
no test coverage detected