I'm so confused now - do y'all really run into people trying to use the optical sensors (spectrometers) to match stains?
That doesn't even make any sense to try directly.
They are meant for, and great at, matching solid colors. A properly calibrated sensor should be able to be used to make custom *pigmented* color matches that are indistinguishable from the original.
Stains are another matter, because
A. they are transparent
B. the thing they are sitting on top of (wood) is not a single color
C. Different wood reacts differently to stain.
For starters, the spectrometer can only tell you what color something is now.
If it was a solid pigmented color, that's all you need, because you are covering it all.
For transparent colors, you need to know what color you *added* to the original to get it to where it is, and reading just a stained piece of wood will *never* give you that.
It literally can't.
You'd really need two accurate samples of the same wood, one stained, one not.
You can then subtract the colors from each other and tell what color the actual stain was imparting, and that should be something that can probably be automatically constructed to work on that wood.
You could also use the piece of wood you *want* to stain as the point of comparison, and that would be able to tell what color needs to be added to it to make it into the stained piece.
(But this is much harder to construct automatically. At least you'd know what color to aim for!)