The error that I'm getting on Postman
我的代码:
@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)
或者谁能告诉我如何在 POST 请求中提供图片,因为我认为这就是问题所在。
答案 0 :(得分:0)
可能在此处回答:"Post Image data using POSTMAN"
这不是您通过邮递员发送文件的方式。你所做的是发送一个字符串,它是你的图像的路径,仅此而已。
你应该做的是;
将请求方法设置为 POST 后,单击“正文”选项卡。 选择表单数据。在第一行,您将看到名为 key 和 value 的文本框。将“图像”写入密钥。您将看到默认设置为“文本”的值类型。使其成为文件并上传您的文件。 然后选择“原始”并粘贴您的 json 文件。同样在二元选择旁边,您会看到“文本”被点击。使其成为 JSON。