Recently I started learning image processing using openCV. so I wanted to have fun with it that's why I created this project.it's easy and works good not perfect but good.
the idea is to detect the cactus in the image by openCV and jump by simulating key strokes using the pynput module.
Now let's try it out :
i'm using windows 10 but these steps are the same for any os that can run python
i'm assuming that you have python already installed on your machine
run these commands in your cmd/terminal :
- first install openCV
pip install opencv-python
- install pil
pip install Pillow
install
pynput
pip install pynput
now we are ready to go
first a new tab in google chrome and make sure that the window is half the size of your screen (ore close to that value). try to put the script on your desktop it will make things easier
now type the following in your search bar :
chrome://dino
this will open the game.
please note that in order to work the game has to be in a specific part of your screen as this code captures a small part and process it.
now run the script and start the game py pressing SPACE key
I added some comments in the code to explain things but if you have any questions feel free to contact me.
a very good source to learn about opencv : https://docs.opencv.org/3.4.6/d6/d00/tutorial_py_root.html
Comments
Please log in or sign up to comment.