Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken behaviour of UC480 Thorlabs camera driver #150

Closed
LMSC-NTappy opened this issue Jan 29, 2022 · 3 comments
Closed

Broken behaviour of UC480 Thorlabs camera driver #150

LMSC-NTappy opened this issue Jan 29, 2022 · 3 comments

Comments

@LMSC-NTappy
Copy link

LMSC-NTappy commented Jan 29, 2022

Hello,

I have some troubles with the current behaviour of the thorlabs UC480 camera driver.

from instrumental import list_instruments,Q_
instruments = list_instruments()
instruments
# [<ParamSet[UC480_Camera] serial=b'4102795822' model=b'C1285R12M' id=1>]
i = instruments[0]
cam = i.create()
cam._get_exposure()
# 10.012500000000001 millisecond
cam._set_exposure(Q_(0.1,'ms'))
cam._get_exposure()
# 0.1335 millisecond
cam.grab_image()
# array([[255, 255, 255, ..., 255, 255, 255],
#        [255, 255, 255, ..., 255, 255, 255],
#        [255, 255, 255, ..., 255, 255, 255],
#        ...,
#        [255, 255, 255, ..., 255, 255, 255],
#        [255, 255, 255, ..., 255, 255, 255],
#        [255, 255, 255, ..., 255, 255, 255]], dtype=uint8)
cam._get_exposure()
# 10.012500000000001 millisecond

Obviously, if one applies a new exposure time to the camera and asks to grab a frame, she expects the exposure time to be applied in the acquisition and not re-set to default. This makes the _set_exposure as well as some facet parameters useless.

This is due to a faulty behaviour of the _handle_keywords function.

def _handle_kwds(self, kwds, fill_coords=True):

If no args are passed, the parameters are re-set to the default values. Since I saw that you are currently changing this in #140 & #144 I thought I would share.

@seb5g
Copy link
Contributor

seb5g commented Jan 31, 2022

In fact grab_image is requesting parameters as argument for them to be applied. This is kind of awkward. In my PR #144 I added functionalities for that reason.

@natezb
Copy link
Contributor

natezb commented Feb 2, 2022

This behavior is not "broken", it is as originally designed. Note that in your example code you're using private functions not intended for external use. There is currently no public interface for setting things like exposure in a persistent way.

We can consider adding persistent setting of values like this, but we'll have to be careful in thinking how this interacts with the existing behavior. For example, if we pass an exposure to grab_image(), does that persistently set the exposure, or only set it for that image? I'm thinking probably the latter.

cam.grab_image()  # Uses default value

cam.exposure = '100 ms'
cam.grab_image()  # 100 ms

cam.grab_image(exposure='20 ms')  # 20 ms

cam.grab_image()  # 100 ms

@LMSC-NTappy
Copy link
Author

Ok, I get it now. I didn't think of it that way, sorry.

In any case I agree with your suggestion and example.

Many thanks for adressing this. I'll close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants