...
The sending address consists of the IP address, port, type, and optionally further query parameters. The request method must be of ‘POST’ type , and the content type of ‘application/octet-stream’ type.
...
If the project is running with the “Secure image analyze” option enabled, each request in the parameter query must contain the API key that is generated after you enable this option.
...
You can add extra information to the request. This string will be added to the context (the key is data). It is available only in the Code module (context variable).
Code Block | ||
---|---|---|
| ||
'http://127.0.0.1:8000/analyze_image?data=SomeInfo' |
In the Code module you can access this string using:
...
Used for sending the image as raw data. For example, the numpy NumPy array in Python is converted to binary format.
...
Example of a Python code sending requests with raw images from the camera:
Code Block | ||||
---|---|---|---|---|
| ||||
import cv2 import requests cap = cv2.VideoCapture(0) # you can set frame size # cap.set(cv2.CAP_PROP_FRAME_WIDTH, 960) # cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 540) # keep alive request_session = requests.Session() while True: # get frame from camera ret, frame = cap.read() # get image shape shape = frame.shape # send frame to PEKAT VISION response = requests.post( url='http://127.0.0.1:8000/analyze_raw_image?width='+str(shape[1])+'&height='+str(shape[0]), data=frame.tobytes(), headers={'Content-Type': 'application/octet-stream'} ) print(response.json()) |
...
Code Block | ||
---|---|---|
| ||
'http://127.0.0.1:8000/analyze_image?api_key=SUPER_SECRET' |
Example Python code which that sends images from a folder to the Pekat project with an API key:
Code Block | ||||
---|---|---|---|---|
| ||||
import requests import os request_session = requests.Session() for image in os.listdir('images_folder'): with open(os.path.join('images_folder', image), 'rb') as image: response = requests.post( url='http://127.0.0.1:8000/analyze_image?api_key=728a9180-8357-11ec-b645-e917eb5f5d27', data=image.read(), headers={'Content-Type': 'application/octet-stream'} ) print(response.json()) |
...
Python code which gets the last processed image with heatmap and shows it , then prints out the context.
...