I currently have code that I am using to send a single image to a Flask server over HTTP using the Python request library. This is not an image that originates from a file, it's an image that has been opened using OpenCV.
Currently, the code I am using to send the image to the Flask server on the client side is:
adress = (http address)
content_type = 'image/jpeg'
headers = {'content-type': content_type}
_, img_encoded = cv2.imencode('.jpeg', image)
response = requests.post(address, data=img_encoded.tostring(), headers=headers,
auth=HTTPBasicAuth(username, password))
And on the server side, the image is "received" in the following way:
r = request
nparr = np.fromstring(r.data, np.uint8)
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
I would now like to define a new route where I send two images instead of one to the server (the images have to be in the same call because I am performing a single operation that requires both of them at the same time), but I am having no luck with extending the current code to work with two images. I tried encoding two images, and having the data sent in the requests be
data=[img_1_encoded.tostring(), img_2_encoded.tostring()]
but did not have much luck with that.
Any help would be greatly appreciated!