Video Analytics in 2 Lines of Code

Image for post
Image for post

In this article, I show you how to perform image recognition & video understanding tasks in just 2 lines of code, using TensorFlow.JS

To detect objects :

model = cocoSsd.load();

objects = model.detect(frame);

Model output tested on Olympics horse-riding game..

For video tagging :

model = mobilenet.load();

tags = model.classify(frame);

Model output tested on wild-life documentary films..

To capture Facial Expressions :

model = facemesh.load();

faces = model.estimateFaces(frame);

Model output tested on live video stream to detect facial expressions..

For Hand-Tracking :

model = handpose.load();

result = model.estimateHands(frame);

Model tested on live camera stream to generate music using hand gestures..

Or to move objects in AR / VR..

For body segmentation :

model = bodyPix.load();

pixel_array = model.segmentPersonParts(frame);

Model output tested on live camera stream..

And to create chroma-key effect by replacing background..

Yes, that’s how easy it is to use TensorFlow.JS

See code samples at : https://github.com/pamruta/TensorFlowJS

The rest of the Java Script just loads the video in HTML, scans it frame by frame and displays the output on screen..

Written by

Creative Media Technology || Website: pamruta.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store