Device
[Hardware Package]
Collaboration diagram for Device:
|
Both physical camera and logical cameras are derived from the Device base class. A physical camera represents the state of the actual hardware. Implementations are responsible for enforcing that no more than one physical camera variable be constructed for each hardware camera.
Camera is derived from Device, and is the base class for all logical cameras. A logical camera represents the user's view of the camera state. A change of state in one logical camera does not affect the state of another logical camera, even if they both refer to the same piece of hardware. A logical camera implementation is required to maintain a local cache of logical camera state. The acquire member function performs an atomic operation which both sets the physical camera state to match that of the logical camera, and acquires a single image.
A logical camera should not be shared between tasks. A physical camera may be safely shared between tasks if each task constructs its own logical camera and all access to the physical camera is via these logical cameras.
An algorithm may be written without knowledge of the type of Camera being used:
void my_algorithm(Camera & my_camera) { Camera_Image<uint8_t> my_image; my_camera.set_exposure(0.25); my_camera.acquire(my_image); ... }
We can then pass a specific implemenation to the algorithm:
XYZ_HW_Camera hw_camera(0x0233432, 0x343); XYZ_Camera my_logical_camera(hw_camera); my_algorithm(my_logical_camera);