Playing chrome’s dino game by physically jumping and crouching

Original article was published by Theodoros Ntakouris on Deep Learning on Medium


Overcoming Tech Barriers

Setting up a small webpage with basic javascript support to get a webcam feed and a dino game container is trivial for seasoned developers. All you need is latest chrome, a <video> tag, some JavaScript snippets to load a webcam feed from stackoveflow and the ripped t-rex game.

Moving on to the interesting part. Movement/Action detection.

Tensorflow Lite has open — sourced a lot of fine — tuned models for web or mobile usage. I decided to use the full (both lower and upper body) pose detector. You can import tensorflow lite for javascript as well as the model I am using here, by adding these 2 lines inside your <head> .

With every dependency downloaded and ready, we can start by handling the camera element’s loadeddata event.

Once the webcam is ready, load the model and start a pose prediction loop.

I’ve also included a small recording play/pause functionality by just adding an on — click event on the video feed container.