()
| 12 | import cv2 |
| 13 | |
| 14 | def test(): |
| 15 | ip = 'localhost' |
| 16 | port = '8084' |
| 17 | user_define_string = 'content' |
| 18 | url = f'http://{ip}:{port}/analyze/{user_define_string}' |
| 19 | img = cv2.imread("./test.jpg") |
| 20 | _, data = cv2.imencode(".jpg", img) |
| 21 | data = data.tobytes() |
| 22 | |
| 23 | headers = {'Content-Length': f'{len(data)}', 'Content-Type': 'image/*'} |
| 24 | res = requests.post(url, data=data, headers=headers) |
| 25 | print(res.content) |
| 26 | |
| 27 | |
| 28 | if __name__ == "__main__": |