Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/byronhsu/never-blink
πBlink and lose.
https://github.com/byronhsu/never-blink
blink flask game peerjs react socketio video-streaming
Last synced: 7 days ago
JSON representation
πBlink and lose.
- Host: GitHub
- URL: https://github.com/byronhsu/never-blink
- Owner: ByronHsu
- License: mit
- Created: 2019-06-07T13:46:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-11-22T03:51:53.000Z (about 2 years ago)
- Last Synced: 2024-10-11T17:43:10.345Z (3 months ago)
- Topics: blink, flask, game, peerjs, react, socketio, video-streaming
- Language: JavaScript
- Homepage:
- Size: 92.4 MB
- Stars: 898
- Watchers: 10
- Forks: 68
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Never-Blink
## 1. π Introduction
π Upvote for my [product hunt](https://www.producthunt.com/posts/never-blink)!
Randomly connect to a player around the world and challenge him/her. Remember not to blink!
For full version of demo video, click [here](https://www.youtube.com/watch?v=VCP36k5OqDs&t=59s).
## 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](https://zh.wikipedia.org/wiki/%E6%9C%89%E9%99%90%E7%8A%B6%E6%80%81%E6%9C%BA) 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](./src/play.jsx) or [server.py](./src/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.
```bash
git clone [email protected]:ByronHsu/Never-Blink.git
```2. Install the packages
```bash
# Frontend
npm install
# Backend
pip install -r requirements.txt
```3. Build and Run
```bash
# 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.
4. 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. Because 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](./License)