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:
commit
fe5db1a0f5
1 changed files with 6 additions and 1 deletions
|
|
@ -15,6 +15,7 @@ from threading import Event
|
||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
import piexif
|
import piexif
|
||||||
|
import re
|
||||||
|
|
||||||
from labthings_fastapi.thing import Thing
|
from labthings_fastapi.thing import Thing
|
||||||
from labthings_fastapi.dependencies.metadata import GetThingStates
|
from labthings_fastapi.dependencies.metadata import GetThingStates
|
||||||
|
|
@ -41,6 +42,8 @@ BackgroundDep = direct_thing_client_dependency(
|
||||||
BackgroundDetectThing, "/background_detect/"
|
BackgroundDetectThing, "/background_detect/"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IMAGE_REGEX = re.compile(r"-?[0-9]+_-?[0-9]+\.jpeg$")
|
||||||
|
|
||||||
|
|
||||||
def unpack_autofocus(scan_data):
|
def unpack_autofocus(scan_data):
|
||||||
"""Extract z, sharpness data from a move_and_measure call
|
"""Extract z, sharpness data from a move_and_measure call
|
||||||
|
|
@ -884,7 +887,9 @@ class SmartScanThing(Thing):
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
images_folder = os.path.join(path, IMG_DIR_NAME)
|
images_folder = os.path.join(path, IMG_DIR_NAME)
|
||||||
if os.path.isdir(images_folder):
|
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:
|
else:
|
||||||
number_of_images = 0
|
number_of_images = 0
|
||||||
modified = max(os.stat(root).st_mtime for root, _, _ in os.walk(path))
|
modified = max(os.stat(root).st_mtime for root, _, _ in os.walk(path))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue