Introduction

CCTV cameras are now everywhere. Large-scale video processing is a grand challenge representing an important frontier for analytics, what with videos from factory floors, Jewellery showroom, traffic intersections, police vehicles, and retail shops. It’s the golden era for computer vision, AI, and machine learning – it’s a great time now to extract value from videos to impact science, society, and business!

I would like to share one recent incident happened in India, TamilNadu. The one of the famous Jewellery store in Trichy has more than 20 securities, and 60 CCTV cameras in surveillance. Two members were wearing animal masks and packing all the jewels in a sack, just like a scene from the movie. The burglars entered the showroom by drilling a hole in the wall which is enough for a man to enter, in the backside of the building. stole almost 100 kgs of gold which is worth Rs 50 crore.

Video surveillance is incredibly useful for helping track down a suspect. Often burglars are intelligent enough to mask their faces, so only facial recognition is not a possibility. However, video surveillance will help identify what the perpetrator looked like by recording height build, hair color, skin color and human body and object recognition and it will alert to showroom manager.

   

 This wiki post will share with how to implement computer Vision and Face API Analyze Videos in Real-time.

How to use Microsoft cognitive services

Perform of the real-time analysis on frames taken from a live video stream and identify the face with extracted the content using vision API, the application will follow the below.

  • Used Microsoft’s Cognitive Face API to identify sentiment person by person.
  • Used Microsoft’s Emotion API to match facial patterns to emotions.
  • Extracted emotion data using Microsoft’s Vision API.
Chart

Let we start implement Live Video analysis, in the following steps


Create Computer Vision API

The Computer Vision API will help developers to identify the objects with access to advanced algorithms for processing images and returning image metadata information.

Step 1: Microsoft Announcing Azure cognitive services free for 12 month, it's fantastic News, Create a free trial Azure subscription account from Azure portal.



Step 2: Create New resource and select the AI+ Machine learning and click on Computer Vision API



Step 3: After this, fill in the following information for creating Cognitive Service and click on "Create".

  • Name - Microsoft recommends a descriptive name for API, for example - <common name><APIName>Account.
  • Subscription - Select the available Azure subscriptions.
  • Location - Select the service locations.
  • Pricing tier - You can choose your pricing tier. F0 is free service and S0 is paid service. Based on your usage, you can choose the pricing tier.
  • Resource group - Select the Resource group > confirm the Microsoft notice and click on "Create" again for creating the account

Step 4: The resource successfully complete after few min and will get confirmation message,you can click on “Go to Resource “ Button .



Step 5: You can capture/copy the Azure commuter vision API Endpoint url and key from All resources.it will while implementing the application.

Create Face API

The Face API will Detect one or more human faces in an image and get back face rectangles for where in the image the faces are, along with face attributes which contain machine learning-based predictions of facial features.

Step 1: You have already login into the Azure portal again click on Create on resource > Select AI + Machine Learning and click on Face  and follow the step 3 and step 4 like computer vision API.

Step 2: You can capture/copy the Azure Face API End point url and key from All resources.it will while implement the application.


Demo Source code

Microsoft Create and released the sample POC application for Video Analysis, let you download and replace the cognitive service API Endpoint url and key. Application contains a library, along with two applications, for analyzing video frames from a webcam in near-real-time using APIs from Microsoft Cognitive Services and use the OpenCvSharp package for webcam support.

Step 1Open the sample in Visual Studio 2019++.
Step 2: Restore all required nuget package. Right click on solutions and select the restore nuget pakages

Step 3: Select the solutions and build the applications. You can change the key and End point url from following files.
  • For BasicConsoleSample, the Face API key is hard-coded directly in BasicConsoleSample/Program.cs.
  • For LiveCameraSample, the keys should be entered into the Settings pane of the app.
They will be persisted across sessions as user data. You can also go change the value from App.config file.

Step 4: Let start run the application. Select your camera and Mode of event.

Summary

In this wiki, you learned how to run real-time analysis on live video streams using the Face, Computer Vision APIs, and how to use Microsoft sample code to get started. Let you start building your app with free API keys and reference sample code.

References