Darknet: Videos flipped when running YOLO detection

Created on 24 Sep 2017  路  4Comments  路  Source: pjreddie/darknet

I built YOLO with GPU, CuDnn and OpenCV.

I am running a test on a video I created. However, the video is displayed upside down. Hence, the detection is quite bad.

What should I do to get my video on the right side?

EDIT:

I used the following command:

./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights ~/Videos/test_vid_2.mp4

Here is a screenshot:

flipped_yolo

Most helpful comment

try running

s蕠丧苾岽壡澥嵥檕lo蕩 苾蔁蓴藱olo蕩/苾蔁蓴 蓯蕠蓯p藱o蓴o蓴/苾蔁蓴 o莎菨p 晒o蕠蓴菨蕠菨p 蕠菨u蕿晒蓯p/藱

instead

All 4 comments

what command did you use?Any screenshot?

Try opening the video in OpenCV.
If the video is displayed upside down, then check for the video file property 'Rotation' or 'Composite:Rotation' using some exif-reader tool e.g. exiftool. If it says any value other than 0 then probably you want to first save the video in right orientation.

try running

s蕠丧苾岽壡澥嵥檕lo蕩 苾蔁蓴藱olo蕩/苾蔁蓴 蓯蕠蓯p藱o蓴o蓴/苾蔁蓴 o莎菨p 晒o蕠蓴菨蕠菨p 蕠菨u蕿晒蓯p/藱

instead

You might need to use a tool like avconv to flip the video:
sudo apt-get install libav-tools libavcodec-extra
avconv -i original.mp4 -vf "vflip" -codec:v libx264 -preset slow -crf 20 -codec:a copy flipped.mp4

Below is some python code to show the original video's OpenCV output:

# USAGE
# python testshowvideocv.py --video myvid.mp4

# import the necessary packages
import argparse
import cv2

# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-v", "--video",
help="path to the (optional) video file")
args = vars(ap.parse_args())

camera = cv2.VideoCapture(args["video"])

# keep looping
while True:
# grab the current frame
(grabbed, frame) = camera.read()

# if we are viewing a video and we did not grab a frame,
# then we have reached the end of the video
if args.get("video") and not grabbed:
    break

# blur frame, and convert it to the HSV
# color space
blurred = cv2.GaussianBlur(frame, (11, 11), 0)
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

# show the frame to our screen
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF

# if the 'q' key is pressed, stop the loop
if key == ord("q"):
    break

# cleanup the camera and close any open windows
camera.release()
cv2.destroyAllWindows()

Was this page helpful?
0 / 5 - 0 ratings