【发布时间】:2021-08-18 07:43:48
【问题描述】:
我正在尝试上传图像并使用接收到的图像运行 opencv。 它说文件上传成功,但是我不知道如何设置使用上传图像的路径而不是img部分的绝对路径。 这是文件上传。
@app.route('/', methods = ['GET', 'POST'])
def uploader_file():
if request.method == 'POST':
f = request.files['file']
f.save(secure_filename(f.filename))
return redirect(url_for('test'))
这是html
<html>
<head>
<title>얼굴황금비율인식AI</title>
</head>
<body>
<h1>얼굴황금비율인식 AI</h1>
<img src="{{ url_for('video_feed') }}">
<h2>사진을 업로드 해주세요</h2>
<form action = "" method= "POST"
enctype = "multipart/form-data">
<input type = "file" name = "file"/>
<input type = "submit"/>
</form>
</body>
</html>
不知道如何设置接收文件的图片路径。
img = "C:\\Users\\20khj\\Desktop\\photo.jpg"
img = cv2.imread("C:\\Users\\20khj\\Desktop\\photo.jpg")
【问题讨论】:
标签: python flask image-upload