首页 > 解决方案 > 游戏对象检测

问题描述

我想为 Flappy Bird 创建一个 AI,我想使用对象检测和神经网络(我知道这不是最有效的方法,但这是我需要的方法)。我使用了 ImageAI python 模块,但它并没有真正做我想做的事情。我的代码是:

from imageai.Detection import ObjectDetection
import os

execution_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5"))
detector.loadModel()
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "image.jpg"), output_image_path=os.path.join(execution_path , "imagenew.jpg"))

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

我给了它这张图片,看看它是否知道这是一个对象:

管道图像

但它没有做任何事情。

所以我的问题是:有什么东西可以在没有数据库的情况下检测对象吗?

标签: pythonobject-detection

解决方案


推荐阅读