|
30 | 30 |
|
31 | 31 | from functools import partial
|
32 | 32 | from operator import itemgetter
|
33 |
| -from PyQt5.QtCore import Qt, QRectF, QLocale, pyqtSignal, QTimer |
| 33 | +from PyQt5.QtCore import Qt, QRectF, QRect, QLocale, pyqtSignal, QTimer |
34 | 34 | from PyQt5.QtGui import (
|
35 | 35 | QIcon, QColor, QBrush, QPen, QPalette, QPixmap,
|
36 | 36 | QPainter, QPainterPath, QLinearGradient, QFont, QFontInfo,
|
@@ -450,28 +450,26 @@ def contextMenuEvent(self, event):
|
450 | 450 | clip_instance_icon = clip_index.data(Qt.DecorationRole)
|
451 | 451 | # Get the pixmap of the clip icon
|
452 | 452 | icon_size = 64
|
453 |
| - icon_pixmap = clip_instance_icon.pixmap(icon_size) |
| 453 | + icon_pixmap = clip_instance_icon.pixmap(icon_size, icon_size) |
454 | 454 | # Add tracked objects to the selection menu
|
455 | 455 | tracked_objects = []
|
456 | 456 | for effect in clip_instance_data["effects"]:
|
457 |
| - # Check if the effect has the "box_id" property, i.e., is the Tracker effect |
458 |
| - if ("box_id" in effect.keys()): |
459 |
| - # Get the Tracker properties from the timeline |
460 |
| - tracker_effect = timeline_instance.GetClipEffect(effect["id"]) |
461 |
| - tracker_effect_properties = json.loads(tracker_effect.PropertiesJSON(1)) |
462 |
| - x1 = tracker_effect_properties["x1"]["value"] |
463 |
| - x2 = tracker_effect_properties["x2"]["value"] |
464 |
| - y1 = tracker_effect_properties["y1"]["value"] |
465 |
| - y2 = tracker_effect_properties["y2"]["value"] |
466 |
| - # Get the tracked object's icon from the clip's icon - different adjustment if it's an image or video file |
467 |
| - if clip_instance_data["reader"]["has_single_image"]: |
468 |
| - tracked_object_icon = QIcon(icon_pixmap.copy(x1*icon_size, y1*icon_size, (x2-x1)*icon_size, (y2-y1)*icon_size*(2/3))) |
469 |
| - else: |
470 |
| - tracked_object_icon = QIcon(icon_pixmap.copy(x1*icon_size, y1*icon_size, (x2-x1)*icon_size, (y2-y1)*icon_size/2)) |
471 |
| - tracked_objects.append({"name": effect["box_id"], |
472 |
| - "value": effect["box_id"], |
473 |
| - "selected": False, |
474 |
| - "icon": tracked_object_icon}) |
| 457 | + # Iterate through the effect properties |
| 458 | + for effect_key in effect.keys(): |
| 459 | + # Check if the effect has the "box_id" property, i.e., is the Tracker or ObjectDetection effect |
| 460 | + if effect_key.startswith("box_id"): |
| 461 | + # Get the Tracked Object properties from the timeline |
| 462 | + tracked_object_properties = json.loads(timeline_instance.GetTrackedObjectValues(effect[effect_key])) |
| 463 | + x1 = tracked_object_properties["x1"] |
| 464 | + x2 = tracked_object_properties["x2"] |
| 465 | + y1 = tracked_object_properties["y1"] |
| 466 | + y2 = tracked_object_properties["y2"] |
| 467 | + # Get the tracked object's icon from the clip's icon |
| 468 | + tracked_object_icon = icon_pixmap.copy(QRect(x1*icon_size, y1*icon_size, (x2-x1)*icon_size, (y2-y1)*icon_size/2)).scaled(icon_size, icon_size) |
| 469 | + tracked_objects.append({"name": effect[effect_key], |
| 470 | + "value": effect[effect_key], |
| 471 | + "selected": False, |
| 472 | + "icon": QIcon(tracked_object_icon)}) |
475 | 473 | clips_choices.append({"name": clip_instance_data["title"],
|
476 | 474 | "value": tracked_objects,
|
477 | 475 | "selected": False,
|
|
0 commit comments