How to Build a Monitoring Application With the Google Cloud Vision API

The setup for this application is fairly simple to demonstrate. It comprises the following:

You can use any microcomputer like Raspberry Pi, Tessel or others with a camera module to monitor the area where the system is setup. In our case, we used a Tessel with the Camera module.

The code running on the Tessel is a simple Node.js app that captures a photo, at a defined interval (30 seconds) and writes this image to the system.

We write a basic Python application next to analyze the images one by one and if it contains certain labels that were detected as part of the LABEL_DETECTION feature then we highlight those.

While we demonstrate the pieces that you will need to accomplish the above step by step, it is easy to see how you could combine them into an overall application and also add some alerting logic of your own.

The Node program is straightforward and even if you do not have a Tessel, you can identify that the initial couple of lines was just to initialize the tessel library and the camera library. The rest of the code is as follows:

Once the Camera module is ready, we use the JavaScript SetInterval function to invoke a piece of code every 5 seconds (5000 milliseconds).

This code, uses the camera module to take a picture and saves it with a unique filename.

Once we begin running the application, over time it will produce images, which you could then analyze using the Cloud Vision API. Of course, we could integrate the Cloud Vision API here directly but the decoupling is done to help you understand different parts of the system and also to effectively demonstrate that your image capturing process could be completely separate.

Python App to Analyze the Image

The Camera image capture and writing those images to the system is not a part of the Google Cloud Vision Workflow. Now that we have the images and want to analyze each of them, let us look at what we need to do to invoke the API.

Here are the steps that are necessary to use the Google Cloud Vision API:

1. Create Google Cloud Platform Project

Head over to the Google Cloud Platform Developers Console and login with your account. Ensure that you have a Billing Account setup with Google Cloud Platform.

Go to the list of all projects for your account and click on the Create Project button to create a new project. This will bring up the form as shown below:

Enter a name for your project and select the Billing account that you want to apply to your project. Click on Create.