Skip to content

Commit

Permalink
Add JPEG handler (used by webcams at NSLS-II BMM and elsewhere)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrakitin committed May 29, 2024
1 parent f58ca85 commit 3787364
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions area_detector_handlers/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
import pandas as pd
import tifffile
from PIL import Image

from . import HandlerBase
from .spe_reader import PrincetonSPEFile
Expand Down Expand Up @@ -654,3 +655,14 @@ def __init__(self, filename, frame_per_point=1):
super(TimepixHDF5Handler, self).__init__(
filename=filename, key=self.hardcoded_key,
frame_per_point=frame_per_point)


class JPEGHandler:
specs = {"JPEG"}

def __init__(self, resource_path):
self._resource_path = resource_path

def __call__(self):
filepath = self._resource_path
return np.asarray(Image.open(filepath))
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"MERLIN_FLY_STREAM_V1 = area_detector_handlers.handlers:BulkXSPRESS",
"MERLIN_FLY = area_detector_handlers.handlers:BulkXSPRESS",
"IMM = area_detector_handlers.handlers:IMMHandler",
"JPEG = area_detector_handlers.handlers:JPEGHandler",
]
},
include_package_data=True,
Expand Down

0 comments on commit 3787364

Please sign in to comment.