这是使用flask让用户上传视频文件的服务器脚本
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()的问题?