Sending image to the flask server and do object detection on that and send back that image as a response and no of object detected variable value. Flask route function is as below
@app.route('/upload', methods=['POST'])
def upload_file():
file = request.files['image']
im = Image.open(file)
total_count = 0
for i in keypoints:
total_count = total_count + 1
im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (0, 0, 255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
file_object = io.BytesIO()
img = Image.fromarray(im_with_keypoints.astype('uint8'))
# write PNG in file-object
img.save(file_object, 'JPEG')
# move to beginning of file so `send_file()` it will read from start
file_object.seek(0)
return send_file(file_object, mimetype='image/jpeg')
when I do post a request by uploading an image I get the processed image back on POSTMAN but I need to get the value of variable total_count along with the image. I tried calling like this
return '{} {}'.format(total_count,send_file(file_object, mimetype='image/jpeg'))
but I got output as 11 <Response streamed [200 OK]>
where the image is stored as object form, is there a way to get the image along with the total_count value as a response?
Any suggestion or example on the way of getting both response which is Image and variable total_count?