错误:[Errno 10054]远程主机Python强行关闭现有连接

时间:2018-01-03 03:03:02

标签: python opencv flask

我正在使用flask来运行一个简单的Web服务器来显示我从网络摄像头输出的视频作为mjpeg,我需要使用链接在Mission planner上传输它,我的代码是:

// changed the method to accept an Article object instead of a string.

deleteArticle(article:Article): Observable<any> {
  return this.http.post('http://localhost:3000/api/deletePost', JSON.stringify(article), {
    headers: new HttpHeaders().set('Content-Type', 'application/json'),
  }).map(data => {
    if (data["status"] == 200) {
      this.router.navigate(['posts']);
    } else if (data["status"] == 500) {
      // TODO: error message and handling here
      console.log(data);
    }
    return data["status"];
  });
}

当我通过chrome访问链接时它运行正常但是当我在任务规划器上使用相同的链接作为mjpeg源时,我从shell获得此响应:

from flask import Flask, render_template, Response
from camera import VideoCamera
import time

app = Flask(__name__)

@app.route('/video_feed')
def index():
return render_template('index.html')

def gen(camera):
    while True:
        frame = camera.get_frame()
        yield (b'--frame\r\n'
               b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
        #time.sleep(1)

@app.route('/vid.jpg')
def video_feed():
    time.sleep(1)
    return Response(gen(VideoCamera()),
                    mimetype='multipart/x-mixed-replace; boundary=frame')
#multipart/x-mixed-replace

if __name__ == '__main__':
    app.run(host='127.0.0.1', port=54223)

我做错了吗?我正在使用Windows 10。

0 个答案:

没有答案