Object detection in Grand Theft Auto San Andreas using AI

Karthick Nambi
Predict
Published in
2 min readOct 30, 2019

--

This article is a continuation of Self driving Grand Theft Auto car in 100 lines of code . The objective of this series is to use Grand Theft Auto or any other game for AI development.

GTA SA has a rich environment of objects and different viewpoints while driving the vehicle.

Project 2: Object Detection in GTA

The idea is to use YOLO to perform object detection in GTA environment

Prerequisites:

1. GTA San Andreas (put d3d9.dll in the installation path so that GTA will start in a minimized window)

2. Anaconda

Getting the inputs and outputs:

The input to the YOLO model is a screenshot of the game window using image grab

img1 = ImageGrab.grab(bbox=(0,200,800,400))

The grabbed image is then passed to YOLO model to print prediction

detections = detector.detectObjectsFromImage(input_image=’img1.jpg’, output_image_path=’combo.jpg’, minimum_percentage_probability=30)

The predcited image is printed as frame after frame while gives a view of a video stream

Output:

Traffic light detection

Traffic light detection

--

--

Karthick Nambi
Predict

A human with interest in history and technology