Remove separate camera stream thread
This commit is contained in:
parent
94bc49cd5c
commit
021745da26
5 changed files with 137 additions and 232 deletions
|
|
@ -7,8 +7,10 @@ import time
|
|||
|
||||
# Look for debug flag
|
||||
if "-d" in sys.argv or "--debug" in sys.argv:
|
||||
debug_app = True
|
||||
log_level = logging.DEBUG
|
||||
else:
|
||||
debug_app = False
|
||||
log_level = logging.INFO
|
||||
|
||||
|
||||
|
|
@ -208,4 +210,4 @@ if __name__ == "__main__":
|
|||
|
||||
logging.info("Starting OpenFlexure Microscope Server...")
|
||||
server = Server(app)
|
||||
server.run(host="0.0.0.0", port=5000, debug=False, zeroconf=True)
|
||||
server.run(host="0.0.0.0", port=5000, debug=debug_app, zeroconf=True)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ def gen(camera):
|
|||
"""Video streaming generator function."""
|
||||
while True:
|
||||
# the obtained frame is a jpeg
|
||||
frame = camera.get_frame()
|
||||
frame = camera.stream.getframe()
|
||||
|
||||
yield (b"--frame\r\n" b"Content-Type: image/jpeg\r\n\r\n" + frame + b"\r\n")
|
||||
|
||||
|
|
@ -33,8 +33,6 @@ class MjpegStream(PropertyView):
|
|||
will block all proceeding requests.
|
||||
"""
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
# Restart stream worker thread
|
||||
microscope.camera.start_worker()
|
||||
|
||||
return Response(
|
||||
gen(microscope.camera), mimetype="multipart/x-mixed-replace; boundary=frame"
|
||||
|
|
@ -53,7 +51,5 @@ class SnapshotStream(PropertyView):
|
|||
Single snapshot from the camera stream
|
||||
"""
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
# Restart stream worker thread
|
||||
microscope.camera.start_worker()
|
||||
|
||||
return Response(microscope.camera.get_frame(), mimetype="image/jpeg")
|
||||
return Response(microscope.camera.stream.getframe(), mimetype="image/jpeg")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue