Skip to content

Commit

Permalink
Add frame_id
Browse files Browse the repository at this point in the history
* indicate when the video is processed successfully
  • Loading branch information
bessszilard committed Jul 29, 2020
1 parent 8f7f810 commit 7f77392
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions detectvideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ def main(_argv):
codec = cv2.VideoWriter_fourcc(*FLAGS.output_format)
out = cv2.VideoWriter(FLAGS.output, codec, fps, (width, height))

frame_id = 0
while True:
return_value, frame = vid.read()
if return_value:
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
image = Image.fromarray(frame)
else:
if frame_id == vid.get(cv2.CAP_PROP_FRAME_COUNT):
print("Video processed")
break
raise ValueError("No image! Try with another video format")

frame_size = frame.shape[:2]
image_data = cv2.resize(frame, (input_size, input_size))
image_data = image_data / 255.
Expand Down Expand Up @@ -113,6 +118,8 @@ def main(_argv):
if FLAGS.output:
result = cv2.cvtColor(result, cv2.COLOR_RGB2BGR)
out.write(result)

frame_id += 1

if __name__ == '__main__':
try:
Expand Down

0 comments on commit 7f77392

Please sign in to comment.