Git Product home page Git Product logo

movement_games's Introduction

Movement Games

Ever wondered about playing Subway Surfers with your body movements! I have made a program to synchronize basic body movements with movements in games like Subway Surfers, Temple Run, etc. I have made the program in python using OpenCV(for video and movement detection) and pynput(for keyboard actions).

Prerequisites:

Follow the following instructions to run the code on your local machine.

OpenCV

Install this package using:

pip install opencv-contrib-python

In case the code shows any error try installing:

pip install opencv-python

pynput

Install this package using:

pip install pynput

Installing the Game

You can download the game from anywhere. There are a lot of options present but some of them might not work. I have used Bluestacks to run Subway Surfers.

Using mobile camera as webcam(Optional)

Laptop cameras generally do not have good quality. So I have used Droid Cam to use my mobile camera as a webcam to get a better frame rate and accuracy. If you are doing this then make sure to change the argument of the cv2.VideoCapture(0) to 1 in line number 5.

Running the Code:

After running the code, a window will open. Make a box-like structure(called bounding box) keeping its midpoint on the part of the body to be detected(in my case: tip of nose).

Screenshot (187)

Press Enter and a small circle will appear around that part. Now if you move out of the circumference of the tracking circle, the terminal shows where are you moving. Now start playing the game and move as you want the player to move. HAPPY PLAY!

Setting parameters:

You can always set some parameters according to your convenience:

1)Tracking Circle(outer circle): tracking_circle_radius in line number 27

2)Detection Circle(inner circle): detection_circle_radius in line number 66

3)There are 8 trackers available. MedianFlow works best for me as it provides good accuracy as well as FPS but you can try all of them, as each one has different FPS and accuracy with diffrent sizes of bounding boxes.

Points to Note:

You can run the code on any IDE but my VSCode was giving some issue so I recommend using PyCharm.

Try to keep the camera away from the light as reflection hampers the tracking.

Try to avoid unnecessary movement as the detection circle might displace from its desired position.

The program is not very efficient. It may take you time to get acquainted.

Developers

Sahil Ahuja

Aman Verma

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.