conservationtechlab / dencam

Polar bear maternal den observation system.
MIT License
5 stars 2 forks source link

Refactor: Make `recorder.BaseRecorder` agnostic to camera type #101

Closed iingram closed 1 month ago

iingram commented 1 month ago

Move picamera-specific bits out of BaseRecorder

In prep for adding code to handle a different kind of camera (i.e. a ptz network surveillance camera for cyclops project), refactoring out picamera-specific bits of BaseRecorder and into a derived class (via the subclass Recorder as that's got some stuff we want, too). The derived class is in a separate module so that the picamera package import is only required in that module. The idea is that we will make a similar derived class for the ptz camera, and BaseRecorder and Recorder (and thus ideally everything in recorder.py) will be truly agnostic to the difference systems.

An assumption is that we will wrap the ptz camera control code in methods that match those of picamera.PiCamera so that every place in recorder.py that self.camera uses those methods it will all work.

Ideally, we will also be able to do a similar thing with changes necessary for picamera2 i.e. make class derived from Recorder in its own module that implements everything as it needs to be for using picamera2. That is part of the reason we didn't use an alternate solution: making a camera object an argument to BaseRecorder constructor and initializing the camera in the top-level application module.

Resolves #98

iingram commented 1 month ago

yeah, agreed that we want to do that. but also agreed that that is best done later. first: this surgery. second: build a similar class that mirrors this PicameraRecorder for the ptz context (including an additional class that mirrors picamera.Picamera functionality for the ptz camera that is used by that "PTZRecorder" class). third: assuming no surprises there, then make it so dencam.py can just use a config file switch to determine which Recorder subclass to use. Seems cleanest to it in that order, particularly as there is some linting and refactoring we probably want to do on dencam.py itself first.