AttributeError:“VideoObjectDetection”对象没有属性“detectObjectsFromImage”

2024-04-30 05:51:33 发布

您现在位置:Python中文网/ 问答频道 /正文

尝试使用ImageAI创建对象检测程序。ImageAI文档中有detectObjectsFromImage命令,但当我尝试使用此命令时

AttributeError: 'VideoObjectDetection' object has no attribute 'detectObjectsFromImage'

代码:

    from imageai.Detection import VideoObjectDetection
UAVImages = os.listdir("UAV")
randomFile = UAVImages[random.randint(0, len(UAVImages) - 1)]

detectedImage, detections = detector.detectObjectsFromImage(output_type="array", input_image="UAV/{0}".format(randomFile), minimum_percentage_probability=30)
convertedImage = cv.cvtColor(detectedImage, cv.COLOR_RGB2BGR)
showImage(convertedImage)

for eachObject in detections:
    print(eachObject["name"] , " : ", eachObject["percentage_probability"], " : ", eachObject["box_points"] )
    print("--------------------------------")

Tags: 命令cvprobabilityprintpercentageuavimageaidetections