Skip to content

Commit

Permalink
updated to drive version
Browse files Browse the repository at this point in the history
  • Loading branch information
HeshanSudarshana committed Aug 9, 2019
1 parent a82c601 commit 5a5da34
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/centroid_tracker/centroidtracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def update(self, rects):
if len(rects) == 0:
# loop over any existing tracked objects and mark them
# as disappeared
for objectID in self.disappeared.keys():
for objectID in list(self.disappeared.keys()):
self.disappeared[objectID] += 1

# if we have reached a maximum number of consecutive
Expand Down
3 changes: 3 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def run():
fps = 8.0
frames_to_video.convert_frames_to_video(location_to_store_summary_keyframes, output_video_path, output_video_name, fps)

print("No. of keyframes: " + str(len(summary_frame_name_list)))
print("FPS of the output video: " + str(fps))

print(
"\n**************** summary video generated ./test_data/output_video/ location ****************")

Expand Down
60 changes: 60 additions & 0 deletions src/video_to_frames_no_skipping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'''
Within this script, focus to get the frames of the input video file.
Requirements
----
You require OpenCV 3.2 to be installed.
Run
----
If need to run this script seperately, then can edit the releavant input file path and output file path.
If need to use this script within another code then can import the scirpt and call the functions with relevant arguments.
'''

import cv2
import os


def get_frames(video_input_path, frame_output_path):
if os.path.isfile(video_input_path):

# Playing the input video from file
video_capture = cv2.VideoCapture(video_input_path)

try:
if not os.path.exists(frame_output_path):
os.makedirs(frame_output_path)
except OSError:
print('Error: Creating directory of data')

# Capture the very first frame
return_status, frame = video_capture.read()

current_frame = 0
while return_status:
# Saving the current frame's image as a jpg file
frame_location = frame_output_path + "frame" + str(current_frame) + ".jpg"
print("Creating..." + frame_location)
cv2.imwrite(frame_location, frame)
# Increasing the current frame value for the next frame
current_frame += 1

# Capture frame-by-frame
return_status, frame = video_capture.read()

# Release the capture
video_capture.release()
cv2.destroyAllWindows()
else:
print("Invalid input video to capture. Location or the video not exist.")


def run():
video_input_path = "./data/input_video/input_video.mp4"
frame_output_path = "./data/generated_frames/"
get_frames(video_input_path, frame_output_path)


if __name__ == "__main__":
run()

0 comments on commit 5a5da34

Please sign in to comment.