问题描述
我正在尝试将我的 flir Lepton 的视频源流式传输到网页。我给自己弄了一些代码,我还没有完全理解。我是烧瓶新手。 但是,我让相机在 VLC 和一个简单的 python 脚本中工作,该脚本捕获 200 帧并将它们保存到视频文件中。 正如我在标题中所说,我使用 OpenCV 来完成所有这些,但似乎无法“获取”相机。尝试连接到网站时,出现“无法读取”打印输出。 我还应该补充一点,在尝试相同的事情时,我也遇到了 PiCam 模块的问题,尽管问题不同。
对我来说更神秘的是,相机似乎进入了捕捉状态。在“简单”脚本中捕获视频时,LED 开始闪烁,就像它本来的样子。 这是我遇到问题的文件的来源:
studentName
这是运行没有问题的简单文件:
from flask import Flask,render_template,Response
import cv2
from flirpy.camera.lepton import Lepton
fcamera = Lepton()
app = Flask(__name__)
camera = cv2.VideoCapture(1) # use 0 for web camera
# for cctv camera use rtsp://username:password@ip_address:554/user=username_password='password'_channel=channel_number_stream=0.sdp' instead of camera
# for local webcam use cv2.VideoCapture(0)
def gen_frames(): # generate frame by frame from camera
while True:
# Capture frame-by-frame
success,frame = camera.read() # read the camera frame
if not success:
print("could not read")
break
else:
ret,buffer = cv2.imencode('.jpg',frame)
frame = buffer.tobytes()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n') # concat frame one by one and show result
@app.route('/video_feed')
def video_feed():
#Video streaming route. Put this in the src attribute of an img tag
return Response(gen_frames(),mimetype='multipart/x-mixed-replace; boundary=frame')
@app.route('/')
def index():
"""Video streaming home page."""
return render_template('index.html')
if __name__ == '__main__':
app.run(debug=True)
我应该提一下,我没有尝试同时使用这些脚本中的任何一个。 VLC 也没有运行。
感谢您的帮助!
javamaster10000
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)