The Vision API from Google Cloud has multiple functionalities. In this article, we will see how to access them. Before using the API, you need to open a Google Developer account, create a Virtual Machine instance and set up an API. For that, refer to this article.
We need to download the following packages –
pip install google.cloud.vision
The various services performed by Google Vision API are –
It can detect multiple faces in an image and express the emotional state of the faces.
Save the ‘credetials.json’ file in the same folder as the .py file with the Python code. We need to save the path of ‘credentials.json’ (C:\Users\…) as ‘GOOGLE_APPLICATION_CREDENTIALS’ which has been done in line-7 of the following code.
The above code detects multiple faces in a picture and determines the emotional expressions exhibited by the faces and whether any of the faces is wearing a headgear. It also returns the vertices which form a rectangle around the individual faces.
Lastly, it prints the percentage of surety with which the conclusions were drawn.
For example, when the following image is given as input –
Possibility of anger: VERY_UNLIKELY Possibility of joy: VERY_LIKELY Possibility of surprise: VERY_UNLIKELY Possibility of sorrow: VERY_UNLIKELY Vertices covering face: [(115, 84), (308, 84), (308, 309), (115, 309)] Confidence in Detection: 99.93739128112793%
Detects popular product logos present in an image.
The above code detects the logos of various companies in an image and prints the name of the companies. For example, when given the following image:
Detects broad sets of categories in an image, which ranges from animals, trees to vehicles, buildings etc.
All possible labels or tags are attched to an image. For example, when the following image is given as input:
Street Neighbourhood Café Coffeehouse Sitting Leisure Tourism Restaurant Street performance City
Detects famous landmarks (mostly man-made) within an image.
The above code recognizes any famous landmark and also returns the location of that landmark using latitudes and longitudes. For example, when we input the following picture:
Victoria Memorial Latitude: 22.545121, Longitude: 88.342781
For more information, visit the Google Vision API documentation here.
- How to use Vision API from Google Cloud | Set-2
- Translation and Natural Language Processing using Google Cloud
- Computer Vision - Introduction
- Cyber Security in Cloud computing
- How to use Google Colaboratory for Video Processing
- Who Will Win The Quantum Supremacy Debate: Google or IBM?
- Getting started with the Google Coral USB accelerator
- Audio processing using Pydub and Google speechRecognition API
- MongoDB CRUD operations
- MongoDB Projection
- MongoDB - Query Documents using Mongo Shell
- PHP | DOMElement getAttributeNS() Function
- MongoDB - Delete Multiple Documents Using MongoShell
- MongoDB - Delete Single Document Using MongoShell
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.