Open eldonluk opened 5 years ago
Can you share your video detection code? What is the length of your video input?
`from imageai.Detection import VideoObjectDetection import os
execution_path = os.getcwd()
detector = VideoObjectDetection() detector.setModelTypeAsRetinaNet() detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5")) detector.loadModel()
video_path = detector.detectObjectsFromVideo(input_file_path=os.path.join( execution_path, "768.mp4"), output_file_path=os.path.join(execution_path, "768_detected"), frames_per_second=50, log_progress=True) print(video_path) `
Above is the code I've been using. The videos I have been passing vary from 10 seconds to minutes long, but all of them clip to 2 seconds when the detections are generated.
Your frames_per_second
is pretty high 50
. If the FPS of your videos are much less than 50, then the generated video will be shorter.
Awesome! I dropped it down to 10 and it lengthened the video to 6 seconds. Is there anyway to guarantee that is can run detections on the full length of my video?
Use the code below to obtain the frame per second for your video. Then use the value in your detection.
import cv2
if __name__ == '__main__' :
video = cv2.VideoCapture("video.mp4");
fps = video.get(cv2.CAP_PROP_FPS)
print "Frames per second of video: {0}".format(fps)
video.release()
I ran the code and found out all my videos have a fps of 59.94005994005994. When I put that in, it shrinks my video back to just the first second. I think it is only running detections on the first 57 frames of my video each time, as that is what my command terminal gets to when I run the code. Do you know how to have it run on more frames than the first 57?
Until such time we can figure out why only the first second of your video is detected, you can use OpenCV to obtain the frames from the video and feed it into the ObjectDetection class to process each frame individually as a numpy array and process the result for saving/displaying as a video. Visit the ImageAI documentation linked below on this.
Sounds great! I will definitely check it out! Thank you so much for all your help!
ELDON LUK Data Scientist Intern (703) 788-0010 Direct (571) 338-2828 Mobile (703) 288-0012 Fax
[Connect with us!]http://bit.ly/1HKPjoP CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed and may contain confidential and privileged information protected by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please notify the sender immediately by return e-mail and delete all copies from your system.
From: MOSES OLAFENWA notifications@github.com Sent: Saturday, December 21, 2019 4:47 PM To: OlafenwaMoses/ImageAI ImageAI@noreply.github.com Cc: Eldon Luk eldon.luk@ntconcepts.com; State change state_change@noreply.github.com Subject: Re: [OlafenwaMoses/ImageAI] Video Detection Trims Video clip (#293)
Until such time we can figure out why only the first second of your video is detected, you can use OpenCV to obtain the frames from the video and feed it into the ObjectDetection class to process each frame individually as a numpy array and process the result for saving/displaying as a video. Visit the ImageAI documentation linked below on this.
https://imageai.readthedocs.io/en/latest/
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/OlafenwaMoses/ImageAI/issues/293?email_source=notifications&email_token=AMMYXGXVOG5XSXGOS66MBOLQZ2FDTA5CNFSM4IMKWGMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHPEFQQ#issuecomment-568214210, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMMYXGR5VSVCSXWPPYDTQQTQZ2FDTANCNFSM4IMKWGMA.
When I try running the Video Object Detection, the resulting detection clip is trimmed to just 2 seconds long, even though my video is longer. Does anyone know how to resolve this issue?