...
Code Block |
---|
import requests import cv2 import numpy as np import base64 import json port = '80508000' request_session = requests.Session() response = requests.get( url=f'http://127.0.0.1:{port}/last_image?response_type=annotated_image', headers={'Content-Type': 'application/octet-stream'} ) # Decode and show image with heatmap img = cv2.imdecode(np.frombuffer(response.content, np.uint8), 1) cv2.imshow("Image", img) cv2.waitKey(0) # Decode context from Base64 context_str = base64.b64decode(response.headers['ContextBase64utf']) # Load json from string context = json.loads(context_str) print(context) |
...
Code Block |
---|
import requests import cv2 import numpy as np import json port = '80508000' request_session = requests.Session() response = requests.get( url=f'http://127.0.0.1:{port}/last_image?response_type=annotated_image&context_in_body=t', headers={'Content-Type': 'application/octet-stream'} ) # Get image length img_len = int(response.headers['ImageLen']) # Decode and show image with heatmap img = cv2.imdecode(np.frombuffer(response.content[:img_len], np.uint8), 1) cv2.imshow("Image", img) cv2.waitKey(0) # Get and print context context = json.loads(response.content[img_len:]) print(context) |
...