Loading openflexure_microscope/api/v1/blueprints/camera/__init__.py +6 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ from openflexure_microscope.api.v1.views import MicroscopeView from flask import Blueprint from . import capture, record, preview, config from . import capture, record, preview, config, overlay def construct_blueprint(microscope_obj): Loading Loading @@ -31,4 +31,9 @@ def construct_blueprint(microscope_obj): '/preview/<string:operation>', view_func=preview.GPUPreviewAPI.as_view('gpu_preview', microscope=microscope_obj)) # Overlay routes blueprint.add_url_rule( '/overlay', view_func=overlay.OverlayAPI.as_view('overlay', microscope=microscope_obj)) return(blueprint) No newline at end of file openflexure_microscope/api/v1/blueprints/camera/overlay.py 0 → 100644 +39 −0 Original line number Diff line number Diff line from openflexure_microscope.api.v1.views import MicroscopeView from openflexure_microscope.api.utilities import JsonPayload from flask import Response, Blueprint, jsonify, request, abort, url_for, redirect, send_file class OverlayAPI(MicroscopeView): def post(self): """ Set overlay text .. :quickref: Overlay; Set camera overlay text **Example requests**: .. sourcecode:: http POST /camera/overlay HTTP/1.1 Accept: application/json { "text": "2019/01/15 14:48", "size": 50 } :>header Accept: application/json :<header Content-Type: application/json :status 200: preview started/stopped """ payload = JsonPayload(request) text = payload.param('text', default="", convert=str) size = payload.param('size', default=50, convert=int) self.microscope.camera.camera.annotate_text = text self.microscope.camera.camera.annotate_text_size = size return jsonify({'text': text, 'size': size}) No newline at end of file Loading
openflexure_microscope/api/v1/blueprints/camera/__init__.py +6 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ from openflexure_microscope.api.v1.views import MicroscopeView from flask import Blueprint from . import capture, record, preview, config from . import capture, record, preview, config, overlay def construct_blueprint(microscope_obj): Loading Loading @@ -31,4 +31,9 @@ def construct_blueprint(microscope_obj): '/preview/<string:operation>', view_func=preview.GPUPreviewAPI.as_view('gpu_preview', microscope=microscope_obj)) # Overlay routes blueprint.add_url_rule( '/overlay', view_func=overlay.OverlayAPI.as_view('overlay', microscope=microscope_obj)) return(blueprint) No newline at end of file
openflexure_microscope/api/v1/blueprints/camera/overlay.py 0 → 100644 +39 −0 Original line number Diff line number Diff line from openflexure_microscope.api.v1.views import MicroscopeView from openflexure_microscope.api.utilities import JsonPayload from flask import Response, Blueprint, jsonify, request, abort, url_for, redirect, send_file class OverlayAPI(MicroscopeView): def post(self): """ Set overlay text .. :quickref: Overlay; Set camera overlay text **Example requests**: .. sourcecode:: http POST /camera/overlay HTTP/1.1 Accept: application/json { "text": "2019/01/15 14:48", "size": 50 } :>header Accept: application/json :<header Content-Type: application/json :status 200: preview started/stopped """ payload = JsonPayload(request) text = payload.param('text', default="", convert=str) size = payload.param('size', default=50, convert=int) self.microscope.camera.camera.annotate_text = text self.microscope.camera.camera.annotate_text_size = size return jsonify({'text': text, 'size': size}) No newline at end of file