From 65b50be0c564e2875e249d1890801e4398ff685d Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Tue, 15 Jan 2019 17:07:43 +0000 Subject: [PATCH] Added API route to draw overlay text --- .../api/v1/blueprints/camera/__init__.py | 7 +++- .../api/v1/blueprints/camera/overlay.py | 39 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 openflexure_microscope/api/v1/blueprints/camera/overlay.py diff --git a/openflexure_microscope/api/v1/blueprints/camera/__init__.py b/openflexure_microscope/api/v1/blueprints/camera/__init__.py index 933efa7e..55fea5c1 100644 --- a/openflexure_microscope/api/v1/blueprints/camera/__init__.py +++ b/openflexure_microscope/api/v1/blueprints/camera/__init__.py @@ -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): @@ -31,4 +31,9 @@ def construct_blueprint(microscope_obj): '/preview/', 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 diff --git a/openflexure_microscope/api/v1/blueprints/camera/overlay.py b/openflexure_microscope/api/v1/blueprints/camera/overlay.py new file mode 100644 index 00000000..c5c541d6 --- /dev/null +++ b/openflexure_microscope/api/v1/blueprints/camera/overlay.py @@ -0,0 +1,39 @@ +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 + + :