Loading openflexure_microscope/api/v1/blueprints/camera/preview.py +19 −3 Original line number Diff line number Diff line from openflexure_microscope.api.utilities import JsonPayload from openflexure_microscope.api.v1.views import MicroscopeView from flask import jsonify from flask import jsonify, request class GPUPreviewAPI(MicroscopeView): def post(self, operation): """ Create a new image capture. Start or stop the onboard GPU preview. Optional "window" parameter can be passed to control the position and size of the preview window, in the format ``[x, y, width, height]``. .. :quickref: GPU Preview; Start/stop preview Loading @@ -18,6 +21,10 @@ class GPUPreviewAPI(MicroscopeView): POST /camera/preview/start HTTP/1.1 Accept: application/json { "window": [0, 0, 480, 320], } .. sourcecode:: http POST /camera/preview/stop HTTP/1.1 Loading @@ -29,7 +36,16 @@ class GPUPreviewAPI(MicroscopeView): :status 200: preview started/stopped """ if operation == "start": self.microscope.camera.start_preview() payload = JsonPayload(request) window = payload.param('window', default=[]) fullscreen = False if len(window) != 4 or not all(isinstance(n, int) for n in window): fullscreen = True window = None self.microscope.camera.start_preview(fullscreen=fullscreen, window=window) elif operation == "stop": self.microscope.camera.stop_preview() return jsonify(self.microscope.state) openflexure_microscope/camera/pi.py +2 −2 Original line number Diff line number Diff line Loading @@ -225,9 +225,9 @@ class StreamingCamera(BaseCamera): # LAUNCH ACTIONS def start_preview(self) -> bool: def start_preview(self, fullscreen=True, window=None) -> bool: """Start the on board GPU camera preview.""" self.camera.start_preview() self.camera.start_preview(fullscreen=fullscreen, window=window) self.state['preview_active'] = True return True Loading Loading
openflexure_microscope/api/v1/blueprints/camera/preview.py +19 −3 Original line number Diff line number Diff line from openflexure_microscope.api.utilities import JsonPayload from openflexure_microscope.api.v1.views import MicroscopeView from flask import jsonify from flask import jsonify, request class GPUPreviewAPI(MicroscopeView): def post(self, operation): """ Create a new image capture. Start or stop the onboard GPU preview. Optional "window" parameter can be passed to control the position and size of the preview window, in the format ``[x, y, width, height]``. .. :quickref: GPU Preview; Start/stop preview Loading @@ -18,6 +21,10 @@ class GPUPreviewAPI(MicroscopeView): POST /camera/preview/start HTTP/1.1 Accept: application/json { "window": [0, 0, 480, 320], } .. sourcecode:: http POST /camera/preview/stop HTTP/1.1 Loading @@ -29,7 +36,16 @@ class GPUPreviewAPI(MicroscopeView): :status 200: preview started/stopped """ if operation == "start": self.microscope.camera.start_preview() payload = JsonPayload(request) window = payload.param('window', default=[]) fullscreen = False if len(window) != 4 or not all(isinstance(n, int) for n in window): fullscreen = True window = None self.microscope.camera.start_preview(fullscreen=fullscreen, window=window) elif operation == "stop": self.microscope.camera.stop_preview() return jsonify(self.microscope.state)
openflexure_microscope/camera/pi.py +2 −2 Original line number Diff line number Diff line Loading @@ -225,9 +225,9 @@ class StreamingCamera(BaseCamera): # LAUNCH ACTIONS def start_preview(self) -> bool: def start_preview(self, fullscreen=True, window=None) -> bool: """Start the on board GPU camera preview.""" self.camera.start_preview() self.camera.start_preview(fullscreen=fullscreen, window=window) self.state['preview_active'] = True return True Loading