Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -60,32 +60,31 @@ class VideoProcessor:
|
|
60 |
self.pose = mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5)
|
61 |
|
62 |
def process_video(self, video_file):
|
63 |
-
#
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
cap = cv2.VideoCapture(filename)
|
71 |
-
frame_width = int(cap.get(3))
|
72 |
-
frame_height = int(cap.get(4))
|
73 |
-
out = cv2.VideoWriter(output_filename, cv2.VideoWriter_fourcc(*'h264'), 30, (frame_width, frame_height))
|
74 |
while cap.isOpened():
|
75 |
ret, frame = cap.read()
|
76 |
if not ret:
|
77 |
break
|
78 |
-
|
79 |
-
|
80 |
-
processed_frame = self.process_frame(
|
81 |
-
|
|
|
82 |
cap.release()
|
83 |
-
|
84 |
-
#
|
85 |
-
|
86 |
-
|
|
|
87 |
return output_filename
|
88 |
|
|
|
89 |
|
90 |
def process_frame(self, frame, results):
|
91 |
# Process the frame using the `process` function
|
|
|
60 |
self.pose = mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5)
|
61 |
|
62 |
def process_video(self, video_file):
|
63 |
+
cap = cv2.VideoCapture(video_file.name) # Open the video file
|
64 |
+
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
65 |
+
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
66 |
+
fps = cap.get(cv2.CAP_PROP_FPS)
|
67 |
+
|
68 |
+
frames = []
|
69 |
+
|
|
|
|
|
|
|
|
|
70 |
while cap.isOpened():
|
71 |
ret, frame = cap.read()
|
72 |
if not ret:
|
73 |
break
|
74 |
+
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
75 |
+
# Process the frame (replace this with your processing logic)
|
76 |
+
processed_frame = self.process_frame(rgb_frame)
|
77 |
+
frames.append(processed_frame) # Append processed frame
|
78 |
+
|
79 |
cap.release()
|
80 |
+
|
81 |
+
# Write processed frames to video
|
82 |
+
output_filename = "processed_video.mp4"
|
83 |
+
mediapy.write_video(output_filename, frames, fps=fps)
|
84 |
+
|
85 |
return output_filename
|
86 |
|
87 |
+
|
88 |
|
89 |
def process_frame(self, frame, results):
|
90 |
# Process the frame using the `process` function
|