我使用 ImageAI 检测视频中的车辆,我的要求是将检测到的车辆作为图像保存在一个单独的文件夹中,因为视频正在处理。给出了我使用的代码。
from imageai.Detection import VideoObjectDetection
import os
execution_path = os.getcwd()
detector = VideoObjectDetection()
detector.setModelTypeAsTinyYOLOv3()
detector.setModelPath( os.path.join(execution_path , "yolo-tiny.h5"))
detector.loadModel()
custom_objects = detector.CustomObjects( motorcycle=True, car=True, bus=True,truck=True,)
video_path = detector.detectCustomObjectsFromVideo(custom_objects=custom_objects,
input_file_path=os.path.join(execution_path,
'C:\\Users\\priyan\\Desktop\\Number plate identification\\Test
Videos\\test04.mp4'),output_file_path=os.path.join(execution_path,
"traffic_custom_detected"),frames_per_second=20, log_progress=True)
print(video_path)