darknet icon indicating copy to clipboard operation
darknet copied to clipboard

For testing and saving videos using darknet_video.py

Open Sambhav300899 opened this issue 4 years ago • 0 comments

1.If a video was loaded from the file, the loop doesn't break and frame_read is then None. The following line gives an error due to frame_read being of None type

frame_rgb = cv2.cvtColor(frame_read, cv2.COLOR_BGR2RGB)  

therefore added the following, it breaks out of the loop when the video file ends.

if ret == False:
  break

2.The output frames were not being written to the file by the VideoWriter, the following will write the processed frame to the file

out.write(video) 

3.The output writer in the current code writes the frames which are equivalent(in size) to the input of YOLO. To preserve the aspect ratio I made some changes to the arguments of the video writer by passing w,h and fps according to the input video and resized the image after model inference and post processing(drawing bounding boxes and RGB2BGR).

  1. Another change i thought of but didnt know if it was required or not was just adding the video path as an input path or prompting for the video path and output file path etc. Or writing a single script for passing a single image, video or file containing them would also make it easier for users

Sambhav300899 avatar Apr 29 '20 15:04 Sambhav300899