pytweezer.drivers.camera_base module¶
Generic camera abstraction shared by every real camera driver.
Rather than each camera module hand-rolling its own ROI/trigger/acquisition logic and its own simulated twin, this module defines:
Camera– an abstract base that owns everything generic to a camera server (broadcasting frames onto an image stream, TIFF autosave, the autosave/broadcast acquisition loop, connection lifecycle) and declares the small set of hardware-specific hooks a concrete driver must implement (connect/disconnect, ROI, trigger, exposure, acquisition start/stop, and the raw frame read).SimulatedCamera– a single, one-size-fits-all synthetic backend that implements those hooks with generated frames, usable in place of any real camera in simulation mode.simulated_camera_for()– adaptsSimulatedCamerato a specific real driver so that driver’s extra methods (e.g. the ImagEM’s EM-gain setters) are auto-stubbed viapytweezer.servers.simulated_device.simulate(), keeping the simulated surface interface-complete without drift.
A concrete driver (“shim”) is therefore just the thin translation layer between its vendor SDK (dcam, Spinnaker, …) and the abstract hooks below.
- class pytweezer.drivers.camera_base.Camera(image_dir=None, timeout=5.0, stream_name=None)[source]¶
Bases:
ABCAbstract base for a single-camera RPC target.
Subclasses (“shims”) implement the abstract hardware hooks; everything generic – image broadcasting, TIFF autosave, the acquisition loop, and the connection lifecycle – lives here so each driver stays a thin translation layer over its vendor SDK.
The connected hardware handle is stored on
_backend;Nonemeans the camera has been relinquished. Subclasses set it in_connect()and clear it (implicitly, viaclose()) on teardown.- image_prefix: str = 'image'¶
Filename prefix used by
save_tiff(); override per driver.
- abstractmethod set_exposure_time(exposure)[source]¶
Set the per-frame exposure time in seconds.
- Parameters:
exposure (float)
- Return type:
None
- abstractmethod set_roi(x0, width, y0, height)[source]¶
Restrict readout to the given region of interest (pixels).
- abstractmethod set_trigger_source(source)[source]¶
Select the trigger mode/source (e.g.
"int"/"ext").- Parameters:
source (str)
- Return type:
None
- class pytweezer.drivers.camera_base.SimulatedCamera(image_dir=None, timeout=5.0, stream_name=None)[source]¶
Bases:
CameraOne-size-fits-all synthetic camera backend.
Implements every
Camerahardware hook with generated frames, so it can stand in for any real camera in simulation mode. Driver-specific extra methods (beyond theCamerainterface) are not defined here; usesimulated_camera_for()to auto-stub those for a particular driver.- set_exposure_time(exposure)[source]¶
Set the per-frame exposure time in seconds.
- Parameters:
exposure (float)
- Return type:
None
- set_trigger_source(source)[source]¶
Select the trigger mode/source (e.g.
"int"/"ext").- Parameters:
source (str)
- Return type:
None
- pytweezer.drivers.camera_base.requires_camera(func)[source]¶
Guard a method so it raises cleanly if the camera has been relinquished.
- pytweezer.drivers.camera_base.simulated_camera_for(real_cls)[source]¶
Return a
SimulatedCamerasubclass tailored toreal_cls.The returned class has the full generic simulated behaviour, plus a logging no-op stub for every public method
real_clsadds beyond theCamerainterface (e.g. a driver’s EM-gain setters), courtesy ofsimulate(). This keeps the simulated surface interface-complete with the real driver without any hand-written per-driver simulated class.