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

uc480 start_live_video() fails after close() and open() #157

Open
Feargus opened this issue Mar 28, 2023 · 0 comments
Open

uc480 start_live_video() fails after close() and open() #157

Feargus opened this issue Mar 28, 2023 · 0 comments

Comments

@Feargus
Copy link

Feargus commented Mar 28, 2023

from instrumental.drivers.cameras import uc480
instruments = uc480.list_instruments()
#cam = uc480.UC480_Camera(instruments[0],reopen_policy='reuse')
#cam = uc480.UC480_Camera(instruments[0], reopen_policy='new')
cam = uc480.UC480_Camera(instruments[0])
#cam.is_open#True

cam.start_live_video()

cam.stop_live_video()

cam.close()
#cam.is_open#False

cam.open()
#cam.is_open#True

cam.start_live_video()

In the above code, the first cam.start_live_video() works fine, the second one throws an error

UC480Error                                Traceback (most recent call last)
Cell In [1], line 18
     15 cam.open()
     16 cam.is_open
---> 18 cam.start_live_video()

File <decorator-gen-2>:2, in start_live_video(self, framerate, **kwds)

File ~\Anaconda3\envs\COVEQ-v08-TSI\lib\site-packages\instrumental\drivers\util.py:342, in _unit_decorator.<locals>.wrap.<locals>.wrapper(func, *args, **kwargs)
    339     if name not in new_kwargs:
    340         new_kwargs[name] = new_defaults[name]
--> 342 result = func(*new_args, **new_kwargs)
    344 # Allow for unit checking of multiple return values
    345 if isinstance(ret_units, tuple):

File ~\Anaconda3\envs\COVEQ-v08-TSI\lib\site-packages\instrumental\drivers\cameras\uc480.py:881, in UC480_Camera.start_live_video(self, framerate, **kwds)
    878 self._set_exposure(kwds['exposure_time'])
    879 self._set_gain(kwds['gain'])
--> 881 self._free_image_mem_seq()
    882 self._allocate_mem_seq(num_bufs=2)
    883 self._set_queueing(False)

File ~\Anaconda3\envs\COVEQ-v08-TSI\lib\site-packages\instrumental\drivers\cameras\uc480.py:719, in UC480_Camera._free_image_mem_seq(self)
    717 self._dev.ClearSequence()
    718 for buf in self._buffers:
--> 719     self._dev.FreeImageMem(buf.ptr, buf.id)
    720 self._buffers = []

File ~\Anaconda3\envs\COVEQ-v08-TSI\lib\site-packages\nicelib\nicelib.py:701, in LibMethod.__call__(self, *args, **kwds)
    699 if self._libfunc.sig.flags.get('use_handle', True):
    700     args = self._niceobj._handles + args
--> 701 return self._libfunc._call(args, kwds, niceobj=self._niceobj)

File ~\Anaconda3\envs\COVEQ-v08-TSI\lib\site-packages\nicelib\nicelib.py:1171, in LibFunction._call(self, args, kwds, niceobj)
   1164 retval = self.c_func(*c_args)
   1166 ret_handler_args = {
   1167     'niceobj': niceobj,
   1168     'funcname': self.name,
   1169     'funcargs': c_args,
   1170 }
-> 1171 return self.sig.extract_outputs(c_args, retval, ret_handler_args)

File ~\Anaconda3\envs\COVEQ-v08-TSI\lib\site-packages\nicelib\nicelib.py:219, in Sig.extract_outputs(self, c_args, retval, ret_handler_kwargs)
    214 out_vals = [handler.extract_output(self.ffi, c_arg)
    215             for handler, c_arg in zip(self.handlers, c_args)
    216             if handler.makes_output]
    218 if self.ret_handler:
--> 219     retval = self.ret_handler.handle(retval, ret_handler_kwargs)
    221 if retval is not None:
    222     out_vals.append(retval)

File ~\Anaconda3\envs\COVEQ-v08-TSI\lib\site-packages\nicelib\nicelib.py:543, in RetHandler.handle(self, retval, available_kwargs)
    540 except KeyError as e:
    541     raise KeyError("Unknown arg '{}' in arglist of ret-handling function "
    542                    "'{}'".format(e.args[0], self.__name__))
--> 543 return self.__func__(retval, **kwargs)

File ~\Anaconda3\envs\COVEQ-v08-TSI\lib\site-packages\instrumental\drivers\cameras\uc480.py:110, in ret_cam_errcheck(result, niceobj)
    107 @RetHandler(num_retvals=0)
    108 def ret_cam_errcheck(result, niceobj):
    109     if result != NiceUC480.SUCCESS:
--> 110         raise get_last_error(result, niceobj)

UC480Error: (-1) b'An unspecified error occurred'

Changing the reopen_policy doesn't seem to matter.
Am I doing something wrong here?
I would really like to be able to close(), in order to be able run the normal ThorCam software from time to time.

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

1 participant