stytra.hardware.video package

Submodules

stytra.hardware.video.ring_buffer module

class stytra.hardware.video.ring_buffer.RingBuffer(length)[source]

Bases: object

put(item)[source]
get()[source]
get_most_recent()[source]

stytra.hardware.video.write module

class stytra.hardware.video.write.VideoWriter(input_queue, finished_signal, saving_evt, log_format='hdf5')[source]

Bases: stytra.utilities.FrameProcess

Writes behavior movies into video files using PyAV

Parameters
  • folder – output folder

  • input_queue – queue of incoming frames

  • finished_signal – signal to finish recording

  • kbit_rate – ouput movie bitrate

run()[source]

Method to be run in sub-process; can be overridden in sub-class

configure(size)[source]
ingest_frame(frame)[source]
complete()[source]
reset()[source]
class stytra.hardware.video.write.H5VideoWriter(*args, **kwargs)[source]

Bases: stytra.hardware.video.write.VideoWriter

reset()[source]
ingest_frame(frame)[source]
complete()[source]
class stytra.hardware.video.write.StreamingVideoWriter(*args, extension='mp4', output_framerate=24, format='mpeg4', kbit_rate=1000, **kwargs)[source]

Bases: stytra.hardware.video.write.VideoWriter

configure(shape)[source]
ingest_frame(frame)[source]
reset()[source]
complete()[source]

Module contents

Module to interact with video surces as cameras or video files. It also implement video saving

class stytra.hardware.video.VideoSource(rotation=False, max_mbytes_queue=200, n_consumers=1)[source]

Bases: stytra.utilities.FrameProcess

Abstract class for a process that generates frames, being it a camera or a file source. A maximum size of the memory used by the process can be set.

Input Queues:

self.control_queue :

queue with control parameters for the source, e.g. from a CameraControlParameters object.

Output Queues

self.frame_queue :

TimestampedArrayQueue from the arrayqueues module where the frames read from the camera are sent.

Events

self.kill_signal :

When set kill the process.

Parameters
  • rotation (int) – n of times image should be rotated of 90 degrees

  • max_mbytes_queue (int) – maximum size of camera queue (Mbytes)

put_frame(frame, messages)[source]
class stytra.hardware.video.CameraSource(camera_type, *args, downsampling=1, roi=(-1, -1, -1, -1), max_buffer_length=1000, camera_params={}, **kwargs)[source]

Bases: stytra.hardware.video.VideoSource

Process for controlling a camera.

Cameras currently implemented:

Ximea

Add some info

Avt

Add some info

Parameters
  • camera_type (str) – specifies type of the camera (currently supported: ‘ximea’, ‘avt’)

  • downsampling (int) – specifies downsampling factor for the camera.

retrieve_params(messages)[source]
run()[source]

After initializing the camera, the process constantly does the following:

  • read control parameters from the control_queue and set them;

  • read frames from the camera and put them in the frame_queue.

class stytra.hardware.video.VideoFileSource(source_file=None, loop=True, **kwargs)[source]

Bases: stytra.hardware.video.VideoSource

A class to stream videos from a file to test parts of stytra without a camera available, or do offline analysis

Parameters
  • source_file – path of the video file

  • loop (bool) – continue video from the beginning if the end is reached

inner_loop()[source]
update_params()[source]
run()[source]

Method to be run in sub-process; can be overridden in sub-class

class stytra.hardware.video.VideoControlParameters(**kwargs)[source]

Bases: lightparam.param_qt.ParametrizedQt

class stytra.hardware.video.CameraControlParameters(**kwargs)[source]

Bases: lightparam.param_qt.ParametrizedQt

HasPyQtGraphParams class for controlling the camera params. Ideally, methods to automatically set dynamic boundaries on frame rate and exposure time can be implemented. Currently not implemented.