Update app.py
Browse files
app.py
CHANGED
@@ -14,8 +14,6 @@ def read_motion_csv(csv_filename):
|
|
14 |
|
15 |
Returns:
|
16 |
A dictionary mapping frame numbers to (dx, dy) offsets.
|
17 |
-
The offsets are the negative cumulative displacements,
|
18 |
-
which can be used to counteract the camera motion.
|
19 |
"""
|
20 |
motion_data = {}
|
21 |
cumulative_dx = 0.0
|
@@ -106,11 +104,21 @@ def process_video(video_file, csv_file, zoom):
|
|
106 |
Accepts an input video file, a motion CSV file, and a zoom factor.
|
107 |
Returns the original video and the stabilized video.
|
108 |
"""
|
109 |
-
#
|
|
|
|
|
|
|
|
|
110 |
if isinstance(video_file, dict):
|
111 |
-
video_file = video_file
|
112 |
if isinstance(csv_file, dict):
|
113 |
-
csv_file = csv_file
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
stabilized_path = stabilize_video_using_csv(video_file, csv_file, zoom=zoom)
|
116 |
return video_file, stabilized_path
|
|
|
14 |
|
15 |
Returns:
|
16 |
A dictionary mapping frame numbers to (dx, dy) offsets.
|
|
|
|
|
17 |
"""
|
18 |
motion_data = {}
|
19 |
cumulative_dx = 0.0
|
|
|
104 |
Accepts an input video file, a motion CSV file, and a zoom factor.
|
105 |
Returns the original video and the stabilized video.
|
106 |
"""
|
107 |
+
# Ensure the video file is provided
|
108 |
+
if video_file is None:
|
109 |
+
raise ValueError("Please upload a video file.")
|
110 |
+
|
111 |
+
# Convert file inputs to file paths if they come as dictionaries
|
112 |
if isinstance(video_file, dict):
|
113 |
+
video_file = video_file.get("name", None)
|
114 |
if isinstance(csv_file, dict):
|
115 |
+
csv_file = csv_file.get("name", None)
|
116 |
+
|
117 |
+
# Check that both file paths are available
|
118 |
+
if video_file is None:
|
119 |
+
raise ValueError("Video file path is missing.")
|
120 |
+
if csv_file is None:
|
121 |
+
raise ValueError("CSV file path is missing. Please upload a CSV file.")
|
122 |
|
123 |
stabilized_path = stabilize_video_using_csv(video_file, csv_file, zoom=zoom)
|
124 |
return video_file, stabilized_path
|