AHF_Camera
AHF_Camera refers to modules responsible for controlling recordings. Camera control is coordinated by AHF_Stimulator.
AHF_Camera.AHF_Camera module
- class AHF_Camera.AHF_Camera(taskP, settingsDictP)
Bases:
AHF_Base.AHF_BaseAHF_Camera is the base class for the main brain imaging camera used in AutoHeadFix. This class is used to manage recordings and previews. Currently implemented only by AHF_Camera_PiCam (See below).
- abstract resolution()
Return the resolution of the camera. Used for certain stimulators.
- abstract start_preview()
Starts a preview of the camera’s current vision.
- abstract start_recording()
Starts a recording of the camera’s current vision.
- abstract stop_preview()
Ends a preview of the camera’s current vision.
- abstract stop_recording()
Ends a recording of the camera’s current vision.
AHF_Camera.AHF_Camera_PiCam module
- class AHF_Camera_PiCam.AHF_Camera_PiCam(taskP, settingsDictP)
Bases:
AHF_Camera.AHF_CameraAHF_Camera_PiCam implements AHF_Camera for Raspberry Pi Cameras, using the picamera2 library. The library supports raw YUV, RGB, or Bayer frames, as well as H264- or MJPEG-encoded videos. Refer to the Picamera2 manual for further information.
- static about()
Returns a brief message describing your sub-class, used when asking user to pick a sub-class of this class
- add_overlay(bytes, layer, alpha)
- capture(path, type, video_port=False)
- static config_user_get(starterDict={})
static method that querries user for settings, with default responses from starterDict, and returns starterDict with settings as edited by the user.
- hardwareTest()
Tests functionality, gives user a chance to change settings
- remove_overlay(overlay)
- resolution()
Return the resolution of the camera. Used for certain stimulators.
- set_gain()
Sets the gain and white balance of the camera based on a 2 second preview - so set illumination as you like before calling
If ISO for the camera is set to non-zero value, gain is not settable. If pWhiteBalance was set to False, white balancing is not done, and gains for red and green are set to 1. :raises PiCameraError: error raised by superclass Picamera2 from preview
- setdown()
Writes session end and closes log file
- setup()
does hardware initialization with(possibly updated) info in self.settingsDict Run by __init__, or can be run separately after editing the settingsDict
- Returns
- code
bool whether setup completed without errors
- start_preview()
Starts a preview of the camera’s current vision.
- start_recording(video_name_path)
Starts a video recording using the saved settings for format, quality, gain, etc.
A preview of the recording is always shown
- Parameters
video_name_path – a full path to the file where the video will be stored. Always save to a file, not a PIL, for, example
- stop_preview()
Ends a preview of the camera’s current vision.
- stop_recording()
Stops a video recording previously started with start_recording.
- timed_recording(video_name_path, recTime)
Does a timed video recording using the Picamera2 wait_recording function.
A preview of the recording is always shown
Control does not pass back to the calling function until the recording is finished :param video_name_path: a full path to the file where the video will be stored. :param recTime: duration of the recorded video, in seconds