Intro and Screen reading - Python plays Grand Theft Auto V p.1

sentdex · 613K views · 2017 · 14:44

Open on YouTube

Computer vision, speech & NLPSelf-driving & autonomous vehiclesIndie game developmenttutorial

Why Stack Overflow recommends it

Stack Overflow users link it as a worked example of capturing a game or screen region in real time with Python and OpenCV, and as inspiration for building game-playing AIs.

Recommended by 1 people across 1 different months, 2017 to 2022.

What it is

The first episode of sentdex's 'Python plays Grand Theft Auto V' series, in which he sets up a Python project to control GTA V, starting with grabbing and displaying the game screen in real time with OpenCV. The longer goal is a self-driving vehicle built on screen capture and a neural network.

What people said

Recommends n1colas.m · 2020-05 · Stack Overflow · on “Deep Q Learning **WITHOUT** OpenAI Gym”

Youtube channel `sentdex` has a excellent playlist on Python Plays: Grand Theft Auto V [this video] that uses Python to create a self-driving car using GTA 5 that may be somewhat related with what you want.

Cites jmadden173 · 2017-08 · Stack Overflow · on “Get position of the crosshair within a Directx game in python”

I have recently gotten in trying to program an AI to play a game after watching the "Python plays GTA5" ( [this video] ) which basically makes a self driving car. Since I do not want to directly copy it as I want to learn how to implement it in TF2 which is a source game. The problem is that the game is played in first person and I would need to get the mouse position within the game in order to train it where to shoot. I have already tried win32 in order to get the mouse position but it just returns that the mouse is in the middle of the screen. Is there any possible way that I could get the position of the crosshair?

Cites Jakub Cichalewski · 2017-12 · Stack Overflow · on “Dealing with pixels in real-time using OpenCV”

I've been through same problem, as I wanted to do same thing. The main problem is that you are using CPU to do all operations, and you are not using much of its power. You may either optimize your program or use more power. Try this: Reading about using GPU with python (e.g. CUDA) Trying to do OpenCV operations on less data - e.g. converting RGB to gray scale, decreasing ROI [this video] OpenCV has GPU module, but only for C++. It is not much information, but I hope it helps.

Cites Parth Sarthi Sharma · 2018-07 · Stack Overflow · on “How to capture my screen with python properly?”

You're capturing the part of the screen which displays the output too. If you don't want to view the output, remove cv2.imshow('window', cv2.cvtColor(screen, cv2.COLOR_BGR2RGB)) . Otherwise move the output screen out of the capture window. Refer to this [this video] . This guys(Sentdex) uses a similar method to capture screen to create a neural network to play GTA5(much later).

Cites doog · 2022-02 · Stack Overflow · on “trying to compare a cv2 window to a saved jpeg”

so as the title says, im trying to compare a cv2 generated live window to a jpeg i have already saved to help create a decently advanced macro im working on. my solution to this was to repeatedly save the live stream to a file on my pc so that i instead only have to compare image to image but its proving to be more difficult than i thought, idk what exactly is wrong either (i was following only the first part of this [this video] tutorial for the creation of the live window) import numpy as np import PIL import keyboard from PIL import ImageGrab import cv2 import time last_time = time.time() path = r'C:\Users\srajp\OneDrive\Desktop\Pranav (temporary)\gaming.jpg' img = cv2.imread(path) path2 = r'C