Update utils/object_detection_brainai.py
Browse files
utils/object_detection_brainai.py
CHANGED
|
@@ -49,7 +49,7 @@ class ObjectDetectionModel():
|
|
| 49 |
camera = cv2.VideoCapture(temporary_location)
|
| 50 |
fps = camera.get(cv2.CAP_PROP_FPS)
|
| 51 |
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.mp4')
|
| 52 |
-
|
| 53 |
total_frames = int(camera.get(cv2.CAP_PROP_FRAME_COUNT))
|
| 54 |
progress_bar = st.progress(0)
|
| 55 |
frame_count = 0
|
|
@@ -61,7 +61,7 @@ class ObjectDetectionModel():
|
|
| 61 |
if ret:
|
| 62 |
img_plot, _ = self.process_image(frame)
|
| 63 |
st_frame.image(img_plot, channels = "BGR")
|
| 64 |
-
|
| 65 |
frame_count +=1
|
| 66 |
progress_bar.progress(frame_count/total_frames, text = None)
|
| 67 |
|
|
@@ -70,7 +70,7 @@ class ObjectDetectionModel():
|
|
| 70 |
st_frame.empty()
|
| 71 |
progress_bar.empty()
|
| 72 |
break
|
| 73 |
-
clip = mpy.ImageSequenceClip(
|
| 74 |
clip.write_videofile(temp_file.name)
|
| 75 |
|
| 76 |
return temp_file.name
|
|
|
|
| 49 |
camera = cv2.VideoCapture(temporary_location)
|
| 50 |
fps = camera.get(cv2.CAP_PROP_FPS)
|
| 51 |
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.mp4')
|
| 52 |
+
processed_frames=[]
|
| 53 |
total_frames = int(camera.get(cv2.CAP_PROP_FRAME_COUNT))
|
| 54 |
progress_bar = st.progress(0)
|
| 55 |
frame_count = 0
|
|
|
|
| 61 |
if ret:
|
| 62 |
img_plot, _ = self.process_image(frame)
|
| 63 |
st_frame.image(img_plot, channels = "BGR")
|
| 64 |
+
processed_frames.append(cv2.cvtColor(img_plot,cv2.COLOR_BGR2RGB))
|
| 65 |
frame_count +=1
|
| 66 |
progress_bar.progress(frame_count/total_frames, text = None)
|
| 67 |
|
|
|
|
| 70 |
st_frame.empty()
|
| 71 |
progress_bar.empty()
|
| 72 |
break
|
| 73 |
+
clip = mpy.ImageSequenceClip(processed_frames,fps=fps)
|
| 74 |
clip.write_videofile(temp_file.name)
|
| 75 |
|
| 76 |
return temp_file.name
|