Giter Site home page Giter Site logo

dinoplay's Introduction

DinoPlay

Play chrome Dino with your smile! Used lib OpenCv.

How it works?

OpenCv library has pretrained Haar cascade models. At first we are detecting face. If face is detected, we are looking for a smile. When we are smiling Dino is happy so he jumps! Now we can play Dino without touching keyboard!

1. Open new Chrome tab with Dino game.

s1

2. Initialize pretrained Haar model.

In variable "cap" we define which camera we will be using.
s2

3. While loop.

We use while(True) loop for continous capturing frames from camera.
s3

4. Function detectMultiScale() is used to detect faces.

This function works only on black-white frames so we have to convert RGB frame.
s4

5. Drawing rectangle on detected face.

If face is detected, variable faces will contains table with [X_up_left_corner,Y_up_left_corner, Width_of_face, Height_of_face]. X of the down right corner = X_up_left_corner + Width_of_face Y of the down right corner = Y_up_left_corner + Height_of_face
s5

6.Crop out detected face for smile detection.

For smile detection, face have to be in black-white as well.
s6

7. Drawing rectangle on the detected face.

If smile is detected, code artificially create pressing key "UP".

s7

8. After all detection and drawing we have to show image in a frame.

If we want to break the loop we press 'Q'.
s8

9. When everything done, release the capture.

s9

Me playing Dino:

https://www.youtube.com/watch?v=aYPh4HTYxdc

dinoplay's People

Contributors

dataprofunda avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.