Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Image processing through API works on the principle of sending the image via HTTP request and getting a response with the result (contains Context by default, but there are also other response types available). Only one image can be sent per request.

...

heatmap - response contains only the heat maps heatmaps over the image (without the image!)…….

For all those image response types, the serialized context is added to the headers with the header title 'ContextBase64utf'. To get it to json form, you can use this code:

Code Block
languagepy
import base64
import json

# Decode from Base64
context_str = base64.b64decode(response.headers['ContextBase64utf'])
# Load json from string
context = json.loads(context_str)

Testing the API functionality

If you have a running project on a port e.g. 8000, you can test the API by accessing this address in your browser:

Info

http://localhost:8000/api

This displays the testing app, where you can choose to display the last processed image or send a new image to analyze. You can choose the Response type - Context, Image, Annotated image (image with a heatmap) or Heatmap. If the project has Secure image analyze enabled, you also need to enter the API key.

...

If Analyze image is chosen, you can also select the image that will be sent through the API. If response type is different than Context, the default behavior is that the image is sent in the body of the response and the context is sent in the headers - to change this and send both in the body, check the box with Context in body. The detail of the request structure will be displayed.

After you click Send, you will also see the structure of the response in the blue info box, context (as you would see it in Inspection) and optionally an image based on the response type.

...