I just started to study OpenCV with Python and was trying to build my first game bot. My thought is: capture the game window frame by frame and analyze the pixels in some specific locations, if the color of those pixels has changed, then press a key to do some automatic operations.
This game needs quick reactions so the FPS is quite important, I have tried the mss and PIL, but the fps in both methods are not enough (30+ with mss and 10+ with PIL's ImageGrab), so I'm wondering if there is any better way to deal with pixels in real-time. Thanks!
Want to continue Jakubs great answer:
Using C++ or something might be a good idea in some cases.
I created a csgo aimbot with opencv, pil, pyautogui and numpy and few other modules, watching sentdex's videos on this subject might give u some idea(link above).
There might be a custom module for GPU cv2
tips for py:
1) lower imagegrab resolution.
2) in imagegrab.grab bbox you can give coordinates on which the grabs will happen instead of full screen.
3) grayscale is 0-255 so it will speed up the process, if u know which colors are in this reaction thingy just pass them to grayscale so u know in which colors to respond to.
Dealing with pixels in real-time using OpenCV