-
Notifications
You must be signed in to change notification settings - Fork 0
Simulated Camera
The simulated camera can be used for testing the full functionality of the program without a real camera attached. This is used for test cases as well as development purposes.
To switch between to the simulated camera add -Dspring.profiles.active="simulated_camera" as a JVM argument.
- When running a jar from the command line the call looks like this
java -Dspring.profiles.active="simulated_camera" -jar <your_jar_name>.jar
- When running the program from Intellij, add
-Dspring.profiles.active="simulated_camera"
as a VM Option in Run -> Edit Configurations menu.
Note: When the simulated camera is active, a log entry states during program startup: "Simulated Camera active"
The simulated camera will show up like real camera with the label SIMULATED_CAMERA and just as a real camera it has to be activated in a profile.
The simulated camera in itself is implemented in the SimCameraHandler
class as another implementation of the CameraHandler
interface and uses the SimCameraThread
which, extends the abstract CameraThread
class. More documentation on how the camera package is structured can be found in the corresponding wiki page.
Note: The simulated camera does not require the libgphoto2 library and can be used even if this library is not present, such as a windows system.
The SimCameraHandler
could be easily extended to simulate multiple cameras, as all methods support this, but currently only one simulated camera is instantiated at the constructor
The SimCameraThread
represents one simulated camera and is responsible for simulating the preview and shot images. This is done by loading a predefined image from the resource package.
The switch between the real camera handler and the simulated camera handler is done by using Spring Profiles, which enable the user to specify at runtime, which implementation of the CameraHandler
interface should be used. The SimCameraHandler
is used when the "simulated_camera" profile is active and the CameraHandlerImpl
is used when the "simulated_camera" profile is not active using @Profile("simulated_camera")
and @Profile("!simulated_camera")
respectively.
More information about Spring Profiles and how they can be used or activated can be found in the Spring Documentation.