我正在构建一个简单的web应用程序,使用HTML和Python在画布上显示图像。我也在使用烧瓶框架。 图片从HTML上传,在Opencv(Python)中处理,然后显示在HTML制作的画布上, 到目前为止我所做的只是上传图片。但我不能在画布上显示。在
这是CSS和HTML代码
p {
font-family: verdana;
font-size: 20px;
}
h2 {
margin-left: 20px;
text-align: center;
}
^{pr2}$
和Python代码
from flask import Flask, render_template, request
import cv2
app = Flask(__name__)
@app.route('/')
def index():
return render_template('test.html')
@app.route('/hello', methods=['GET','POST'])
def hello():
if request.method == 'POST':
image = request.form['Image']
get_image = cv2.imread(image,0)
return cv2.imshow(get_image)
else:
return render_template('test.html')
if __name__ == '__main__':
app.run(host = 'localhost', port = 3000, debug=True)
请告诉我我错过了什么,出了什么问题!!谢谢
使用FileReader API(readAsDataURL)发布您的图像。在
将图像写入file with python(注意base64编码)
然后返回Json with Flask(错误或成功)
根据来自服务器的结果显示图像或错误消息。在
我希望这是足够的信息。快乐的编码
相关问题 更多 >
编程相关推荐