Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -62,10 +62,9 @@ class VideoProcessor:
|
|
| 62 |
def process_video(self, video_file):
|
| 63 |
# Get the filename from the file object
|
| 64 |
filename = "temp_video.mp4"
|
| 65 |
-
#
|
| 66 |
with open(filename, 'wb') as temp_file:
|
| 67 |
temp_file.write(video_file.read())
|
| 68 |
-
|
| 69 |
# Process the video and save the processed video to a new file
|
| 70 |
output_filename = "processed_video.mp4"
|
| 71 |
cap = cv2.VideoCapture(filename)
|
|
@@ -82,12 +81,11 @@ class VideoProcessor:
|
|
| 82 |
out.write(processed_frame)
|
| 83 |
cap.release()
|
| 84 |
out.release()
|
| 85 |
-
|
| 86 |
# Remove the temporary file
|
| 87 |
os.remove(filename)
|
| 88 |
-
|
| 89 |
# Return the path to the processed video file
|
| 90 |
return output_filename
|
|
|
|
| 91 |
|
| 92 |
def process_frame(self, frame, results):
|
| 93 |
# Process the frame using the `process` function
|
|
|
|
| 62 |
def process_video(self, video_file):
|
| 63 |
# Get the filename from the file object
|
| 64 |
filename = "temp_video.mp4"
|
| 65 |
+
# Open the file and read its contents
|
| 66 |
with open(filename, 'wb') as temp_file:
|
| 67 |
temp_file.write(video_file.read())
|
|
|
|
| 68 |
# Process the video and save the processed video to a new file
|
| 69 |
output_filename = "processed_video.mp4"
|
| 70 |
cap = cv2.VideoCapture(filename)
|
|
|
|
| 81 |
out.write(processed_frame)
|
| 82 |
cap.release()
|
| 83 |
out.release()
|
|
|
|
| 84 |
# Remove the temporary file
|
| 85 |
os.remove(filename)
|
|
|
|
| 86 |
# Return the path to the processed video file
|
| 87 |
return output_filename
|
| 88 |
+
|
| 89 |
|
| 90 |
def process_frame(self, frame, results):
|
| 91 |
# Process the frame using the `process` function
|