GithubHelp home page GithubHelp logo

hhy5277 / never-blink Goto Github PK

View Code? Open in Web Editor NEW

This project forked from byronhsu/never-blink

0.0 2.0 0.0 94.59 MB

πŸ‘€Blink and lose.

License: MIT License

Python 38.88% JavaScript 60.38% HTML 0.74%

never-blink's Introduction

Never-Blink

1. πŸŽ‰ Introduction

Randomly connect to a player around the world and challenge him/her. Remember not to blink!

For full version of demo video, click here.

2. πŸ“œ Implementation

1. Project structure

.
β”œβ”€β”€ backend
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ detect.py
β”‚   └── shape_predictor_68_face_landmarks.dat (detect model)
β”œβ”€β”€ package.json
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ server.py
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ app.jsx
β”‚   β”œβ”€β”€ index.js
β”‚   β”œβ”€β”€ play.jsx
β”‚   └── start.jsx
β”œβ”€β”€ static
β”‚   └── bundle.js
β”œβ”€β”€ templates
β”‚   └── index.html
└── webpack.config.js

We use react as our frontend framework, and use peerjs to communicate between clients. At backend, we use flask to host the server. For connection between clients and server, we use socketio to implement real-time data transfer.

2. Game State

We use the notion of Finite State Machine to design our game state. The circle is the state. The text in the top of each box is the event causing state transition, and the text in the bottom of each box is the action taken when event occurs. The logic looks quite simple here, but it is not that easy to implement. For more detail you can check play.jsx or server.py.

3. πŸ’» Development

I spent lots of time formatting my code and writing comments to make it as readable as possible. Hope you enjoy 😊

  1. Clone this repo.
git clone [email protected]:andyh0913/blink_contest.git
  1. Install the packages
# Frontend
npm install
# Backend
pip install -r requirements.txt
  1. Build and Run
# Build frontend files
npm run build
# Run server
npm run start

Every time you changed your code, you should run the above command again. We do not support hot module replacement now.

  1. Start and Enjoy

Goto https://0.0.0.0:3000

0.0.0.0:3000 does not work, remember to add https.

4. 🚧 Problem

  1. Becausee the detector is too slow and weak, we can not endure too many clients. Therefore, we do not deploy it to a public server now. We plan to train a robust and fast model in the future.
  2. When restarting, the old media connection listener will be called again. So we remove restart temporarily.

5. πŸ“– Reference

  1. Environment setup: https://github.com/rwieruch/minimal-react-webpack-babel-setup
  2. Simple P2P WebRTC package: https://github.com/peers/peerjs
  3. Socket-io: https://socket.io/docs/client-api/
  4. Flask-socketio: https://flask-socketio.readthedocs.io/en/latest/
  5. Blink detector: https://github.com/dilawar/eye-blink-detector
  6. Material UI: https://material-ui.com/

6. πŸ—žοΈ License

MIT Licensed

never-blink's People

Contributors

andyh0913 avatar byronhsu avatar edjw avatar

Watchers

 avatar  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.