-
Notifications
You must be signed in to change notification settings - Fork 1
Technical
Building
Building libcam_fltk requires FLTK V1.4 and its dependencies to be built and installed. Otherwise follow the same steps as building libcamera-apps:
cd libcamera-apps
mkdir build
cd build
cmake .. -DENABLE_DRM=1 -DENABLE_X11=1 -DENABLE_QT=1 -DENABLE_OPENCV=0 -DENABLE_TFLITE=0
make -j4
Replacing FLTK
A GUI can be written using other frameworks than FLTK. The camera specific functionality is limited to camThread.cpp
(see below). A different GUI can use the camThread.cpp
as-is by implementing the same inter-thread shared memory variables.
The only use of FLTK in camThread.cpp
is to invoke guiEvent
, which sends a message to the main GUI thread. The use of FLTK guiEvent
can be replaced by the appropriate mechanism from your GUI framework of choice.
The Camera Thread
The actual interaction with the camera / libcamera-apps is via the camera thread. The code for this can be found in camthread.cpp. The camera thread is literally a separate thread, in order to not interfere with the behavior of the main, GUI thread.
The camera process is a state machine, following the libcamera-app programs. The overview of the state machine is:
The "triggers" occur by changes to the inter-thread shared memory variables. E.g. when the GUI modifies the "stateChange" variable, this causes the state machine to "react" to the "Settings Change Trigger".
All interactions with the lib-camera must follow these steps:
- Stop the camera.
- Tear down the camera.
- Perform your activity (modify settings; change camera state; save image).
- Start the camera.
Changes to libcamera-apps code
Some changes were made to the libcamera-app codebase to support the GUI.
Preview Window
libcam_fltk allows the user to a) show and hide the preview window; b) change the preview window size; c) save and restore the preview window location.
Methods were added to the preview code to allow setting and getting the preview window location.
Hiding the preview window and changing its size both require destroying the preview window and being able to re-create it. Changes were made to the preview destructor and reset methods to make this possible.
Disable Preview Window Close
The libcamera-app programs will shut down when the user closes the Preview Window. This is not desirable for a GUI and was disabled.
Image Capture
The JPEG/PNG save functions were crudely copied to deal with type conflicts between VideoOptions
and StillOptions
. The copied JPEG code currently does not permit saving EXIF data. These changes should be unnecessary in a future release.