portugueslab / stytra

A modular package to control stimulation and track behaviour
http://www.portugueslab.com/stytra/
GNU General Public License v3.0
41 stars 26 forks source link

Running on cameras with low fps #8

Closed EricThomson closed 5 years ago

EricThomson commented 5 years ago

I have a point grey camera with max 30fps sampling, and find it useful to test things at home with it. I've been trying to run a simple script to just display the camera output using Stytra, adapted from display_opencv_cam, called display_spinnaker_cam:

from stytra import Stytra
from stytra.stimulation.stimuli import Pause
from stytra.stimulation import Protocol

class Nostim(Protocol):
    name = "empty_protocol"
    stytra_config = dict(camera=dict(type="spinnaker"))
    def get_stim_sequence(self):
        return [Pause(duration=10)]  # protocol does not do anything

if __name__ == "__main__":
    s = Stytra(protocol=Nostim())

It says in the Stytra gui that the Spinnaker API camera was successfully opened, but that the FPS is too large:

Error: Spinnaker: GenICam::OutOfRangeException= Value 150.000000 must be smaller than or equal 30.003332. : OutOfRangeException thrown in node 'AcquisitionFrameRate' while calling 'AcquisitionFrameRate.SetValue()' (file 'FloatT.h', line 85) [-2002] File "C:\Users\Eric\Dropbox\Programming\stytra_dev\stytra\stytra\collectors\accumulators.py", line 316, in update_list t, fps = self.queue.get(timeout=0.001)

I went into hardware/video/__init__.py and modified the CameraControlParameters() but still got the same error, though in a different locus in the flow:

SpinnakerCamera.set() error: Spinnaker: GenICam::OutOfRangeException= Value 150.000000 must be smaller than or equal 30.003332. : OutOfRangeException thrown in node 'AcquisitionFrameRate' while calling 'AcquisitionFrameRate.SetValue()' (file 'FloatT.h', line 85) [-2002] File "C:\Users\Eric\Dropbox\Programming\stytra_dev\stytra\stytra\gui\status_display.py", line 88, in refresh self.addMessage(msg)

It seems there are a few places where it is trying to enforce a frame rate lower limit. I wonder if there is a simple workaround for testing with lower frame rates?

vigji commented 5 years ago

This should be solved with your new spinnaker API version!