ethoscope.hardware.input package

Submodules

ethoscope.hardware.input.cameras module

class ethoscope.hardware.input.cameras.BaseCamera(drop_each=1, max_duration=None, *args, **kwargs)[source]

Bases: object

The template class to generate and use video streams.

Parameters:
  • drop_each – keep only 1/drop_each‘th frame
  • max_duration – stop the video stream if t > max_duration (in seconds).
  • args – additional arguments
  • kwargs – additional keyword arguments
capture = None
height
Returns:the height of the returned frames
Return type:int
is_last_frame()[source]
is_opened()[source]
resolution
Returns:The resolution of the camera W x H.
Return type:(int, int)
restart()[source]

Restarts a camera (also resets time). :return:

width
Returns:the width of the returned frames
Return type:int
class ethoscope.hardware.input.cameras.DummyFrameGrabber(target_fps, target_resolution, queue, stop_queue, path, *args, **kwargs)[source]

Bases: multiprocessing.process.Process

Class to mimic the behaviour of PiFrameGrabber. This is intended for testing purposes. This way, we can emulate the async functionality of the hardware camera by a video file.

Parameters:
  • target_fps (int) – the desired number of frames par second (FPS)
  • target_fps – the desired resolution (W x H)
  • target_resolution – (int,int)
  • args – additional arguments
  • kwargs – additional keyword arguments
run()[source]
class ethoscope.hardware.input.cameras.DummyPiCameraAsync(target_fps=20, target_resolution=(1280, 960), *args, **kwargs)[source]

Bases: ethoscope.hardware.input.cameras.OurPiCameraAsync

Class to mimic the behaviour of OurPiCameraAsync. This is intended for testing purposes. This way, we can emulate the async functionality of the hardware camera by a video file.

Class to acquire frames from the raspberry pi camera asynchronously. At the moment, frames are only greyscale images.

Parameters:
  • target_fps (int) – the desired number of frames par second (FPS)
  • target_fps – the desired resolution (W x H)
  • target_resolution – (int,int)
  • args – additional arguments
  • kwargs – additional keyword arguments
class ethoscope.hardware.input.cameras.MovieVirtualCamera(path, use_wall_clock=False, *args, **kwargs)[source]

Bases: ethoscope.hardware.input.cameras.BaseCamera

Class to acquire frames from a video file.

Parameters:
  • path (str) – the path of the video file
  • use_wall_clock (bool) – whether to use the real time from the machine (True) or from the video file (False). The former can be useful for prototyping.
  • args – additional arguments.
  • kwargs – additional keyword arguments.
is_last_frame()[source]
is_opened()[source]
path
restart()[source]
start_time
class ethoscope.hardware.input.cameras.OurPiCameraAsync(target_fps=20, target_resolution=(1280, 960), *args, **kwargs)[source]

Bases: ethoscope.hardware.input.cameras.BaseCamera

Class to acquire frames from the raspberry pi camera asynchronously. At the moment, frames are only greyscale images.

Parameters:
  • target_fps (int) – the desired number of frames par second (FPS)
  • target_fps – the desired resolution (W x H)
  • target_resolution – (int,int)
  • args – additional arguments
  • kwargs – additional keyword arguments
is_last_frame()[source]
is_opened()[source]
restart()[source]
start_time
class ethoscope.hardware.input.cameras.PiFrameGrabber(target_fps, target_resolution, queue, stop_queue, *args, **kwargs)[source]

Bases: multiprocessing.process.Process

Class to grab frames from pi camera. Designed to be used within OurPiCameraAsync This allows to get frames asynchronously as acquisition is a bottleneck.

Parameters:
  • target_fps (int) – desired fps
  • target_resolution ((int, int)) – the desired resolution (w, h)
  • queue (JoinableQueue) – a queue that stores frame and makes them available to the parent process
  • stop_queue (JoinableQueue) – a queue that can stop the async acquisition
  • args – additional arguments
  • kwargs – additional keyword arguments
run()[source]

Initialise pi camera, get frames, convert them fo greyscale, and make them available in a queue. Run stops if the _stop_queue is not empty.

class ethoscope.hardware.input.cameras.V4L2Camera(device=0, target_fps=5, target_resolution=(960, 720), *args, **kwargs)[source]

Bases: ethoscope.hardware.input.cameras.BaseCamera

class to acquire stream from a video for linux compatible device (v4l2).

Parameters:
  • device (int or str) – The index of the device, or its path.
  • target_fps (int) – the desired number of frames par second (FPS)
  • target_fps – the desired resolution (W x H)
  • target_resolution – (int,int)
  • args – additional arguments
  • kwargs – additional keyword arguments
is_last_frame()[source]
is_opened()[source]
restart()[source]
start_time

Module contents