python - 无法将从烧瓶上传的文件传递到 VideoCapture()
问题描述
这是使用烧瓶让用户上传视频文件的服务器脚本
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
file.save(file_path)
abc.abc(file_path)
flash('File successfully uploaded')
return redirect('/')
else:
flash('Allowed file types are txt, pdf, png, jpg, jpeg, gif')
return redirect(request.url)
abc.abc(file_path)
使用上传的文件并将文件路径传递给cv2.videocapture(file_path)
函数。但是,在文件上传后,实际上并没有发生任何事情,并且对的函数调用videocapture
也没有被执行。这是视频捕获部分的代码,作为单独的 python 脚本
class abc:
def __init__(self, video_url):
self.video_url = video_url
def abc(self):
# Define the video stream
print('here')
cap = cv2.VideoCapture(self.video_url) # Change only if you have more than one webcams
如何解决烧瓶没有将文件传递给 videocapture() 的问题?
解决方案
它应该调用 init 并且不接受传递的参数,一种解决方法是删除类并直接从模块中导入函数并将文件路径作为参数传递并且它可以工作。谢谢凯文
推荐阅读
- sql-server - 安装 SQL Server 2019 CU2 后,SQL Server 代理停止工作
- windows - 在 golang 中运行 windows 命令
- java - 如何使elasticsearch解析相同类型的json对象列表?
- php - PHP MySQL 计数总问题
- flutter - Flutter - 如何更改子小部件语言
- flutter - 在 Flutter 中的 FAB 上方显示 SnackBar / Toast
- c# - Podio C# 第一次使用 API 无法使用密码进行身份验证
- embedded-linux - uboot中的fatload mmc和bootm是什么意思?
- javascript - 超过“10000ms”的赛普拉斯命令超时
- javascript - 从对象数组添加标记