Skip to content

Effect parenting #4058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
525ee64
Added transform handler for Tracker effect
BrennoCaldato Nov 28, 2020
0d348bb
Changed Json interface that updates the Tracker effect
BrennoCaldato Dec 12, 2020
4179022
Added support for rotation transform to the bounding-box and to the t…
BrennoCaldato Dec 14, 2020
c97ff76
Added support for rotation to the transform handler for the tracker e…
BrennoCaldato Dec 23, 2020
b4cac00
Small fix - print removed
BrennoCaldato Dec 24, 2020
8ae8dda
Merge branch 'opencv' into keyframe-refactor
BrennoCaldato Jan 14, 2021
085a731
Added mini-GUI to attach a clip to a tracked object
BrennoCaldato Jan 14, 2021
c25ffe8
Minor fixes to the attached object property
BrennoCaldato Jan 18, 2021
ceefbf8
Fixed clip transform handler when attached to object
BrennoCaldato Jan 19, 2021
430433d
Added support to attach clip to detected object (ObjectDetection) effect
BrennoCaldato Jan 22, 2021
6858b6c
Added support to update the detected bounding-boxes keyframes
BrennoCaldato Jan 22, 2021
2ef5c07
ObjectDetection: show object's icons and transform handlers per frame
BrennoCaldato Jan 22, 2021
f94ccb5
Added support to show the transform handler for the selected object
BrennoCaldato Jan 27, 2021
0320094
ObjectDetection: updated object selection and transform handler
BrennoCaldato Jan 27, 2021
32a97bc
Added support to attach a clip to another clip
BrennoCaldato Jan 27, 2021
ba42267
Updated variable names
BrennoCaldato Jan 27, 2021
45da4d6
Added support to set the visibility of a Tracked Object
BrennoCaldato Feb 4, 2021
ff2ee27
Added support to insert the image of a clip inside a Tracked Object
BrennoCaldato Feb 4, 2021
0f1d700
Added support to set an effect's properties by it's parent effect
BrennoCaldato Feb 4, 2021
7f5501e
Merge remote-tracking branch 'origin/develop' into effect-parenting
BrennoCaldato Mar 4, 2021
32fcb8f
Fixing video_widget to allow an override, which ignores the project a…
jonoomph Mar 10, 2021
3b08209
Protecting from missing attributes and checking for Null values
jonoomph Mar 12, 2021
6f695f5
Fixed bounding box offset when selecting an object to be tracked
BrennoCaldato Mar 13, 2021
08feaef
Fixed cache delay when moving the Tracker Transform Handler
BrennoCaldato Mar 13, 2021
e5a5e55
Fixed bounding box selection on portrait videos
BrennoCaldato Mar 14, 2021
e10f970
Using normalized initial bounding box for Tracker effect
BrennoCaldato Mar 16, 2021
ea93464
Protecting from missing attributes
BrennoCaldato Mar 16, 2021
e728227
Merge branch 'effect-parenting-fix' into effect-parenting
BrennoCaldato Mar 16, 2021
1f3393a
Fixed Transforming handler shape mismatch for Tracker effect
BrennoCaldato Mar 16, 2021
bfdfc6d
Removed the single "Clips" menu level
BrennoCaldato Mar 27, 2021
64acae8
Changed default ObjectDetection default path for required files
BrennoCaldato Mar 27, 2021
7229583
Prevent crash when no object was detected on a clip
BrennoCaldato Apr 13, 2021
44d1120
Code review
BrennoCaldato Apr 13, 2021
b9f2e22
build_server: Code-formatting/readability fixes
ferdnyc Apr 18, 2021
fbd3551
Windows builder: mingw32\mingw32\ => mingw64\mingw32
ferdnyc Apr 18, 2021
7bfa57c
Look up Python ABI version, instead of hardcoding
ferdnyc Apr 18, 2021
9a16b52
Gitlab-ci: Make PY_ABI an envvar on Windows
ferdnyc Apr 18, 2021
1a70c0c
Gitlab-CI: Fix use of PowerShell variables
ferdnyc Apr 18, 2021
22fda5a
Gitlab-CI: Add PyQt5 back to PYTHONPATH, crazily
ferdnyc Apr 18, 2021
2a89045
Small change to github3 API
ferdnyc Apr 26, 2021
3cf7717
deploy.py: Reformat long lines
ferdnyc Apr 26, 2021
3c6f783
Munge command strings with shlex
ferdnyc Apr 26, 2021
d9dcd17
Fix editbit command
ferdnyc Apr 26, 2021
64aec0f
Handle multiple github3 versions
ferdnyc Apr 26, 2021
b54ae46
Rename version_info files to NAME.env
ferdnyc Apr 26, 2021
8a868b5
Fix env-file parsing
ferdnyc Apr 26, 2021
9050d67
Freeze: Include OpenGL/OpenGL_accelerate on Win32
ferdnyc Apr 28, 2021
5f2453b
Changed JSON communication for detected objects
BrennoCaldato May 8, 2021
85c579d
Fixed dict update
BrennoCaldato May 11, 2021
2df9e94
Improved speed when interacting with transform handlers
BrennoCaldato May 11, 2021
e096a2b
Merge remote-tracking branch 'origin/mingw-paths' into effect-parenting
BrennoCaldato May 11, 2021
10d8345
Simplified if statements
BrennoCaldato May 19, 2021
2390092
Merge pull request #4151 from OpenShot/fix-saving
BrennoCaldato May 19, 2021
1a89ef0
Apply suggestions from code review
BrennoCaldato May 24, 2021
c4266b3
Changed method name to set_property
BrennoCaldato May 24, 2021
7582c01
Keeping compatibility with older python versions
BrennoCaldato May 24, 2021
beb522e
Reverting dictionary optimizations
BrennoCaldato May 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/classes/effect_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
You should have received a copy of the GNU General Public License
along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
"""

from classes.info import USER_PATH
import os
# Not all Effects support pre-processing, so for now, this is a hard-coded
# solution to providing the pre-processing params needed for these special effects.

Expand Down Expand Up @@ -150,19 +151,19 @@

"Object Detector": [
{
"value": "../yolo/yolov3.weights",
"value": os.path.join(USER_PATH,"yolo/yolov3.weights"),
"title": "Model Weights",
"type": "text",
"setting": "model-weights"
},
{
"value": "../yolo/yolov3.cfg",
"value": os.path.join(USER_PATH,"yolo/yolov3.cfg"),
"title": "Model Config",
"type": "text",
"setting": "model-config"
},
{
"value": "../yolo/obj.names",
"value": os.path.join(USER_PATH,"yolo/obj.names"),
"title": "Class names",
"type": "text",
"setting": "class-names"
Expand Down
52 changes: 52 additions & 0 deletions src/classes/project_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,58 @@ def rescale_keyframes(self, scale_factor):
scaled = scaler(copy.deepcopy(self._data))
return scaled

# Create copy of active project data
data = copy.deepcopy(self._data)

# Rescale the the copied project data
# Loop through all clips (and look for Keyframe objects)
# Scale the X coordinate by factor (which represents the frame #)
for clip in data.get('clips', []):
for attribute in clip:
if type(clip.get(attribute)) == dict and "Points" in clip.get(attribute):
for point in clip.get(attribute).get("Points"):
if "co" in point:
point["co"]["X"] = self.scale_keyframe_value(point["co"].get("X", 0.0), scale_factor)
if type(clip.get(attribute)) == dict and "red" in clip.get(attribute):
for color in clip.get(attribute):
for point in clip.get(attribute).get(color).get("Points"):
if "co" in point:
point["co"]["X"] = self.scale_keyframe_value(point["co"].get("X", 0.0), scale_factor)
for effect in clip.get("effects", []):
for attribute in effect:
if type(effect.get(attribute)) == dict and "Points" in effect.get(attribute):
for point in effect.get(attribute).get("Points"):
if "co" in point:
point["co"]["X"] = self.scale_keyframe_value(point["co"].get("X", 0.0), scale_factor)
if type(effect.get(attribute)) == dict and "red" in effect.get(attribute):
for color in effect.get(attribute):
for point in effect.get(attribute).get(color).get("Points"):
if "co" in point:
point["co"]["X"] = self.scale_keyframe_value(point["co"].get("X", 0.0), scale_factor)
if effect.get("class_name") == "Tracker":
effect["TimeScale"] = effect["TimeScale"] * scale_factor


# Loop through all effects/transitions (and look for Keyframe objects)
# Scale the X coordinate by factor (which represents the frame #)
for effect in data.get('effects', []):
for attribute in effect:
if type(effect.get(attribute)) == dict and "Points" in effect.get(attribute):
for point in effect.get(attribute).get("Points"):
if "co" in point:
point["co"]["X"] = self.scale_keyframe_value(point["co"].get("X", 0.0), scale_factor)
if type(effect.get(attribute)) == dict and "red" in effect.get(attribute):
for color in effect.get(attribute):
for point in effect.get(attribute).get(color).get("Points"):
if "co" in point:
point["co"]["X"] = self.scale_keyframe_value(point["co"].get("X", 0.0), scale_factor)
if effect.get("class_name") == "Tracker":
effect["TimeScale"] = effect["TimeScale"] * scale_factor


# return the copied and scaled project data
return data

def read_legacy_project_file(self, file_path):
"""Attempt to read a legacy version 1.x openshot project file"""
import sys
Expand Down
11 changes: 10 additions & 1 deletion src/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from classes.importers.final_cut_pro import import_xml
from classes.logger import log
from classes.metrics import track_metric_session, track_metric_screen
from classes.query import Clip, Transition, Marker, Track
from classes.query import Clip, Transition, Marker, Track, Effect
from classes.thumbnail import httpThumbnailServerThread
from classes.time_parts import secondsToTimecode
from classes.timeline import TimelineSync
Expand Down Expand Up @@ -101,6 +101,7 @@ class MainWindow(updates.UpdateWatcher, QMainWindow):
FoundVersionSignal = pyqtSignal(str)
WaveformReady = pyqtSignal(str, list)
TransformSignal = pyqtSignal(str)
KeyFrameTransformSignal = pyqtSignal(str, str)
SelectRegionSignal = pyqtSignal(str)
MaxSizeChanged = pyqtSignal(object)
InsertKeyframe = pyqtSignal(object)
Expand Down Expand Up @@ -2282,6 +2283,14 @@ def addSelection(self, item_id, item_type, clear_existing=False):
elif item_type == "effect" and item_id not in self.selected_effects:
self.selected_effects.append(item_id)

effect = Effect.get(id=item_id)
if effect:
if effect.data.get("has_tracked_object"):
# Show bounding boxes transform on preview
clip_id = effect.parent['id']
self.KeyFrameTransformSignal.emit(item_id, clip_id)


# Change selected item in properties view
self.show_property_id = item_id
self.show_property_type = item_type
Expand Down
21 changes: 14 additions & 7 deletions src/windows/process_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ def rect_select_clicked(self, widget, param):
topLeft = win.videoPreview.regionTopLeftHandle
bottomRight = win.videoPreview.regionBottomRightHandle
viewPortSize = win.viewport_rect
curr_frame_size = win.videoPreview.curr_frame_size

x1 = topLeft.x() / curr_frame_size.width()
y1 = topLeft.y() / curr_frame_size.height()
x2 = bottomRight.x() / curr_frame_size.width()
y2 = bottomRight.y() / curr_frame_size.height()

# Get QImage of region
if win.videoPreview.region_qimage:
Expand All @@ -275,13 +281,10 @@ def rect_select_clicked(self, widget, param):

# If data found, add to context
if topLeft and bottomRight:
self.context[param["setting"]].update({"x": topLeft.x(), "y": topLeft.y(),
"width": bottomRight.x() - topLeft.x(),
"height": bottomRight.y() - topLeft.y(),
"scaled_x": topLeft.x() / viewPortSize.width(), "scaled_y": topLeft.y() / viewPortSize.height(),
"scaled_width": (bottomRight.x() - topLeft.x()) / viewPortSize.width(),
"scaled_height": (bottomRight.y() - topLeft.y()) / viewPortSize.height(),
"first-frame": win.current_frame
self.context[param["setting"]].update({"normalized_x": x1, "normalized_y": y1,
"normalized_width": x2-x1,
"normalized_height": y2-y1,
"first-frame": win.current_frame,
})
log.info(self.context)

Expand Down Expand Up @@ -344,11 +347,15 @@ def accept(self):
if(self.cancel_clip_processing):
processing.CancelProcessing()

fps = get_app().project.get("fps")

if(not self.cancel_clip_processing):

# Load processed data into effect
self.effect = openshot.EffectInfo().CreateEffect(self.effect_name)

self.effect.SetJson( '{"protobuf_data_path": "%s"}' % protobufPath )

self.effect.Id(ID)

# Accept dialog
Expand Down
7 changes: 6 additions & 1 deletion src/windows/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ def __init__(self, file=None, clip=None):
self.videoPreview.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
self.verticalLayout.insertWidget(0, self.videoPreview)

# Set aspect ratio to match source content
aspect_ratio = openshot.Fraction(self.width, self.height)
aspect_ratio.Reduce()
self.videoPreview.aspect_ratio = aspect_ratio

# Set max size of video preview (for speed)
self.viewport_rect = self.videoPreview.centeredViewport(self.videoPreview.width(), self.videoPreview.height())
self.viewport_rect = self.videoPreview.centeredViewport(self.width, self.height)

# Create an instance of a libopenshot Timeline object
self.r = openshot.Timeline(self.viewport_rect.width(), self.viewport_rect.height(), openshot.Fraction(self.fps_num, self.fps_den), self.sample_rate, self.channels, self.channel_layout)
Expand Down
Loading