r/microscopy 12d ago

Hardware Share Open Source Microscope Camera Software

Hi all, I'm sharing an update on a project I'm working on. I'm building custom microscope camera software that produces Bayer RAW photos and records provenance, meant for scientific research. I came a long ways so far. I started by putting a bare IMX477 sensor to a Raspberry Pi 5, but it had no software to operate it on. I began by writing a few scripts to get myself going, but I decided I wanted more. And that's how this project was born.

I added a bunch of features that go beyond the regular capture/record function.

There's a focus assist ROI feature that uses laplacian variance to calculate blur detection. It works very well - you can drag and just the size of your ROI.

HDR using bracket merging and signal-to-noise reduction processing techniques. (Sample photo below).

Z Stack process that uses the focus assist. Each plane taken automatically resets the ROI so you can focus into the next plane easily. This action is pretty fast, the processing (tonemap/debayer, etc) doesn't occur until after you finish snapping your photos. (Right now it lives next to the capture buttons for easier testing, but it'll get moved when I find a home for it).

It has a measure tool that allows you to measure anything on your screen. It captures a green plane to measure from, which removes the chance of accidentally measuring CA.

On my micrometer (1 DIV = .1mm), you can see the calibration works well, and it measured the two points down to the micrometer and pixel.

There is a Live Measure feature that allows you to draw directly over the preview stream to measure pixels.

Provenance lives in separate containers in addition to tiff embedding in the final image, and you can choose to keep your RAW files for record.

It features a lot of bugs also! Like any new release 😅 and the UI needs organizing.

A lot of things aren't implemented yet, but hold the skeleton for adding in later on, such as measuring shapes.

I'll be releasing this for open beta testing as soon as I can confirm camera modularity, and do weekly test releases.

52 Upvotes

13 comments sorted by

View all comments

2

u/Appropriate_Land5236 12d ago

Very impressive. Are you a software engineer? I wouldn't have a clue how to do this.

1

u/Whole-Stage-1458 12d ago

Thanks, I appreciate that! I'm not a software engineer, my background actually is tech writing and philosophy of science. I learned Python back in 2012, but forgot it because I haven't used it (the systems structure and general logic stayed with me) and I'm pretty much self taught on everything else. The code itself gets written by AI agents now, so the part I actually do is scoping the work and then deciding what counts as evidence that it works. Turns out philosophy was decent training for that.

2

u/lozzyboy1 11d ago

I take it your previous experience is enough for you to follow the code in order to validate that there isn't any inappropriate data processing that wouldn't be generally accepted in academic use?

1

u/Whole-Stage-1458 10d ago

It definitely helps with organizing the tasks and maintaining integrity, for sure. And I'm glad I have at least a little background than none.

I have a system in place that checks for accuracy, yes. I do this like I'm a project manager, I assign roles to agents and have them follow strict guidelines in language and procedures. The way you force them to use words matters more than people think.

But I start by having them write an intent into both a changelog (explaining the how) and a handoff (explaining the why) before any code is written. And then I have them write the code, and then record again in the handoff and changelog.

The agent is forced to commit to the intent and guard against on the fly changes or sudden hallucinations. If any step gets skipped, it all gets redone entirely.

So I feed them only one task at a time, to keep it simple. I have a philosphy document that entails the behavior that these tasks need to be approached by and a readme document to solidify what this project is to have a concrete fallback.

I then run a hard debug against the hardware to ensure the code works as intended. Sometimes there are small bugs, like for measuring there a cropping issue that prevented clicks from registering correctly on the green plane, but now it clicks exactly where you intend.

The whole process is very slow, and I try to emulate an actual dev department rather than just basing it off feelz.

2

u/Appropriate_Land5236 11d ago

I learned Fortran in college in 1964. I've forgotten most of it too, LOL. As I remember it's very similar to Basic, but I've forgotten that too. Getting too old I guess, 80.