Commit graph

46 commits

Author SHA1 Message Date
Joe Knapper
f2d85cb891 sleep before capturing 2024-02-09 19:06:58 +00:00
Joe Knapper
61d7712c27 tiff as an option 2024-02-09 19:05:20 +00:00
Richard Bowman
a61ffbf75a WIP: use code from labthings-picamera2 for EXIF writing
I've now switched to using piexif to write the EXIF tag, which
is slower - but still does not seem to work in openflexure-
stitching.
2024-02-05 17:14:56 +00:00
Richard Bowman
bc8db396bf Acquire raw images rather than processed ones
I've swapped `capture_jpeg` for `capture_array`. This will acquire a raw image and process it manually. Currently I've included LST correction, colour balance, but **not** the colour unmixing matrix. In the future we could add this to implement proper correction for saturation.

Currently EXIF data does not seem to be working properly.
2024-02-01 21:55:15 +00:00
Richard Bowman
24a1d9d020 WIP: try just waiting 0.5s rather than using an Event 2024-02-01 17:37:44 +00:00
Richard Bowman
4a18ef729a Parallelise capture of images and the next move 2024-02-01 17:36:05 +00:00
Richard Bowman
6e4e79f2d2 Factor out moving to the next scan point into a method 2024-02-01 16:49:18 +00:00
jaknapper
db51cd8067 Make overlap value consistent 2024-02-01 15:31:14 +00:00
jaknapper
e6e809cea4 Zip files as we scan, saving the regenerated ones to the end
Removed maximum scan size of 750 images

Save json of scan inputs and use it for future stitching (ensures consistent parameters)

Moved looping autofocus to autofocus thing from recentering thing

Rewrote looping autofocus to skip unneeded moves, as if peak is out of range, no need to nicely focus
2024-01-30 18:46:34 +00:00
jaknapper
a0b98a1adc Fixed autofocus to not combine logs 2024-01-29 19:56:24 +00:00
Joe Knapper
528406137f Start autofocus from base of range for speed 2024-01-29 18:10:11 +00:00
Joe Knapper
53eb51e964 Improved default scan values 2024-01-23 15:22:30 +00:00
Richard Bowman
b35db02f34 Improved error handling and zip download
I've swapped out various `logging.exception` calls for
`logging.error` with `exc_info` set to the exception.
My reading of the docs is that the two shoulld be equivalent,
but the former fails with an error related to
message formatting, as if there was an extra (or missing) '%'.

I've changed the format of the downloaded zip file, so that it
now puts the stitched images at the top level (if they exist).

I've also modified the time of the last stitched image so it
returns None if it doesn't exist - this avoids HTTP errors in
the client.
2024-01-17 13:14:43 +00:00
Richard Bowman
f627d6e2f2 Always generate the preview stitch
The preview stitch is useful even if stitch-as-you-go is not
desired. I've enabled it all the time, not just when the box
is ticked.
2024-01-17 11:59:30 +00:00
Richard Bowman
9ac0a11ce1 Add a property to enable/disable auto-stitching 2024-01-15 21:35:27 +00:00
Richard Bowman
e7a3003c47 Add a closing ` to the logging statement
This was mistakenly not added to the previous commit.
2024-01-15 20:42:54 +00:00
Richard Bowman
dca2d1fabb Improve scan naming logic and type hints
Removed an unnecessary `Optional` and removed the `scan_` prefix from scans that have a non-empty name.

I also added a closing ` to a logging statement.
2024-01-15 20:27:35 +00:00
Joe Knapper
e483c3ddfb custom scan name from gui 2024-01-15 17:40:17 +00:00
Joe Knapper
c2f1b591b1 Fix to CSM scaling for Fiji config as images are now captured at double width 2024-01-13 14:29:34 +00:00
Joe Knapper
d1908eb29a Run stitching thing with appropriate overlap setting 2024-01-13 13:38:39 +00:00
jaknapper
c4e02d9087 Maximum lateral range and minimum autofocus range 2024-01-11 20:38:47 +00:00
Richard Bowman
a279831c41 Reordered cleanup operations for robustness
I now define the variables needed in the finally: block at
the very start, so I can test if they are None.

I've reordered the final move so it can happen as we are awaiting the background processes. I've added exception handling so this won't cause problems with the lock.
2024-01-11 16:39:06 +00:00
Richard Bowman
924cce649a Autofocus tweaks for smart scan
We've removed the initial double-autofocus (we just do a
single looping autofocus at the start), and now only do 3 retries rather than 5 if the focus is rejected.
2024-01-11 14:15:54 +00:00
Richard Bowman
a965d04047 Move raw images folder inside images folder
This ensures images.zip contains everything - a neater solution
for this is TBD.
2024-01-11 13:56:24 +00:00
Richard Bowman
f4c4206a53 Return an empty scans list if the folder is missing 2024-01-11 13:40:47 +00:00
Richard Bowman
ba86c37292 Swap background detection from argument to property
For consistency, I've made background detection a property.
2024-01-11 03:21:50 +00:00
Richard Bowman
717cf7657c Combine stitcher and smart scan Things
I'm now running stitching in subprocesses during the scan.
This seems to be working well - I'm using multiple CPU
cores and getting images out. However, the only way to
avoid circular dependencies was to combine the Things.

I'm still getting not-infrequent memory allocation errors from the camera, which may or may not be related.
2024-01-11 01:49:24 +00:00
Richard Bowman
00a4b38a83 Prevent scans from filling the SD card 2024-01-10 21:07:25 +00:00
Richard Bowman
8fb70bf43a Make latest_scan_name a property 2024-01-10 20:51:50 +00:00
Richard Bowman
9ce52c2845 Added a Thing to run stitching as Actions 2024-01-10 20:51:49 +00:00
jaknapper
6d622c1bf8 Avoid negative dx/dy and allow for float CSM image resolution 2024-01-10 15:38:34 +00:00
jaknpper
d219e32bc8 Option to run scan without background detect in webapp and Thing 2024-01-09 20:24:51 +00:00
Joe Knapper
090f447d26 Thing properties for autofocus dz, overlap and range limit 2024-01-08 19:33:24 +00:00
Richard Bowman
d615522712 Raw images and better cancellation
Cancelling a smart scan now resets position to the starting point.

a "raw images" folder now includes images without resampling.
2024-01-08 17:25:31 +00:00
Richard Bowman
552fde45ed Improve logging commands
use logging.exception instead of setting exc_info.
2024-01-08 16:43:28 +00:00
jaknapper
4445990966 Check we have a background set before starting scan 2024-01-08 16:21:57 +00:00
jaknapper
ae68a1b319 Pseudo spiral scan path and fixed dx-dy inversion 2024-01-08 16:01:54 +00:00
jaknapper
a53062af83 Background detect fraction as a thing 2024-01-07 15:00:46 +00:00
jaknapper
1ebf00ffb3 Fiji config file and low res capture to avoid exposure time drift 2024-01-05 17:23:44 +00:00
Richard Bowman
90a68ed4f1 Added endpoints to add and delete scans
This makes use of the new @fastapi_endpoint decorator
in labthings.
2024-01-05 00:42:24 +00:00
Richard Bowman
2ce143ff01 WIP: Exception handling and file management
It's now possible to see (via the HTTP API) scans and download
them as zip files. Zip files appear to be malformed at present.
2024-01-04 18:59:51 +00:00
Richard Bowman
9f01a5ab29 WIP: logging and cancellability in smart_scan 2024-01-04 01:32:18 +00:00
Richard Bowman
25552215f9 Refactored background detection into a Thing
The new background detect Thing (currently in smart_scan.py)
manages its own settings and exposes a few more actions.
2024-01-03 16:56:20 +00:00
jaknapper
0e32fd1e1f Added position log 2023-12-29 15:58:51 +00:00
Richard Bowman
1b6e2686be Format and linting of recentre and smart scan 2023-12-14 16:06:05 +00:00
jaknapper
1d50dcb3f8 Scanning and centring things 2023-12-14 15:08:43 +00:00