0

The error that I'm getting on Postman

My Code:

@app.route('/getcoordinates', methods=['GET', 'POST'])
def get_image():
    if request.method == 'POST':
        file = request.files['image'].read()
        #use numpy to construct an array from the bytes
        x = np.fromstring(file, dtype='uint8')
        #decode the array into an image
        img = cv2.imdecode(x, cv2.IMREAD_UNCHANGED)
        #In output we get the x&y coordinates of the face bounding box
        output = give_coordinates(img)
    else:
        return "Error: No image provided. Please specify a image."

    return jsonify(output)

Or can anyone tell me how to give a picture in POST request because I think that's where it's going wrong.

Aziza Kasenova
  • 1,501
  • 2
  • 10
  • 22

1 Answers1

0

Possible answered here: "Post Image data using POSTMAN"

That's not how you send file on postman. What you did is sending a string which is the path of your image, nothing more.

What you should do is;

After setting request method to POST, click to the 'body' tab. Select form-data. At first line, you'll see text boxes named key and value. Write 'image' to the key. You'll see value type which is set to 'text' as default. Make it File and upload your file. Then select 'raw' and paste your json file. Also just next to the binary choice, You'll see 'Text' is clicked. Make it JSON. enter image description here

enter image description here

Swapnil
  • 61
  • 5