Skip to content

Getting Started

After you installed this package, the next step is to import the package into your code and start using the functions.

from botcity.plugins.cloudvision import BotCloudVisionPlugin

As a demonstration of the library, let's build a simple example together that will parse the text from the following image:

Click here to Download

Step 1 of Example

To make the example we will instantiate the plugin and setup our Google Cloud Vision service account key. If you don't have one yet, please refer to the Google Cloud website on how to setup the Vision API and create your key.

# Instantiate the plugin
cloudvision = BotCloudVisionPlugin()
# Setup the path to the service account key credentials JSON file
cloudvision.credentials("<path_to_my>/credentials.json")

Step 2 of Example

Now let's read the text from the image.

# Read the text from the image
cloudvision.read("otter_crossing.jpg")

# Print the text from the image
print(cloudvision.full_text())

The output should look like this:

CAUTION
Otters crossing
for next 6 miles

Complete code

Let's take a look into the complete code:

# Instantiate the plugin
cloudvision = BotCloudVisionPlugin()
# Setup the path to the service account key credentials JSON file
cloudvision.credentials("<path_to_my>/credentials.json")
# Read the text from the image
cloudvision.read("otter_crossing.jpg")

# Print the text from the image
print(cloudvision.full_text())

Pro Tip

This plugin allow you to use method chaining so the code above could be written as:

text = BotCloudVisionPlugin() \
    .credentials("<path_to_my>/credentials.json") \
    .read("otter_crossing.jpg") \
    .full_text()
# Print the text from the image
print(text)

Next Steps

Check our examples and experiment with the API. Let us know where it can be improved.

Have fun automating!

Back to top