Sometimes I think my little ideas and projects might be interesting to someone else. Maybe even someone far away, or far in the future. [Considering how fast the Earth is moving, the future is pretty far away.] Enjoy!
Thursday, August 22, 2019
Google Vision API and Labview
Two years ago I used Google Vision API with Labview. I've forgotten some of the details, so I'm making this post to record what I remember.
First, the Vision API and documentation, and examples are found here https://cloud.google.com/vision/
[There are not Labview examples]
This is a good starting point https://cloud.google.com/vision/docs/how-to
The Vision API is a cloud service, so you need to create an account.
In Google Cloud Platform you must enable Vision API.
The Vision API will bill you if you go over 1000 images, so you need a payment method. [But there is a free trial that will last for a few months.]
The Vision API uses a key to validate your HTTP request.
The HTTP request will point to an image URL, so your images need to be accessible from the web. Google has cloud storage 'buckets' that your images can be uploaded to. The HTTP request will point to the image URL in the bucket.
Labview has an HTTP client pallet:
Open a Handle.
Add a header Content-Type Application/json
Add a second header Accept-Encoding Application/json
Build the body of the request and POST to the Vision URL.
The body of the response will need to be converted from json.
Finally, close the HTTP request.
---
To parse the json string you need to create a type def that matches the format of the json data.
The type def is made from an array of type "response"
Type "responce" is 2 1D arrays of type "labelAnnotation" and "logoAnnotation"
Type "labelAnnotation" is a cluster of Type string with the label "mid", Type string labeled "description", and Type single labeled "score"
Type "logoAnnotation" is a cluster of Type string with the label "mid", Type string labled "Description" and Type single labeled "score"
I recall that the organization of the TypeDef must match the JSON order, or there will be an error when "Unflatten from JSON" is used.
What you do with the data after that is up to you... I just overlaid the text onto the image.
Here is a screen shot for the whole VI
Youtube results
https://youtu.be/VlVWLpdqbjc
Subscribe to:
Post Comments (Atom)
can you please share the code
ReplyDeleteHi LowTech,
ReplyDeleteI'm also interested by the way to send an image on google Cloud platforme. (Get File Numbox.vi) .
If you can share your code, don't forget to delete the API key.
This is awesome!
ReplyDeleteWould be great if you could show us the working with some image examples?