Added API route to draw overlay text
This commit is contained in:
parent
9c488279d2
commit
65b50be0c5
2 changed files with 45 additions and 1 deletions
|
|
@ -2,7 +2,7 @@ from openflexure_microscope.api.v1.views import MicroscopeView
|
||||||
|
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
|
|
||||||
from . import capture, record, preview, config
|
from . import capture, record, preview, config, overlay
|
||||||
|
|
||||||
|
|
||||||
def construct_blueprint(microscope_obj):
|
def construct_blueprint(microscope_obj):
|
||||||
|
|
@ -31,4 +31,9 @@ def construct_blueprint(microscope_obj):
|
||||||
'/preview/<string:operation>',
|
'/preview/<string:operation>',
|
||||||
view_func=preview.GPUPreviewAPI.as_view('gpu_preview', microscope=microscope_obj))
|
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)
|
return(blueprint)
|
||||||
39
openflexure_microscope/api/v1/blueprints/camera/overlay.py
Normal file
39
openflexure_microscope/api/v1/blueprints/camera/overlay.py
Normal file
|
|
@ -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
|
||||||
|
|
||||||
|
:<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})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue