Skip to content

Commit

Permalink
Small edge case fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HHousen committed Jul 19, 2023
1 parent f7cf4aa commit 657ac05
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lecture2notes/end_to_end/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def copy_all(list_path_files, output_dir, move=False):


def frame_number_from_filename(filename):
return int(re.search(r"(?<=\_)[0-9]+(?=\_|.)", filename).group(0))
try:
return int(re.search(r"(?<=\_)[0-9]+(?=\_|.)", filename).group(0))
except AttributeError:
return None


def frame_number_filename_mapping(path, filenames_only=True):
Expand Down
6 changes: 5 additions & 1 deletion lecture2notes/end_to_end/sift_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ def does_camera_move_all_in_folder(folder_path):
]
images.sort()

if len(images) < 2:
return 0, 0, 0

move_values = []
movement_detection_values = []
previous_image = cv2.imread(images[0])
Expand Down Expand Up @@ -408,7 +411,7 @@ def match_features(
was enabled and no motion was detected.
"""
if do_motion_detection:
movement_detected = does_camera_move_all_in_folder(presenter_slide_path)
movement_detected = does_camera_move_all_in_folder(presenter_slide_path)[0] > 0.05
else:
movement_detected = True

Expand Down Expand Up @@ -438,6 +441,7 @@ def match_features(
all_dst_corners = []
match_successful = False
frame_with_most_content = None
dst_coords = None
previous_category = images[0][1]

for idx, (filename, category) in tqdm(
Expand Down
2 changes: 2 additions & 0 deletions lecture2notes/end_to_end/slide_structure_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ def all_in_folder(path, do_rename=True, **kwargs):
if os.path.isfile(current_path):
image = cv2.imread(current_path)
frame_number = frame_number_from_filename(current_path)
if not frame_number:
continue

if do_rename:
item_directory = os.path.dirname(item)
Expand Down

0 comments on commit 657ac05

Please sign in to comment.