Skip to content

Instantly share code, notes, and snippets.

@maranemil
Last active June 1, 2018 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maranemil/1b52b6e1566d273002f357769f646579 to your computer and use it in GitHub Desktop.
Save maranemil/1b52b6e1566d273002f357769f646579 to your computer and use it in GitHub Desktop.
Video object detection without GPU wirth post-processing FFMPEG and DarkNet YoloV2
# create in yolo git folder a new one
mkdir jpg2
# extract images from video into folder, down scaling video from 1280x720 (1920x1080)
# start video from secind 26, run first 33 seconds of video
ffmpeg -ss 00:00:26.000 -i myvid.mp4 -s 640x360 -t 00:00:33 -r 6 jpg2/vid_%04d.jpg
# detect object in every image
# for f in jpg2/*.jpg; do echo "$f"; done
# run yolo detection on each image with yolo3 and weights for yolov3
for f in jpg2/*.jpg; do ./darknet detect cfg/yolov3.cfg yolov3.weights "$f" -out "$f"_out; done
# version with yolo2 and weights for yolov2
# for f in jpg4/*.jpg; do ./darknet detect cfg/yolov2.cfg yolov2.weights "$f" -thresh 0.1 -out "$f"_out; done
# tiny yolo for video 320x180 format - but nothing detected :/
# for f in jpg2/*.jpg; do ./darknet detect cfg/yolov1-tiny.cfg yolo-tiny.weights "$f" -out "$f"_out; done
# rebuild merge images into video
#ffmpeg -framerate 1 -pattern_type glob -i '*.jpg' -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
ffmpeg -framerate 1 -r 10 -pattern_type glob -i '*.png' -c:v libx264 -r 30 -pix_fmt yuv420p out4.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment