我需要从一个HTML表单的输入类型文件中获取一个图像,然后用opencv裁剪它,但是我不知道如何阅读它,有人能帮助我吗?
超文本:
<form role="form" method="POST" action="update-doc" enctype="multipart/form-data">
<div class="input-group input-group-lg mb-3">
<label class="input-group-text" for="inputGroupFile01">UPLOAD</label>
<input type="file" class="form-control" name="pic" accept="image/png, image/jpeg" id="inputGroupFile01">
</div>
<button type="submit" class="btn btn-primary px-5 shadow">UPLOAD</button>
</form
- Python:
from flask import Flask, render_template, request, url_for, redirect, session, flash
import cv2
profileimg = request.files['pic']
img = cv2.imread(profileimg)
1条答案
按热度按时间8ehkhllq1#
这对我很有效