物体识别有一段代码:
from imageai.Detection import VideoObjectDetection
import os
execution_path = os.getcwd()
detector = VideoObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath( os.path.join(execution_path , "yolo.h5"))
detector.loadModel()
video_path = detector.detectObjectsFromVideo(
input_file_path = os.path.join(execution_path, "Car - 2165.mp4"),
output_file_path = os.path.join(execution_path, "traffic_detected"),
frames_per_second = 20,
log_progress = True
)
assert isinstance(video_path, object)
print(video_path)
如何在数组(具体来说,矩形等)中显示所选对象的极值点坐标?
detector.detectObjectsFromVideo()函数可以作为参数传递给函数
per_frame_function。处理完每一帧后,将调用传递的函数。此函数在调用时将传递以下参数:frame_number- 帧的序列号output_array- 在帧中检测到的对象数组,由以下形式的字典组成:output_count- 统计:每个类的对象数。例子:为了一起收集这些数据,我会使用Pandas模块:
结果:
整个代码: