Merge branch 'image_count' into 'v3'

Regex to count captured images

Closes #306

See merge request openflexure/openflexure-microscope-server!253
This commit is contained in:
Joe Knapper 2025-05-07 13:53:37 +00:00
commit fe5db1a0f5

View file

@ -15,6 +15,7 @@ from threading import Event
import glob
import json
import piexif
import re
from labthings_fastapi.thing import Thing
from labthings_fastapi.dependencies.metadata import GetThingStates
@ -41,6 +42,8 @@ BackgroundDep = direct_thing_client_dependency(
BackgroundDetectThing, "/background_detect/"
)
IMAGE_REGEX = re.compile(r"-?[0-9]+_-?[0-9]+\.jpeg$")
def unpack_autofocus(scan_data):
"""Extract z, sharpness data from a move_and_measure call
@ -884,7 +887,9 @@ class SmartScanThing(Thing):
if os.path.isdir(path):
images_folder = os.path.join(path, IMG_DIR_NAME)
if os.path.isdir(images_folder):
number_of_images = len(os.listdir(images_folder))
folder_contents = os.listdir(images_folder)
scan_images = [x for x in folder_contents if IMAGE_REGEX.search(x)]
number_of_images = len(scan_images)
else:
number_of_images = 0
modified = max(os.stat(root).st_mtime for root, _, _ in os.walk(path))