Мне нужна помощь с моей программой.Моя цель - потоковая передача с IP-камеры в колбу веб-сервера с начальной загрузкой, я выясняю, как я это делаю, а также я сделал веб-интерфейс как поле ввода и кнопки ... но проблема в том, когда я записал IP-адрес IP-камеры вв поле ввода я получил эту ошибку:
ValueError: Функция просмотра не вернула ответ
Похоже, он не возвращает IP-адрес в качестве ввода из файла HTMLк моей функции в файле Python.
Здесь я хочу попробовать ...
HTML-файл:
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title">Live Streaming</h1>
</div>
<ul class="list-group">
<li class="list-group-item">Stream with IP Camera: <span><a href="#" class="btn btn-sm btn-primary" id="IPcambtn">Start</a></span>
</li>
</ul>
<div id="IPcam" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="IPcamlbl" aria-hidden="true">
<div class="vertical-alignment-helper">
<div class="modal-dialog modal-sm vertical-align-center">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="IPcambl">Enter camera's IP address:</h4>
</div>
<div class="modal-body">
<form action="{{url_for('stream')}}" role="form" id="IPcam" method="post">
<input type="hidden" name="formType" value="IPcam">
<div class="form-group">
<label for="basic-url">IP Address:</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon3">rtsp://</span>
</div>
<input name="IPaddress" type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3" style="width: 275px;>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs- col-xs-offset- text-center">
<!-- Do NOT use name="submit" or id="submit" for the Submit button -->
<button type="submit" class="btn btn-danger" tabindex="3">Confirm</button>
<div class="panel-body">
<img id="pic" src="{{ url_for('IPstream') }}" class="img-responsive img-rounded"></img>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
Файл Python:
class Stream(flask.views.MethodView):
@login_required
def get(self):
return flask.render_template('stream.html')
def post(self):
formType = flask.request.form.get('formType')
IPcamPass = ""
if formType == "IPcam":
required = ['IPaddress']
for r in required:
IPcamPass += flask.request.form.get(r)
print ("Connecting with IP Camera...")
database().writeLogs("IP Camera connection established")
flask.flash("You are now connected with IP Camera")
IPstream()
#Functions for IP Camera streaming.
@app.route('/IPstream')
def IPstream():
return Response(IPcam(),mimetype='multipart/x-mixed-replace; boundary=frame')
return ""
def IPcam():
camera = cv2.VideoCapture(IPaddress)
while True:
success, frame = camera.read() # read the camera frame
if not success:
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
Ошибка:
Traceback (most recent call last)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/middleware/proxy_fix.py", line 228, in __call__
return self.app(environ, start_response)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1615, in full_dispatch_request
return self.finalize_request(rv)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1630, in finalize_request
response = self.make_response(rv)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1725, in make_response
raise ValueError('View function did not return a response')
ValueError: View function did not return a response