Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions rope/Coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def coordinator():
gui.set_video_slider_length(action[0][1])
action.pop(0)

elif action[0][0] == "update_markers_canvas":
gui.update_markers_canvas()
action.pop(0)


else:
Expand Down
36 changes: 27 additions & 9 deletions rope/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, models):
self.title('Rope-Opal-03a')
self.target_media = []
self.target_video_file = []
self.media_file_name = []
self.action_q = []
self.video_image = []
self.video_loaded = False
Expand Down Expand Up @@ -62,7 +63,6 @@ def __init__(self, models):
self.widget = {}
self.static_widget = {}
self.layer = {}



self.json_dict = {
Expand Down Expand Up @@ -1308,6 +1308,7 @@ def load_target(self, button, media_file, media_type):
self.layer['markers_canvas'].delete('all')
self.markers = []
self.stop_marker = []
self.load_markers_json()
self.add_action("markers", self.markers)


Expand Down Expand Up @@ -1488,6 +1489,7 @@ def temp_toggle_swapper(self, state):

def toggle_rec_video(self):
# Play button must be off to enable record button
self.save_markers_json()
if not self.widget['TLPlayButton'].get():
self.widget['TLRecButton'].toggle_button()

Expand Down Expand Up @@ -1684,17 +1686,33 @@ def sort(e):

# resize canvas
else :
self.add_action("update_markers_canvas", self.markers)

self.layer['markers_canvas'].delete('all')
width = self.layer['markers_canvas'].winfo_width()-20-40-20

for marker in self.markers:
position = 20+int(width*marker['frame']/self.video_slider.get_length())
marker['icon_ref'] = self.layer['markers_canvas'].create_line(position,0, position, 15, fill='light goldenrod')

def save_markers_json(self):
if len(self.markers) == 0 or len(self.media_file_name) == 0:
return
json_file_path = os.path.join(self.json_dict["source videos"], self.media_file_name[0] + "_markers.json")
# Save the markers to the JSON file
with open(json_file_path, 'w') as json_file:
json.dump(self.markers, json_file)

def load_markers_json(self):
if len(self.media_file_name) == 0:
return
json_file_path = os.path.join(self.json_dict["source videos"], self.media_file_name[0] + "_markers.json")
if os.path.exists(json_file_path):
# Load the markers from the JSON file
with open(json_file_path, 'r') as json_file:
self.markers = json.load(json_file)
self.add_action("update_markers_canvas", self.markers)

def update_markers_canvas(self):
self.layer['markers_canvas'].delete('all')
width = self.layer['markers_canvas'].winfo_width()-20-40-20
for marker in self.markers:
position = 20+int(width*marker['frame']/self.video_slider.get_length())
marker['icon_ref'] = self.layer['markers_canvas'].create_line(position,0, position, 15, fill='light goldenrod')


def toggle_stop(self):
if self.stop_marker == self.video_slider.self.timeline_position:
self.stop_marker = []
Expand Down
1 change: 1 addition & 0 deletions rope/VideoManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def load_target_video( self, file ):
self.r_frame_q = []
self.found_faces = []
self.add_action("set_slider_length",self.video_frame_total-1)
self.add_action("update_markers_canvas", self.markers)

self.capture.set(cv2.CAP_PROP_POS_FRAMES, self.current_frame)
success, image = self.capture.read()
Expand Down