Skip to content

Commit 9271ec1

Browse files
committed
Videofile output for VideoAnalyser.py
1 parent a180a99 commit 9271ec1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

DeepLabStream.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ def input_frames_for_analysis(self, frames: tuple, index: int):
288288
# passes color frame to analysis
289289
frame = c_frames[camera]
290290
frame_time = time.time()
291-
print("input", index)
292291
self._multiprocessing[camera]['input'].put((index, frame))
293292
if d_maps:
294293
self.store_frames(camera, frame, d_maps[camera], frame_time)
@@ -313,7 +312,6 @@ def get_analysed_frames(self) -> tuple:
313312
self._start_time = time.time() # getting the first frame here
314313
# Getting the analysed data
315314
analysed_index, peaks = self._multiprocessing[camera]['output'].get()
316-
print("output", analysed_index)
317315
skeletons = calculate_skeletons(peaks, ANIMALS_NUMBER)
318316
print('', end='\r', flush=True) # this is the line you should not remove
319317

utils/VideoAnalyser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def create_dataframes(data_output):
4848
resolution = int(video.get(cv2.CAP_PROP_FRAME_WIDTH)), int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
4949
animals_list = ["Animal{}".format(num) for num in range(1, ANIMALS_NUMBER + 1)]
5050

51+
fourcc = cv2.VideoWriter_fourcc(*'DIVX')
52+
output_file = os.path.join(OUT_DIR, "Analysed_" + video_name + ".avi")
53+
video_file = cv2.VideoWriter(output_file, fourcc, 30, resolution)
54+
5155

5256
def start_videoanalyser():
5357
print("Starting DeepLabCut")
@@ -77,6 +81,7 @@ def start_videoanalyser():
7781
else:
7882
out_frame = frame
7983
cv2.imshow('stream', out_frame)
84+
video_file.write(out_frame)
8085
all_rows.append(create_row(index, skeletons, experiment_enabled, experiment.get_trial()))
8186
index += 1
8287
else:
@@ -86,6 +91,8 @@ def start_videoanalyser():
8691
break
8792

8893
experiment.stop_experiment()
94+
video_file.release()
95+
video.release()
8996
create_dataframes(all_rows)
9097

9198

0 commit comments

Comments
 (0)