Python Mini-Project
Colour Detection Dino Under Guidances :
Game Nikita Patil
Group Members, Class SE-CMPN-1:
11 Shriya Bijam
66 Nikita Dubey
72 Lalit Vinde
75 Neha Sargar
Content
● Abstract
● Introduction
● Problem Statement
● Principle
● Algorithm
● Flowchart
● Tech Stack
● Future Work
● References
Abstract
● Computer vision is a field of artificial intelligence (AI) that enables computers
and systems to derive meaningful information from digital images, videos and
other visual inputs — and take actions or make recommendations based on
that information.
● Computer vision works much the same as human vision, except humans have
a head start.
● Computer vision has 5 techniques such as Image Classification, Object
Detection, Object Tracking, Semantic Segmentation, Instance Segmentation.
● Computer vision are used in our day to day life such as in google lens, self
driving car, robotics, weapon detection and many more.
Introduction
● The Dinosaur Game, also known as the T-Rex Game, Steve the
Jumping Dinosaur, or Dino Runner is a built-in browser game in
the Google Chrome web browser.
● This game can be accessed by hitting the spacebar when offline
on Google Chrome or by typing chrome://dino or
chrome://network-error/-106 in the URL bar and even some
websites are present to play this game.
Introduction
● The Dino game has been one of the all-time favorite games both
offline and online.
● In this project we innovate an idea to take the gaming experience
of playing Chrome T-Rex to the next level.
● We proposed our system to play a Chrome T-Rex without any
physical interaction, and in a more fun way with the help of colors.
Problem Statement
● The aim of this project is to provide an alternate game play of the
aforementioned T-Rex game through Colour Recognition using Python
and OpenCV.
● The game must be played without the assistance of keyboard, instead
we use two colours to play the game.
● When one colour is shown the dino must jump (imitating pressing of
‘space’ key) while if other colour is detected, dino must duck (imitating
pressing of ‘down arrow’ key)
Algorithm
● Initialize the lower and upper bounds for Blue and Green.
● Turn on the webcam it can be external and internal.
● Read an Image from a webcam and save it in a shape of (3,2) numpy array that
there are such three 2D matrices for R, G, B and then convert it into HSV color
format
● Create a mask for Blue and green color from lower and upper bound of both
color range,
● Find contours separately for both color.
● Find out area for each of the contours separately and filter it out
● If number of blue contours is 1, then, Press “Space” key
● Else check If number of green contours is 1, then, Press “Down” key
● If “esc” key is get Pressed , then terminate the program
● Else, repeat the process by taking the next pic from the webcam.
Flowchart
Flowchart
Tech Stack
● OpenCV :-OpenCV is a huge open-source library for computer vision, machine
learning, and image processing. It can process images and videos to identify
objects, faces or even the handwriting of a human. In this project we have used
the opencv to detect the colour from the camera.
● Pyautogui : Pyautogui is a library that allows you to control the mouse
and keyboard to do various things.It is a cross-platform GUI automation Python
module for human beings.
Tech Stack
Flask : Flask is a lightweight WSGI web application framework. It is designed to
Tech Stack
●
make getting started quick and easy, with the ability to scale up to complex.It
even lets us to render external HTML file.
● Html : HTML (Hypertext Markup Language) is the code that is used to structure
a web page and its content. For example, content could be structured within a
set of paragraphs, a list of bulleted points, or using images and data tables.
● Keyboard : keyboard which is used to get full control of the keyboard. It’s a
small Python library which can hook global events, register hotkeys, simulate
key presses and much more.
Demonstration:
Please click on the image box to play the
demonstration video
Future Work
● Creating sophisticated, elegant graphics of dino games.
● Adding levels in it.
● By using machine learning, training the models so it can easily detect
the colours.
● Increasing flexibility and smoothness of the game by cancelling the
noise around the colours.
● Even we can create a models of colour detection with the help of
machine learning and deep learning which we can apply to any
games.
References
● https://flask.palletsprojects.com/en/2.0.x/
● https://opencv-python-tutroals.readthedocs.io/
en/latest/py_tutorials/py_tutorials.html
● https://youtu.be/SJCu1d4xakQ
● https://blog.paperspace.com/dino-run/
● https://towardsdatascience.com/how-i-built-a-
bot-to-beat-t-rex-run-3252a47cdcc6
● https://youtube.com/playlist?list=PLhhyoLH6Ijfx
VOdVC1P1L5z5azs0XjMsb
Thank You.