Merge branch 'master' of https://gitlab.com/openflexure/openflexure-microscope-server into master
This commit is contained in:
commit
9dd8004984
5 changed files with 16 additions and 8 deletions
|
|
@ -325,7 +325,7 @@ class MoveAndMeasureAPI(ActionView):
|
||||||
|
|
||||||
if microscope.has_real_stage():
|
if microscope.has_real_stage():
|
||||||
# Acquire microscope lock with 1s timeout
|
# Acquire microscope lock with 1s timeout
|
||||||
with microscope.lock(timeout=1):
|
with microscope.camera.lock, microscope.stage.lock:
|
||||||
return move_and_measure(microscope, dz=args.get("dz"))
|
return move_and_measure(microscope, dz=args.get("dz"))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -315,8 +315,6 @@ class PiCameraStreamer(BaseCamera):
|
||||||
|
|
||||||
def start_preview(self, fullscreen=True, window=None):
|
def start_preview(self, fullscreen=True, window=None):
|
||||||
"""Start the on board GPU camera preview."""
|
"""Start the on board GPU camera preview."""
|
||||||
logging.info("Starting the GPU preview")
|
|
||||||
|
|
||||||
with self.lock():
|
with self.lock():
|
||||||
try:
|
try:
|
||||||
if not self.camera.preview:
|
if not self.camera.preview:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
from . import capture, capture_manager
|
from . import capture, capture_manager
|
||||||
from .capture import CaptureObject
|
from .capture import CaptureObject, THUMBNAIL_SIZE
|
||||||
from .capture_manager import CaptureManager
|
from .capture_manager import CaptureManager
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
|
|
||||||
|
|
@ -14,6 +15,7 @@ from openflexure_microscope.camera.piexif._exceptions import InvalidImageDataErr
|
||||||
from openflexure_microscope.config import JSONEncoder
|
from openflexure_microscope.config import JSONEncoder
|
||||||
|
|
||||||
EXIF_FORMATS = ["JPG", "JPEG", "TIF", "TIFF"]
|
EXIF_FORMATS = ["JPG", "JPEG", "TIF", "TIFF"]
|
||||||
|
THUMBNAIL_SIZE = (200, 150)
|
||||||
|
|
||||||
|
|
||||||
def pull_usercomment_dict(filepath):
|
def pull_usercomment_dict(filepath):
|
||||||
|
|
@ -347,8 +349,16 @@ class CaptureObject(object):
|
||||||
thumbnail = exif_dict.pop("thumbnail")
|
thumbnail = exif_dict.pop("thumbnail")
|
||||||
if thumbnail:
|
if thumbnail:
|
||||||
return io.BytesIO(thumbnail)
|
return io.BytesIO(thumbnail)
|
||||||
# If no thumbnail exists, serve the full image
|
# If no thumbnail exists, make and save one
|
||||||
return self.data.getvalue()
|
thumb_bytes = io.BytesIO()
|
||||||
|
thumb_im = Image.open(self.data)
|
||||||
|
thumb_im.thumbnail(THUMBNAIL_SIZE)
|
||||||
|
thumb_im.save(thumb_bytes, "jpeg")
|
||||||
|
thumbnail = thumb_bytes.getvalue()
|
||||||
|
exif_dict["thumbnail"] = thumbnail
|
||||||
|
exif_bytes = piexif.dump(exif_dict)
|
||||||
|
piexif.insert(exif_bytes, self.file)
|
||||||
|
return io.BytesIO(thumbnail)
|
||||||
|
|
||||||
def save(self) -> None:
|
def save(self) -> None:
|
||||||
"""Write stream to file, and save/update metadata file"""
|
"""Write stream to file, and save/update metadata file"""
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import pkg_resources
|
||||||
from expiringdict import ExpiringDict
|
from expiringdict import ExpiringDict
|
||||||
|
|
||||||
from openflexure_microscope.camera.mock import MissingCamera
|
from openflexure_microscope.camera.mock import MissingCamera
|
||||||
from openflexure_microscope.captures import CaptureManager
|
from openflexure_microscope.captures import CaptureManager, THUMBNAIL_SIZE
|
||||||
from openflexure_microscope.stage.mock import MissingStage
|
from openflexure_microscope.stage.mock import MissingStage
|
||||||
from openflexure_microscope.stage.sanga import SangaDeltaStage, SangaStage
|
from openflexure_microscope.stage.sanga import SangaDeltaStage, SangaStage
|
||||||
|
|
||||||
|
|
@ -387,7 +387,7 @@ class Microscope:
|
||||||
# Capture to output object
|
# Capture to output object
|
||||||
extras = {}
|
extras = {}
|
||||||
if fmt == "jpeg":
|
if fmt == "jpeg":
|
||||||
extras["thumbnail"] = (200, 150, 85)
|
extras["thumbnail"] = (*THUMBNAIL_SIZE, 85)
|
||||||
logging.info("Starting microscope capture %s", output.file)
|
logging.info("Starting microscope capture %s", output.file)
|
||||||
self.camera.capture(
|
self.camera.capture(
|
||||||
output,
|
output,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue