
FujiSxCamera C++ library
v2.4.1
Table of contents
- Overview
- Versions
- Library files
- FujiSxCamera class description
- FujiSxCamera class declaration
- getVersion method
- openLens method
- openCamera method
- initLens method
- initCamera method
- closeLens method
- closeCamera method
- isLensOpen method
- isCameraOpen method
- isLensConnected method
- isCameraConnected method
- setParam method
- getParam method
- getParams method
- executeCommand method
- addVideoFrame method
- decodeAndExecuteCommand method
- encodeSetParamCommand method of Lens class
- encodeCommand method of Lens class
- decodeCommand method of Lens class
- encodeSetParamCommand method of Camera class
- encodeCommand method of Camera class
- decodeCommand method of Camera class
- Data structures
- LensParams class description
- CameraParams class description
- Build and connect to your project
- Simple example
- Test application
- Speed test application
Overview
The FujiSxCamera C++ library is software for controlling Fujifilm long-range surveillance cameras in the SX Series. Fujifilm SX cameras are block cameras that combine a lens and a camera (image sensor) and provide a single control interface (serial port). The FujiSxCamera library supports Fuji SX800 and SX1600 models. The library inherits interfaces from Lens and Camera. It depends on the following libraries: Lens (provides interface and data structures to control lenses, source code included, Apache 2.0 license), Camera (provides interface and data structures to control cameras, source code included, Apache 2.0 license), Logger (provides functions to print logs, source code included, Apache 2.0 license), SerialPort (provides functions to work with serial ports, source code included, Apache 2.0 license), and FujiSxParser (provides functions to encode control commands and decode responses from Fujifilm SX cameras). The FujiSxCamera library provides a simple interface to be integrated into any C++ project. The library has no third-party dependencies that need to be specially installed in the OS. It is developed with the C++17 standard and is compatible with Linux and Windows.
Versions
Table 1 - Library versions.
| Version | Release date | What’s new |
|---|---|---|
| 1.0.0 | 03.04.2023 | First version. |
| 2.0.0 | 10.01.2024 | - Parser updated. - Documentation added. |
| 2.0.1 | 26.04.2024 | - Code reviewed. - Documentation updated. |
| 2.0.2 | 13.05.2024 | - Bug fixes. |
| 2.0.3 | 24.05.2024 | - Submodules updated. - Documentation updated. |
| 2.0.4 | 30.07.2024 | - CMake structure updated. |
| 2.1.0 | 05.10.2024 | - Fix of parameters control. - Add camera menu control. - Update protocol parser submodule. |
| 2.1.1 | 31.03.2025 | - New parameters added. - Small bug fixes on range conversions for parser. - Logger submodule update. |
| 2.1.2 | 10.04.2025 | - Add CUSTOM params to Camera and Lens interface. |
| 2.2.0 | 25.06.2025 | - Add new parameters. |
| 2.2.1 | 16.07.2025 | - Add video stabilization parameters. |
| 2.2.2 | 25.08.2025 | - Add profile parameter for camera presets. - Fix zoom / focus to position report after to position command. |
| 2.2.3 | 19.09.2025 | - Add default values for noise reduction mode and for shutter mode. |
| 2.3.0 | 25.10.2025 | - Add field of view control. - Fix bugs in parameters. - FujiSxParser submodule update. |
| 2.3.1 | 03.02.2026 | - Added different iris mode values for Fuji SX800 and SX1600 models. |
| 2.3.2 | 01.03.2026 | - Added digital zoom mode control after connection to camera. |
| 2.4.0 | 23.05.2026 | - Added AF area zone control for SX1600 (4-step focus area position sequence via FujiSxParser 2.1.0). - Fixed FILTER_MODE range and AF area zone validation. - Fixed wrong error messages, variable typos and logging-flag access consistency. - Documentation and code-comment review. - FujiSxParser submodule updated to 2.1.0. |
| 2.4.1 | 05.06.2026 | - Bug fixes. - Documentation updated. - Send zoom and focus stop commands as soon as possible. - Update test application. - Clean up the code. - Add speed tester. - Fix iris mode functionality. - Fix getParam methods for lens and camera. - Sync library AF sensivity value with camera. - Update FujiSxParser submodule. |
Library files
The library is supplied as source code only. The user is provided with a set of files in the form of a CMake project (repository). The repository structure is shown below:
CMakeLists.txt ---------------- Main CMake file of the library.
3rdparty ---------------------- Folder with third-party libraries.
CMakeLists.txt ------------ CMake file which includes third-party libraries.
Camera -------------------- Folder with Camera library source code.
FujiSxParser -------------- Folder with FujiSxParser library source code.
Lens ---------------------- Folder with Lens library source code.
Logger -------------------- Folder with Logger library source code.
SerialPort ---------------- Folder with SerialPort library source code.
test -------------------------- Folder with test application.
CMakeLists.txt ------------ CMake file for test application.
main.cpp ------------------ Source code file of test application.
example ----------------------- Folder with example application.
CMakeLists.txt ------------ CMake file for example application.
main.cpp ------------------ Source code file of example application.
speedTester ------------------- Folder with speed test application.
CMakeLists.txt ------------ CMake file for speed test application.
main.cpp ------------------ Source code file of speed test application.
src --------------------------- Folder with source code of the library.
CMakeLists.txt ------------ CMake file of the library.
FujiSxCamera.cpp ---------- Source code file of the library.
FujiSxCamera.h ------------ Header file which includes FujiSxCamera class declaration.
FujiSxCameraVersion.h ----- Header file which includes version of the library.
FujiSxCameraVersion.h.in -- CMake service file to generate version file.
FujiSxCamera class description
FujiSxCamera class declaration
The FujiSxCamera class is declared in the FujiSxCamera.h file. The FujiSxCamera class implements both Lens and Camera interfaces, so it includes a set of similar methods (for lens and camera control). Class declaration:
namespace cr
{
namespace fuji
{
class FujiSxCamera : public cr::camera::Camera, public cr::lens::Lens
{
public:
/// Class destructor.
~FujiSxCamera();
/// Get class version.
static std::string getVersion();
/// Decode and execute command.
bool decodeAndExecuteCommand(uint8_t* data, int size) override;
// #######################################
// CAMERA CONTROL INTERFACE
// #######################################
/// Open controller serial port.
bool openCamera(std::string initString) override;
/// Init camera by parameters structure.
bool initCamera(cr::camera::CameraParams& params) override;
/// Close controller.
void closeCamera() override;
/// Get serial port open status.
bool isCameraOpen() override;
/// Get camera connection status.
bool isCameraConnected() override;
/// Set the camera parameter.
bool setParam(cr::camera::CameraParam id, float value) override;
/// Get the camera parameter.
float getParam(cr::camera::CameraParam id) override;
/// Get the camera params.
void getParams(cr::camera::CameraParams& params) override;
/// Execute camera command.
bool executeCommand(cr::camera::CameraCommand id) override;
// #######################################
// LENS CONTROL INTERFACE
// #######################################
/// Open controller serial port.
bool openLens(std::string initString) override;
/// Init lens by parameters structure.
bool initLens(cr::lens::LensParams& params) override;
/// Close controller.
void closeLens() override;
/// Get serial port open status.
bool isLensOpen() override;
/// Get camera connection status.
bool isLensConnected() override;
/// Set the lens parameter.
bool setParam(cr::lens::LensParam id, float value) override;
/// Get the lens parameter.
float getParam(cr::lens::LensParam id) override;
/// Get the lens params.
void getParams(cr::lens::LensParams& params) override;
/// Execute lens command.
bool executeCommand(cr::lens::LensCommand id, float arg = 0) override;
/// Not supported.
void addVideoFrame(cr::video::Frame& frame) override;
};
}
}
getVersion method
The getVersion() method returns a string with the FujiSxCamera class version. Method declaration:
static std::string getVersion();
Method can be used without FujiSxCamera class instance:
std::cout << "FujiSxCamera class version: " << cr::fuji::FujiSxCamera::getVersion();
Console output:
FujiSxCamera class version: 2.4.1
openLens method
The openLens(…) opens a serial port to communicate with the Fujinon SX camera. To initialize the serial port, the user can call openCamera(…) or openLens(…) method (it doesn’t matter which). If the serial port is already open, the method will return TRUE. Camera and lens parameters will be initialized by default. Method declaration:
bool openLens(std::string initString) override;
| Parameter | Value |
|---|---|
| initString | Initialization string. Format can be in 3 different forms: - [serial port name];[baudrate];[lens address] - [serial port name];[baudrate] - [serial port name] When the lens address is not given, it is set to 7 (according to protocol specification) as default, and the same for baudrate to 9600. Recommended initialization string format for controllers that use a serial port: “/dev/ttyUSB0;9600;7” (“/dev/ttyUSB0” - serial port name, “9600” - baudrate, “7” - lens address). |
Returns: TRUE if the controller initialized or FALSE if not.
openCamera method
The openCamera(…) opens a serial port to communicate with the Fujinon SX camera. To initialize the serial port, the user can call openCamera(…) or openLens(…) method (it doesn’t matter which). If the serial port is already open, the method will return TRUE. Camera and lens parameters will be initialized by default. Method declaration:
bool openCamera(std::string initString) override;
| Parameter | Value |
|---|---|
| initString | Initialization string. Format can be in 3 different forms: - [serial port name];[baudrate];[camera address] - [serial port name];[baudrate] - [serial port name] When the camera address is not given, it is set to 7 (according to protocol specification) as default, and the same for baudrate to 9600. Recommended initialization string format for controllers that use a serial port: “/dev/ttyUSB0;9600;7” (“/dev/ttyUSB0” - serial port name, “9600” - baudrate, “7” - camera address). |
Returns: TRUE if the controller initialized or FALSE if not.
initLens method
The initLens(…) initializes the controller and sets lens params (Lens interface). The method will set the given lens params and afterwards will call the openLens(…) method. The method doesn’t initialize camera params (Camera interface). To initialize camera params, the user should call the initCamera(…) method. After successful initialization, the library will run communication threads (thread to communicate with equipment via serial port) if they are not already running. Method declaration:
bool initLens(cr::lens::LensParams& params) override;
| Parameter | Value |
|---|---|
| params | LensParams class object. LensParams class includes initString which is used in openLens(…) method. |
Returns: TRUE if the controller initialized and lens parameters were set or FALSE if not.
initCamera method
The initCamera(…) initializes the controller and sets camera params (Camera interface). The method will set the given camera params and afterwards will call the openCamera(…) method. The method doesn’t initialize lens params (Lens interface). To initialize lens params, the user should call the initLens(…) method. After successful initialization, the library will run communication threads (thread to communicate with equipment via serial port) if they are not already running. Method declaration:
bool initCamera(CameraParams& params) override;
| Parameter | Value |
|---|---|
| params | CameraParams class object. CameraParams class includes initString which is used in openCamera(…) method. |
Returns: TRUE if the controller initialized and camera parameters were set or FALSE if not.
closeLens method
The closeLens() closes the serial port and stops the communication thread. The result of the method is equal to closeCamera(…) method (user can use any of them). Method declaration:
void closeLens() override;
closeCamera method
closeCamera() closes the serial port and stops the communication thread. The result of the method is equal to closeLens(…) method (user can use any of them). Method declaration:
void closeCamera() override;
isLensOpen method
The isLensOpen() method returns the controller initialization status. Open status shows if the controller is initialized (serial port open) but doesn’t show if the controller has communication with equipment. For example, if the serial port is open (opens serial port file in OS) but the equipment is not active (no power). In this case, the open status just shows that the serial port is open. This method is equal to the isCameraOpen(…) method. Method declaration:
bool isLensOpen() override;
Returns: TRUE if the controller is initialized (serial port open) or FALSE if not.
isCameraOpen method
The isCameraOpen() method returns the controller initialization status. Open status shows if the controller is initialized (serial port open) but doesn’t show if the controller has communication with equipment. For example, if the serial port is open (opens serial port file in OS) but the equipment is not active (no power). In this case, the open status just shows that the serial port is open. This method is equal to the isLensOpen(…) method. Method declaration:
bool isCameraOpen() override;
Returns: TRUE if the controller is initialized (serial port open) or FALSE if not.
isLensConnected method
The isLensConnected() shows if the controller receives responses from equipment (camera). For example, if the serial port is open but the equipment is not active (no power). In this case, the isLensOpen(…) and isCameraOpen(…) methods will return TRUE but isLensConnected() method will return FALSE. This method is equal to the isCameraConnected(…) method (user can use any of them). Method declaration:
bool isLensConnected() override;
Returns: TRUE if the controller has data exchange with equipment or FALSE if not.
isCameraConnected method
The isCameraConnected() shows if the controller receives responses from equipment (camera). For example, if the serial port is open but the equipment is not active (no power). In this case, the isLensOpen(…) and isCameraOpen(…) methods will return TRUE but isCameraConnected() method will return FALSE. This method is equal to the isLensConnected(…) method (user can use any of them). Method declaration:
bool isCameraConnected() override;
Returns: TRUE if the controller has data exchange with equipment or FALSE if not.
setParam method
The setParam(…) is an overloaded method. The method is intended to set Camera or Lens parameter values. Method declarations:
bool setParam(LensParam id, float value) override;
bool setParam(CameraParam id, float value) override;
| Parameter | Description |
|---|---|
| id | Lens parameter ID according to LensParam enum or camera parameter ID according to CameraParam enum. |
| value | Camera or Lens parameter value. Valid values depend on parameter ID. |
Returns: TRUE if the parameter is set (accepted by controller) or FALSE if not.
getParam method
The getParam(…) is an overloaded method. The method is intended to obtain Camera or Lens parameter values. Note: the method returns parameters that were stored in local structures and doesn’t control if these parameters are valid in camera hardware. Method declaration:
float getParam(LensParam id) override;
float getParam(CameraParam id) override;
| Parameter | Description |
|---|---|
| id | Lens parameter ID according to LensParam enum or camera parameter ID according to CameraParam enum. |
Returns: parameter value or -1 if the parameter is not supported.
getParams method
The getParams(…) is an overloaded method. The method is intended to obtain the Camera or Lens parameters structure. Note: the method returns parameters that are stored in local structures and does not check whether these parameters are valid in camera hardware. Method declaration:
void getParams(LensParams& params) override;
void getParams(CameraParams& params) override;
| Parameter | Description |
|---|---|
| params | Reference to LensParams class object or CameraParams class object. |
executeCommand method
The executeCommand(…) is an overloaded method. The method is intended to execute a Camera or Lens action command. Method declaration:
bool executeCommand(LensCommand id, float arg = 0) override;
bool executeCommand(CameraCommand id) override;
| Parameter | Description |
|---|---|
| id | Camera command ID according to CameraCommand enum or lens command ID according to LensCommand enum. |
| arg | Only for lens interface. Lens command argument. Valid values depend on command ID. |
Returns: TRUE if the command is executed (accepted by controller) or FALSE if not.
addVideoFrame method
The addVideoFrame(…) method is declared by the Lens interface to pass video frame data to the lens controller for autofocus algorithms. It is not supported by the FujiSxCamera class (the implementation is a no-op). Method declaration:
void addVideoFrame(cr::video::Frame& frame) override;
| Parameter | Description |
|---|---|
| frame | Frame class object. |
decodeAndExecuteCommand method
The decodeAndExecuteCommand(…) method decodes and executes a command on the controller side. The method decodes commands encoded by the encodeCommand(…) and encodeSetParamCommand(…) methods of the Lens and Camera interface classes. If the command is successfully decoded, the method calls the setParam(…) or executeCommand(…) methods of the Lens or Camera interface. This method is thread-safe and can be safely called from any thread. Method declaration:
bool decodeAndExecuteCommand(uint8_t* data, int size) override;
| Parameter | Description |
|---|---|
| data | Pointer to input command. |
| size | Size of command. 11 bytes for Lens commands (SET_PARAM and COMMAND) and Camera SET_PARAM; 7 bytes for Camera COMMAND. |
Returns: TRUE if the command is decoded (SET_PARAM or COMMAND) and executed (action command or set-param command), FALSE otherwise.
encodeSetParamCommand method of Lens class
The encodeSetParamCommand(…) static method of the Lens interface class is designed to encode command to change any remote lens parameter. To control a lens remotely, the developer has to develop his own protocol and according to it encode the command and deliver it over the communication channel. To simplify this, the Lens class contains static methods for encoding the control command. The Lens class provides two types of commands: a parameter change command (SET_PARAM) and an action command (COMMAND). encodeSetParamCommand(…) is designed to encode the SET_PARAM command. Method declaration:
static void encodeSetParamCommand(uint8_t* data, int& size, LensParam id, float value);
| Parameter | Description |
|---|---|
| data | Pointer to data buffer for encoded command. Must have size >= 11. |
| size | Size of encoded data. Will be 11 bytes. |
| id | Parameter ID according to LensParam enum. |
| value | Parameter value. |
encodeSetParamCommand(…) is static and used without Lens class instance. This method is used on client side (control system). Example:
// Buffer for encoded data.
uint8_t data[11];
// Size of encoded data.
int size = 0;
// Random parameter value.
float outValue = (float)(rand() % 20);
// Encode command.
Lens::encodeSetParamCommand(data, size, LensParam::AF_ROI_X0, outValue);
encodeCommand method of Lens class
The encodeCommand(…) static method of the Lens interface class is designed to encode lens action command. To control a lens remotely, the developer has to develop his own protocol and according to it encode the command and deliver it over the communication channel. To simplify this, the Lens class contains static methods for encoding the control command. The Lens class provides two types of commands: a parameter change command (SET_PARAM) and an action command (COMMAND). encodeCommand(…) is designed to encode the COMMAND command (action command). Method declaration:
static void encodeCommand(uint8_t* data, int& size, LensCommand id, float arg = 0.0f);
| Parameter | Description |
|---|---|
| data | Pointer to data buffer for encoded command. Must have size >= 11. |
| size | Size of encoded data. Will be 11 bytes. |
| id | Command ID according to LensCommand enum. |
| arg | Command argument value (value depends on command ID). |
COMMAND format:
encodeCommand(…) is static and used without Lens class instance. This method is used on client side (control system). Encoding example:
// Buffer for encoded data.
uint8_t data[11];
// Size of encoded data.
int size = 0;
// Random command argument value.
float outValue = (float)(rand() % 20);
// Encode command.
Lens::encodeCommand(data, size, LensCommand::ZOOM_TO_POS, outValue);
decodeCommand method of Lens class
The decodeCommand(…) static method of the Lens interface class is designed to decode command on lens controller side. To control a lens remotely, the developer has to develop his own protocol and according to it decode the command on lens controller side. To simplify this, the Lens interface class contains static method to decode input command (commands should be encoded by methods encodeSetParamCommand(…) or encodeCommand(…)). The Lens class provides two types of commands: a parameter change command (SET_PARAM) and an action command (COMMAND). Method declaration:
static int decodeCommand(uint8_t* data, int size, LensParam& paramId, LensCommand& commandId, float& value);
| Parameter | Description |
|---|---|
| data | Pointer to input command. |
| size | Size of command. Should be 11 bytes. |
| paramId | Lens parameter ID according to LensParam enum. After decoding SET_PARAM command the method will return parameter ID. |
| commandId | Lens command ID according to LensCommand enum. After decoding COMMAND the method will return command ID. |
| value | Lens parameter value (after decoding SET_PARAM command) or lens command argument (after decoding COMMAND). |
Returns: 0 - in case of decoding COMMAND, 1 - in case of decoding SET_PARAM command or -1 in case of errors.
encodeSetParamCommand method of Camera class
encodeSetParamCommand(…) static method of Camera interface class encodes command to change any remote camera parameter value. To control a camera remotely, the developer has to design his own protocol and according to it encode the command and deliver it over the communication channel. To simplify this, the Camera class contains static methods for encoding the control command. The Camera class provides two types of commands: a parameter change command (SET_PARAM) and an action command (COMMAND). encodeSetParamCommand(…) is designed to encode the SET_PARAM command. Method declaration:
static void encodeSetParamCommand(uint8_t* data, int& size, CameraParam id, float value);
| Parameter | Description |
|---|---|
| data | Pointer to data buffer for encoded command. Must have size >= 11. |
| size | Size of encoded data. Will be 11 bytes. |
| id | Parameter ID according to CameraParam enum. |
| value | Parameter value. |
encodeSetParamCommand(…) is static and used without Camera class instance. This method is used on client side (control system). Command encoding example:
// Buffer for encoded data.
uint8_t data[11];
// Size of encoded data.
int size = 0;
// Encode command.
Camera::encodeSetParamCommand(data, size, CameraParam::EXPOSURE_MODE, 2);
encodeCommand method of Camera class
encodeCommand(…) static method of Camera interface class encodes command for camera remote control. To control a camera remotely, the developer has to design his own protocol and according to it encode the command and deliver it over the communication channel. To simplify this, the Camera class contains static methods for encoding the control command. The Camera class provides two types of commands: a parameter change command (SET_PARAM) and an action command (COMMAND). encodeCommand(…) is designed to encode the COMMAND command (action command). Method declaration:
static void encodeCommand(uint8_t* data, int& size, CameraCommand id);
| Parameter | Description |
|---|---|
| data | Pointer to data buffer for encoded command. Must have size >= 7. |
| size | Size of encoded data. Will be 7 bytes. |
| id | Command ID according to CameraCommand enum. |
encodeCommand(…) is static and used without Camera class instance. This method is used on client side (control system). Command encoding example:
// Buffer for encoded data.
uint8_t data[7];
// Size of encoded data.
int size = 0;
// Encode command.
Camera::encodeCommand(data, size, CameraCommand::NUC);
decodeCommand method of Camera class
decodeCommand(…) static method of Camera interface class decodes command on camera controller side. Method declaration:
static int decodeCommand(uint8_t* data, int size, CameraParam& paramId, CameraCommand& commandId, float& value);
| Parameter | Description |
|---|---|
| data | Pointer to input command. |
| size | Size of command. Must be 11 bytes for SET_PARAM and 7 bytes for COMMAND. |
| paramId | Camera parameter ID according to CameraParam enum. After decoding SET_PARAM command the method will return parameter ID. |
| commandId | Camera command ID according to CameraCommand enum. After decoding COMMAND the method will return command ID. |
| value | Camera parameter value (after decoding SET_PARAM command). |
Returns: 0 - in case of decoding COMMAND, 1 - in case of decoding SET_PARAM command or -1 in case of errors.
Data structures
LensCommand enum
Enum declaration:
namespace cr
{
namespace lens
{
enum class LensCommand
{
/// Move zoom tele (in).
ZOOM_TELE = 1,
/// Move zoom wide (out).
ZOOM_WIDE,
/// Move zoom to position.
ZOOM_TO_POS,
/// Stop zoom moving including stop zoom to position command.
ZOOM_STOP,
/// Move focus far.
FOCUS_FAR,
/// Move focus near.
FOCUS_NEAR,
/// Move focus to position.
FOCUS_TO_POS,
/// Stop focus moving including stop focus to position command.
FOCUS_STOP,
/// Move iris open.
IRIS_OPEN,
/// Move iris close.
IRIS_CLOSE,
/// Move iris to position.
IRIS_TO_POS,
/// Stop iris moving including stop iris to position command.
IRIS_STOP,
/// Start autofocus.
AF_START,
/// Stop autofocus.
AF_STOP,
/// Restart lens controller.
RESTART,
/// Detect zoom and focus hardware ranges.
DETECT_HW_RANGES
};
}
}
Table 2 - Lens commands description.
| Command | Description |
|---|---|
| ZOOM_TELE | Move zoom tele (in). Command doesn’t have arguments. User can set zoom movement speed via lens parameters. |
| ZOOM_WIDE | Move zoom wide (out). Command doesn’t have arguments. User can set zoom movement speed via lens parameters. |
| ZOOM_TO_POS | Move zoom to position. Controller has zoom range from 0 (full wide) to 65535 (full tele) regardless of the hardware value of the zoom position. User can set zoom movement speed via lens parameters. |
| ZOOM_STOP | Stop zoom moving including stop zoom to position command. The command will be executed as soon as possible. |
| FOCUS_FAR | Move focus far. Command doesn’t have arguments. User can set focus movement speed via lens parameters. |
| FOCUS_NEAR | Move focus near. Command doesn’t have arguments. User can set focus movement speed via lens parameters. |
| FOCUS_TO_POS | Move focus to position. Controller has focus range from 0 (full near) to 65535 (full far) regardless of the hardware value of the focus position. User can set focus movement speed via lens parameters. |
| FOCUS_STOP | Stop focus moving including stop focus to position command. The command will be executed as soon as possible. |
| IRIS_OPEN | Move iris open. Command doesn’t have arguments. User can set iris movement speed via lens parameters. |
| IRIS_CLOSE | Move iris close. Command doesn’t have arguments. User can set iris movement speed via lens parameters. |
| IRIS_TO_POS | Not supported by FujiSxCamera library. |
| IRIS_STOP | Not supported by FujiSxCamera library. |
| AF_START | Start autofocus. Command doesn’t have arguments. |
| AF_STOP | Not supported by FujiSxCamera library. |
| RESTART | Restart lens controller. |
| DETECT_HW_RANGES | Not supported by FujiSxCamera library. |
CameraCommand enum
Enum declaration:
namespace cr
{
namespace camera
{
enum class CameraCommand
{
/// Restart camera controller.
RESTART = 1,
/// Do NUC.
NUC,
/// Apply settings.
APPLY_PARAMS,
/// Save params.
SAVE_PARAMS,
/// Menu on.
MENU_ON,
/// Menu off.
MENU_OFF,
/// Menu set.
MENU_SET,
/// Menu up.
MENU_UP,
/// Menu down.
MENU_DOWN,
/// Menu left.
MENU_LEFT,
/// Menu right.
MENU_RIGHT,
/// Freeze, Argument: time msec.
FREEZE,
/// Disable freeze.
DEFREEZE
};
}
}
Table 3 - Camera commands description.
| Command | Description |
|---|---|
| RESTART | Restart camera controller. |
| NUC | Not supported by FujiSxCamera library. |
| APPLY_PARAMS | Defined as MENU BACK command. |
| SAVE_PARAMS | Not supported by FujiSxCamera library. |
| MENU_ON | Enter camera menu. |
| MENU_OFF | Exit camera menu. |
| MENU_SET | Menu SET command. |
| MENU_UP | Move menu cursor up. |
| MENU_DOWN | Move menu cursor down. |
| MENU_LEFT | Move menu cursor left. |
| MENU_RIGHT | Move menu cursor right. |
| FREEZE | Not supported by FujiSxCamera library. |
| DEFREEZE | Not supported by FujiSxCamera library. |
LensParam enum
Enum declaration:
namespace cr
{
namespace lens
{
enum class LensParam
{
/// Zoom position.
ZOOM_POS = 1,
/// Hardware zoom position.
ZOOM_HW_POS,
/// Focus position.
FOCUS_POS,
/// Hardware focus position.
FOCUS_HW_POS,
/// Iris position.
IRIS_POS,
/// Hardware iris position.
IRIS_HW_POS,
/// Focus mode.
FOCUS_MODE,
/// Filter mode.
FILTER_MODE,
/// Autofocus ROI top-left corner horizontal position in pixels.
AF_ROI_X0,
/// Autofocus ROI top-left corner vertical position in pixels.
AF_ROI_Y0,
/// Autofocus ROI bottom-right corner horizontal position in pixels.
AF_ROI_X1,
/// Autofocus ROI bottom-right corner vertical position in pixels.
AF_ROI_Y1,
/// Zoom speed.
ZOOM_SPEED,
/// Zoom hardware speed.
ZOOM_HW_SPEED,
/// Maximum zoom hardware speed.
ZOOM_HW_MAX_SPEED,
/// Focus speed.
FOCUS_SPEED,
/// Focus hardware speed.
FOCUS_HW_SPEED,
/// Maximum focus hardware speed.
FOCUS_HW_MAX_SPEED,
/// Iris speed.
IRIS_SPEED,
/// Iris hardware speed.
IRIS_HW_SPEED,
/// Maximum iris hardware speed.
IRIS_HW_MAX_SPEED,
/// Zoom hardware tele limit.
ZOOM_HW_TELE_LIMIT,
/// Zoom hardware wide limit.
ZOOM_HW_WIDE_LIMIT,
/// Focus hardware far limit.
FOCUS_HW_FAR_LIMIT,
/// Focus hardware near limit.
FOCUS_HW_NEAR_LIMIT,
/// Iris hardware open limit.
IRIS_HW_OPEN_LIMIT,
/// Iris hardware close limit.
IRIS_HW_CLOSE_LIMIT,
/// Focus factor if it was calculated.
FOCUS_FACTOR,
/// Lens connection status.
IS_CONNECTED,
/// Focus hardware speed in autofocus mode.
FOCUS_HW_AF_SPEED,
/// Threshold for changes of focus factor to start refocus.
FOCUS_FACTOR_THRESHOLD,
/// Timeout for automatic refocus in seconds.
REFOCUS_TIMEOUT_SEC,
/// Flag about active autofocus algorithm.
AF_IS_ACTIVE,
/// Iris mode.
IRIS_MODE,
/// ROI width (pixels).
AUTO_AF_ROI_WIDTH,
/// ROI height (pixels).
AUTO_AF_ROI_HEIGHT,
/// Video frame border size (along vertical and horizontal axes).
AUTO_AF_ROI_BORDER,
/// AF ROI mode (write/read). Value: 0 - Manual position, 1 - Auto position.
AF_ROI_MODE,
/// Lens extender mode.
EXTENDER_MODE,
/// Lens stabilization mode.
STABILIZER_MODE,
/// Autofocus range.
AF_RANGE,
/// Current horizontal Field of view, degree.
X_FOV_DEG,
/// Current vertical Field of view, degree.
Y_FOV_DEG,
/// Logging mode.
LOG_MODE,
/// Lens temperature, degree.
TEMPERATURE,
/// Lens controller initialization status.
IS_OPEN,
/// Lens type.
TYPE,
/// Lens custom parameter.
CUSTOM_1,
/// Lens custom parameter.
CUSTOM_2,
/// Lens custom parameter.
CUSTOM_3
};
}
}
Table 4 - Lens params description.
| Parameter | Access | Description |
|---|---|---|
| ZOOM_POS | read / write | Zoom position. Setting a parameter is equivalent to the command ZOOM_TO_POS. Controller should have zoom range from 0 (full wide) to 65535 (full tele) regardless of the hardware value of the zoom position. User can set zoom movement speed via lens parameters. |
| ZOOM_HW_POS | read / write | Hardware zoom position. Parameter has same value as ZOOM_POS parameter. |
| FOCUS_POS | read / write | Focus position. Setting a parameter is equivalent to the command FOCUS_TO_POS. Lens controller should have focus range from 0 (full near) to 65535 (full far) regardless of the hardware value of the focus position. User can set focus movement speed via lens parameters. |
| FOCUS_HW_POS | read / write | Hardware focus position. Parameter has same value as FOCUS_POS parameter. |
| IRIS_POS | read / write | Not supported by FujiSxCamera library. |
| IRIS_HW_POS | read / write | Not supported by FujiSxCamera library. |
| FOCUS_MODE | read / write | Focus mode. Value : 0 - Manual 1 - Auto 2 - Quick auto focus. |
| FILTER_MODE | read / write | Filter mode. Value: 0 - Visible light (VLC off) 1 - VLC (Visible Light Cut) filter on 2 - 808 nm 3 - 850 nm 4 - 940 nm 5 - 950 nm |
| AF_ROI_X0 | read / write | Not supported by FujiSxCamera library. |
| AF_ROI_Y0 | read / write | Not supported by FujiSxCamera library. |
| AF_ROI_X1 | read / write | Not supported by FujiSxCamera library. |
| AF_ROI_Y1 | read / write | Not supported by FujiSxCamera library. |
| ZOOM_SPEED | read / write | Zoom speed. Controller has zoom speed range from 0 to 100%: <25 - Slowest speed, 25-50 - Low medium speed, 50-75 - High medium speed, 75-100 - Highest speed. |
| ZOOM_HW_SPEED | read / write | Not supported by FujiSxCamera library. |
| ZOOM_HW_MAX_SPEED | read / write | Not supported by FujiSxCamera library. |
| FOCUS_SPEED | read / write | Focus speed. Controller has focus speed range from 0 to 100%: <25 - Slowest speed, 25-50 - Low medium speed, 50-75 - High medium speed, 75-100 - Highest speed. |
| FOCUS_HW_SPEED | read / write | Not supported by FujiSxCamera library. |
| FOCUS_HW_MAX_SPEED | read / write | Not supported by FujiSxCamera library. |
| IRIS_SPEED | read / write | Not supported by FujiSxCamera library. |
| IRIS_HW_SPEED | read / write | Not supported by FujiSxCamera library. |
| IRIS_HW_MAX_SPEED | read / write | Not supported by FujiSxCamera library. |
| ZOOM_HW_TELE_LIMIT | read / write | Not supported by FujiSxCamera library. |
| ZOOM_HW_WIDE_LIMIT | read / write | Not supported by FujiSxCamera library. |
| FOCUS_HW_FAR_LIMIT | read / write | Not supported by FujiSxCamera library. |
| FOCUS_HW_NEAR_LIMIT | read / write | Not supported by FujiSxCamera library. |
| IRIS_HW_OPEN_LIMIT | read / write | Not supported by FujiSxCamera library. |
| IRIS_HW_CLOSE_LIMIT | read / write | Not supported by FujiSxCamera library. |
| FOCUS_FACTOR | read only | Not supported by FujiSxCamera library. |
| IS_CONNECTED | read only | Connection status. Shows whether the controller has data exchange with the equipment. For example, the serial port may be open while the equipment is not active (no power). In this case the connection status shows that the controller doesn’t have data exchange with the equipment (the method will return 0). If the controller has data exchange with the equipment, the method will return 1. If the controller is not initialized, the connection status is always FALSE. Values: 0 - not connected, 1 - connected. |
| FOCUS_HW_AF_SPEED | read / write | Not supported by FujiSxCamera library. |
| FOCUS_FACTOR_THRESHOLD | read / write | Autofocus sensitivity. The base Lens interface meaning of this parameter is the threshold for changes of focus factor to start refocus, but the FujiSxCamera library repurposes it to set the camera autofocus sensitivity. Value: 0 - 100%, mapped to one of three hardware AF sensitivity levels: 0 - 33% - Low 34 - 66% - Middle 67 - 100% - High |
| REFOCUS_TIMEOUT_SEC | read / write | Not supported by FujiSxCamera library. |
| AF_IS_ACTIVE | read only | Not supported by FujiSxCamera library. |
| IRIS_MODE | read / write | Iris mode. Values for SX800 model: 1 - F4 2 - F4.5 3 - F5.0 4 - F5.6 5 - F6.3 6 - F7.1 7 - F8 8 - F9 9 - F10 10 - F12 11 - F13 12 - F14 13 - F16 Values for SX1600 model: 7 - F8 8 - F9 9 - F10 10 - F11 11 - F13 12 - F14 13 - F16 14 - F18 15 - F20 16 - F22 17 - F25 18 - F29 19 - F32 |
| AUTO_AF_ROI_WIDTH | read / write | Not supported by FujiSxCamera library. |
| AUTO_AF_ROI_HEIGHT | read / write | Not supported by FujiSxCamera library. |
| AUTO_AF_ROI_BORDER | read / write | Not supported by FujiSxCamera library. |
| AF_ROI_MODE | read / write | Not supported by FujiSxCamera library. |
| EXTENDER_MODE | read / write | Not supported by FujiSxCamera library. |
| STABILIZER_MODE | read / write | Stabilization mode. Values: 0 - Off, 1 - Auto, 2 - Only optical stabilization ON, 3 - Only electronic stabilization ON. |
| AF_RANGE | read / write | Not supported by FujiSxCamera library. |
| X_FOV_DEG | read / write | Horizontal field of view, in degrees. The library includes tables of zoom position / FOV for SX800 and SX1600 cameras. The library reads the zoom position from the camera hardware and calculates the horizontal field of view. The user can also directly set the field of view. Limitations: X_FOV_DEG must be >= 0; if X_FOV_DEG < minimum horizontal FOV the command will set the minimum camera FOV; if X_FOV_DEG > maximum horizontal FOV the command will set the maximum camera FOV. |
| Y_FOV_DEG | read / write | Vertical field of view, in degrees. The library includes tables of zoom position / FOV for SX800 and SX1600 cameras. The library reads the zoom position from the camera hardware and calculates the vertical field of view. The user can also directly set the field of view. Limitations: Y_FOV_DEG must be >= 0; if Y_FOV_DEG < minimum vertical FOV the command will set the minimum camera FOV; if Y_FOV_DEG > maximum vertical FOV the command will set the maximum camera FOV. |
| LOG_MODE | read / write | Logging mode. Values: 0 - Disable, 1 - Only file, 2 - Only terminal (console), 3 - File and terminal. |
| TEMPERATURE | read only | Not supported by FujiSxCamera library. |
| IS_OPEN | read only | Controller initialization status. Open status shows whether the controller is initialized or not but does not show whether the controller has communication with the equipment. For example, the serial port may be open while the equipment is not active (no power). In this case the open status just shows that the controller has opened the serial port. Values: 0 - not open (not initialized), 1 - open (initialized). |
| TYPE | read / write | Camera type. Values: 800 - SX800 camera (default), 1600 - SX1600 camera. The library includes an algorithm to calculate field of view. To calculate the field of view, the library needs to know the camera type (SX800 or SX1600), which is impossible to detect automatically via the communication protocol. By default the library is configured for the SX800 camera type. If the user sets a value other than 800 or 1600, the library will be configured for the SX800 camera type. |
| CUSTOM_1 | read / write | Set AF area zone. For SX800 the value is sent via the SET_AF_AREA command; for SX1600 the value is mapped to coordinates on the focus-area grid and applied as a 4-step focus area position sequence. Value: 0 - Center (fixed) 1 - Upper left 2 - Upper center 3 - Upper right 4 - Middle left 5 - Middle center 6 - Middle right 7 - Lower left 8 - Lower center 9 - Lower right |
| CUSTOM_2 | read / write | Set backlight compensation. Value: 0 - OFF 1 - soft 2 - hard. |
| CUSTOM_3 | read / write | Not supported by FujiSxCamera library. |
CameraParam enum
Enum declaration:
namespace cr
{
namespace camera
{
enum class CameraParam
{
/// Video frame width. Value from 0 to 16384.
WIDTH = 1,
/// Video frame height Value from 0 to 16384.
HEIGHT,
/// Display menu mode.
DISPLAY_MODE,
/// Video output type.
VIDEO_OUTPUT,
/// Logging mode.
LOG_MODE,
/// Exposure mode.
EXPOSURE_MODE,
/// Exposure time of the camera sensor.
EXPOSURE_TIME,
/// White balance mode.
WHITE_BALANCE_MODE,
/// White balance area.
WHITE_BALANCE_AREA,
/// White dynamic range mode.
WIDE_DYNAMIC_RANGE_MODE,
/// Image stabilization mode.
STABILIZATION_MODE,
/// ISO sensitivity.
ISO_SENSITIVITY,
/// Scene mode.
SCENE_MODE,
/// FPS.
FPS,
/// Brightness mode.
BRIGHTNESS_MODE,
/// Brightness. Value 0 - 100%.
BRIGHTNESS,
/// Contrast. Value 1 - 100%.
CONTRAST,
/// Gain mode.
GAIN_MODE,
/// Gain. Value 1 - 100%.
GAIN,
/// Sharpening mode.
SHARPENING_MODE,
/// Sharpening. Value 1 - 100%.
SHARPENING,
/// Palette.
PALETTE,
/// Analog gain control mode.
AGC_MODE,
/// Shutter mode.
SHUTTER_MODE,
/// Shutter position. 0 (full close) - 65535 (full open).
SHUTTER_POSITION,
/// Shutter speed. Value: 0 - 100%.
SHUTTER_SPEED,
/// Digital zoom mode.
DIGITAL_ZOOM_MODE,
/// Digital zoom. Value 1.0 (x1) - 20.0 (x20).
DIGITAL_ZOOM,
/// Exposure compensation mode.
EXPOSURE_COMPENSATION_MODE,
/// Exposure compensation position.
EXPOSURE_COMPENSATION_POSITION,
/// Defog mode.
DEFOG_MODE,
/// Dehaze mode.
DEHAZE_MODE,
/// Noise reduction mode.
NOISE_REDUCTION_MODE,
/// Black and white filter mode.
BLACK_WHITE_FILTER_MODE,
/// Filter mode.
FILTER_MODE,
/// NUC mode for thermal cameras.
NUC_MODE,
/// Auto NUC interval for thermal cameras.
AUTO_NUC_INTERVAL_MSEC,
/// Image flip mode.
IMAGE_FLIP,
/// DDE mode.
DDE_MODE,
/// DDE level.
DDE_LEVEL,
/// ROI top-left horizontal position, pixels.
ROI_X0,
/// ROI top-left vertical position, pixels.
ROI_Y0,
/// ROI bottom-right horizontal position, pixels.
ROI_X1,
/// ROI bottom-right vertical position, pixels.
ROI_Y1,
/// Camera temperature, degree.
TEMPERATURE,
/// ALC gate.
ALC_GATE,
/// Sensor sensitivity.
SENSETIVITY,
/// Changing mode (day / night).
CHANGING_MODE,
/// Changing level (day / night).
CHANGING_LEVEL,
/// Chroma level. Values: 0 - 100%.
CHROMA_LEVEL,
/// Details, enhancement. Values: 0 - 100%.
DETAIL,
/// Camera settings profile.
PROFILE,
/// Connection status (read only). Shows if we have respond from camera.
/// Value: 0 - not connected, 2 - connected.
IS_CONNECTED,
/// Open status (read only):
/// 1 - camera control port open, 0 - not open.
IS_OPEN,
/// Camera type.
TYPE,
/// Camera custom param.
CUSTOM_1,
/// Camera custom param.
CUSTOM_2,
/// Camera custom param.
CUSTOM_3
};
}
}
Table 5 - Camera params description.
| Parameter | Access | Description |
|---|---|---|
| WIDTH | read / write | Not supported by FujiSxCamera library. |
| HEIGHT | read / write | Not supported by FujiSxCamera library. |
| DISPLAY_MODE | read / write | Display mode (camera menu). Values: 0 - Off, 1 - On. |
| VIDEO_OUTPUT | read / write | Not supported by FujiSxCamera library. |
| LOG_MODE | read / write | Logging mode. Values: 0 - Disable, 1 - Only file, 2 - Only terminal (console), 3 - File and terminal. |
| EXPOSURE_MODE | read / write | Not supported by FujiSxCamera library. |
| EXPOSURE_TIME | read / write | Exposure time of the camera sensor. The exposure time is limited by the frame interval. Camera controller should interpret the values as 100 µs units, where the value 1 stands for 1/10000th of a second, 10000 for 1 second and 100000 for 10 seconds. |
| WHITE_BALANCE_MODE | read / write | White balance mode. Value: 1 or 0 - Auto 2 - Custom1 (Read preset, which can be set only by SDI menu) 3 - Custom2 (Read preset, which can be set only by SDI menu) 4 - Day 5 - Cloud 6 - ColorTemperature(Set the color temperature) 7 - Auto (white priority) others - Auto. |
| WHITE_BALANCE_AREA | read / write | Not supported by FujiSxCamera library. |
| WIDE_DYNAMIC_RANGE_MODE | read / write | Wide dynamic range mode: 0 or 1 - Off, 2 - level 1, 3 - level 2. |
| STABILIZATION_MODE | read / write | Not supported by FujiSxCamera library. |
| ISO_SENSITIVITY | read / write | ISO sensitivity. SHUTTER_MODE should be set to 0 - Manual shutter. Value: 1 - ISO 400 2 - ISO 500 3 - ISO 640 4 - ISO 800 5 - ISO 1000 6 - ISO 1250 7 - ISO 1600 8 - ISO 2000 9 - ISO 2500 10 - ISO 3200 11 - ISO 4000 12 - ISO 5000 13 - ISO 6400 14 - ISO 8000 15 - ISO 10000 16 - ISO 12800 17 - ISO 25600 18 - ISO 51200 19 - ISO 102400 20 - ISO 204800 21 - ISO 409600 22 - ISO 819200 others - ISO 400. |
| SCENE_MODE | read / write | Day/Night mode: 0 - Auto 1 - Manual Day 2 - Manual Night. |
| FPS | read / write | Not supported by FujiSxCamera library. |
| BRIGHTNESS_MODE | read / write | Not supported by FujiSxCamera library. |
| BRIGHTNESS | read / write | Brightness. Value 0 - 100%. |
| CONTRAST | read / write | Contrast. Value 1 - 100%. |
| GAIN_MODE | read / write | Gain mode. Values: 0 - Standard 1 - Off 2 - Hyper others - Standard. |
| GAIN | read / write | Not supported by FujiSxCamera library. |
| SHARPENING_MODE | read / write | Not supported by FujiSxCamera library. |
| SHARPENING | read / write | Sharpening. Value 1 - 100%. |
| PALETTE | read / write | Not supported by FujiSxCamera library. |
| AGC_MODE | read / write | Analog gain control mode. Values: 0 - Standard 1 - Off 2 - Hyper others - Standard. |
| SHUTTER_MODE | read / write | Shutter mode. Values: 0 - Manual shutter 1 - Auto shutter, Lowest limit 1/8 sec 2 - Auto shutter,Lowest limit 1/15 sec 3 - Auto shutter, Lowest limit 1/30 sec 4 - Auto shutter, Lowest limit 1/60 sec 5 - Auto shutter, Lowest limit 1/125 sec others - Auto shutter, Lowest limit 1/8 sec. |
| SHUTTER_POSITION | read / write | Not supported by FujiSxCamera library. |
| SHUTTER_SPEED | read / write | Shutter speed. SHUTTER_MODE should be set to 0 - Manual shutter. Values: 1 - 1 2 - 1/1.3 3 - 1/1.6 4 - 1/2 5 - 1/2.5 6 - 1/3 7 - 1/4 8 - 1/5 9 - 1/6 10 - 1/8 11 - 1/10 12 - 1/13 13 - 1/15 14 - 1/20 15 - 1/25 16 - 1/30 17 - 1/40 18 - 1/50 19 - 1/60 20 - 1/80 21 - 1/100 22 - 1/120 23 - 1/125 24 - 1/160 25 - 1/200 26 - 1/250 27 - 1/320 28 - 1/400 29 - 1/500 30 - 1/640 31 - 1/800 32 - 1/1000 33 - 1/1250 34 - 1/1600 35 - 1/2000 36 - 1/2500 37 - 1/3200 38 - 1/4000 39 - 1/5000 40 - 1/6400 41 - 1/8000 42 - 1/10000 43 - 1/12800 44 - 1/16000 45 - 1/20000 46 - 1/32000 others - 1/30. |
| DIGITAL_ZOOM_MODE | read / write | Digital zoom mode. Values: 0 - Off 1 - On |
| DIGITAL_ZOOM | read / write | Digital zoom level. Values: 0 - 1.25x 1 - 1.5x 2 - 1.75x 3 - 2.0x |
| EXPOSURE_COMPENSATION_MODE | read only | Not supported by FujiSxCamera library. |
| EXPOSURE_COMPENSATION_POSITION | read / write | Not supported by FujiSxCamera library. |
| DEFOG_MODE | read / write | Defog mode. Values: 0 - Off 1 - level 1 2 - level 2 3 - level 3 others - Off. |
| DEHAZE_MODE | Dehaze mode (heat/haze reduction). Values: 0 - Off 1 - level 1 2 - level 2 3 - level 3 others - Off. | |
| NOISE_REDUCTION_MODE | read / write | Noise reduction mode. Values: 1 - Weak 2 - Middle 3 - Strong 0 - Middle. |
| BLACK_WHITE_FILTER_MODE | read only | Not supported by FujiSxCamera library. |
| FILTER_MODE | read / write | Filter mode. Values: 0 - Visible light (VLC off) 1 - VLC (Visible Light Cut) filter on 2 - 808 nm 3 - 850 nm 4 - 940 nm 5 - 950 nm others - invalid. |
| NUC_MODE | read / write | Not supported by FujiSxCamera library. |
| AUTO_NUC_INTERVAL | read / write | Not supported by FujiSxCamera library. |
| IMAGE_FLIP | read / write | Not supported by FujiSxCamera library. |
| DDE_MODE | read / write | Not supported by FujiSxCamera library. |
| DDE_LEVEL | read / write | Not supported by FujiSxCamera library. |
| ROI_X0 | read / write | Not supported by FujiSxCamera library. |
| ROI_Y0 | read / write | Not supported by FujiSxCamera library. |
| ROI_X1 | read / write | Not supported by FujiSxCamera library. |
| ROI_Y1 | read / write | Not supported by FujiSxCamera library. |
| TEMPERATURE | read only | Not supported by FujiSxCamera library. |
| ALC_GATE | read / write | Not supported by FujiSxCamera library. |
| SENSITIVITY | read / write | Not supported by FujiSxCamera library. |
| CHANGING_MODE | read / write | Not supported by FujiSxCamera library. |
| CHANGING_LEVEL | read / write | Day to night changing threshold in auto mode (SCENE_MODE == 0). Values: 0-255. |
| CHROMA_LEVEL | read / write | Not supported by FujiSxCamera library. |
| DETAIL | read / write | Not supported by FujiSxCamera library. |
| PROFILE | read / write | Presets for camera settings. Values: 0 - Day 1 - Night 2 - Auto 3 - Defog 4 - Max sensitivity. |
| IS_CONNECTED | read only | Connection status. Shows whether the controller has data exchange with the equipment. For example, the serial port may be open while the equipment is not active (no power). In this case the connection status shows that the controller doesn’t have data exchange with the equipment (the method will return 0). If the controller has data exchange with the equipment, the method will return 1. If the controller is not initialized, the connection status is always FALSE. Values: 0 - not connected, 1 - connected. |
| IS_OPEN | read only | Controller initialization status. Open status shows whether the controller is initialized or not but does not show whether the controller has communication with the equipment. For example, the serial port may be open while the equipment is not active (no power). In this case the open status just shows that the controller has opened the serial port. Values: 0 - not open (not initialized), 1 - open (initialized). |
| TYPE | read / write | Not supported by FujiSxCamera library. |
| CUSTOM_1 | read / write | Night to day changing threshold in auto mode (SCENE_MODE == 0). Values: 0-255. |
| CUSTOM_2 | read / write | Color temperature on white balance. WHITE_BALANCE_MODE should be set to 6 - ColorTemperature(Set the color temperature). Value: 1 - 3000K 2 - 5000K 3 - 9000K. |
| CUSTOM_3 | read / write | Set antialiasing. Value: 0 - off 1 - on. |
LensParams class description
The LensParams class is used for lens initialization or to get all current params. LensParams also provides a structure to write/read params from JSON files (JSON_READABLE macro) and methods to encode and decode params.
LensParams class declaration
The LensParams interface class is declared in the Lens.h file. Class declaration:
namespace cr
{
namespace lens
{
class LensParams
{
public:
/// Initialization string.
std::string initString{"/dev/ttyUSB0;9600;7"};
/// Zoom position.
int zoomPos{0};
/// Hardware zoom position.
int zoomHwPos{0};
/// Focus position.
int focusPos{0};
/// Hardware focus position.
int focusHwPos{0};
/// Iris position.
int irisPos{0};
/// Hardware iris position.
int irisHwPos{0};
/// Focus mode.
int focusMode{0};
/// Filter mode.
int filterMode{0};
/// Autofocus ROI top-left corner horizontal position in pixels.
int afRoiX0{0};
/// Autofocus ROI top-left corner vertical position in pixels.
int afRoiY0{0};
/// Autofocus ROI bottom-right corner horizontal position in pixels.
int afRoiX1{0};
/// Autofocus ROI bottom-right corner vertical position in pixels.
int afRoiY1{0};
/// Zoom speed.
int zoomSpeed{50};
/// Zoom hardware speed.
int zoomHwSpeed{50};
/// Maximum zoom hardware speed.
int zoomHwMaxSpeed{50};
/// Focus speed.
int focusSpeed{50};
/// Focus hardware speed.
int focusHwSpeed{50};
/// Maximum focus hardware speed.
int focusHwMaxSpeed{50};
/// Iris speed.
int irisSpeed{50};
/// Iris hardware speed.
int irisHwSpeed{50};
/// Maximum iris hardware speed.
int irisHwMaxSpeed{50};
/// Zoom hardware tele limit.
int zoomHwTeleLimit{65535};
/// Zoom hardware wide limit.
int zoomHwWideLimit{0};
/// Focus hardware far limit.
int focusHwFarLimit{65535};
/// Focus hardware near limit.
int focusHwNearLimit{0};
/// Iris hardware open limit.
int irisHwOpenLimit{65535};
/// Iris hardware close limit.
int irisHwCloseLimit{0};
/// Focus factor if it was calculated.
float focusFactor{0.0f};
/// Lens connection status.
bool isConnected{false};
/// Focus hardware speed in autofocus mode.
int afHwSpeed{50};
/// Timeout for automatic refocus in seconds.
float focusFactorThreshold{0.0f};
/// Timeout for automatic refocus in seconds.
int refocusTimeoutSec{0};
/// Flag about active autofocus algorithm.
bool afIsActive{false};
/// Iris mode.
int irisMode{0};
/// ROI width (pixels) for autofocus algorithm.
int autoAfRoiWidth{150};
/// ROI height (pixels) for autofocus algorithm.
int autoAfRoiHeight{150};
/// Video frame border size (along vertical and horizontal axes).
int autoAfRoiBorder{100};
/// AF ROI mode (write/read).
int afRoiMode{0};
/// Lens extender mode.
int extenderMode{0};
/// Lens stabilization mode.
int stabiliserMode{0};
/// Autofocus range.
int afRange{0};
/// Current horizontal Field of view, degree.
float xFovDeg{1.0f};
/// Current vertical Field of view, degree.
float yFovDeg{1.0f};
/// Logging mode.
int logMode{0};
/// Lens temperature, degree (read only).
float temperature{0.0f};
/// Lens controller initialization status.
bool isOpen{false};
/// Lens type. Value depends on implementation.
int type{0};
/// Lens custom parameter.
float custom1{0.0f};
/// Lens custom parameter.
float custom2{0.0f};
/// Lens custom parameter.
float custom3{0.0f};
/// List of points to calculate fiend of view.
std::vector<FovPoint> fovPoints{std::vector<FovPoint>()};
JSON_READABLE(LensParams, initString, focusMode, filterMode,
afRoiX0, afRoiY0, afRoiX1, afRoiY1, zoomHwMaxSpeed,
focusHwMaxSpeed, irisHwMaxSpeed, zoomHwTeleLimit,
zoomHwWideLimit, focusHwFarLimit, focusHwNearLimit,
irisHwOpenLimit, irisHwCloseLimit, afHwSpeed,
focusFactorThreshold, refocusTimeoutSec, irisMode,
autoAfRoiWidth, autoAfRoiHeight, autoAfRoiBorder,
afRoiMode, extenderMode, stabiliserMode, afRange,
logMode, type, custom1, custom2, custom3, fovPoints);
/// operator =
LensParams& operator= (const LensParams& src);
/// Encode params.
bool encode(uint8_t* data, int bufferSize, int& size,
LensParamsMask* mask = nullptr);
/// Decode params.
bool decode(uint8_t* data, int dataSize);
};
}
}
The LensParams class fields description is equivalent to the LensParam enum description, except for initString. initString can take 3 different forms:
- [serial port name];[baudrate];[lens address]
- [serial port name];[baudrate]
- [serial port name]
When the lens address is not given, it is set to 7 by default; the same applies to baudrate, which defaults to 9600. Note: the fovPoints list is not used and is always empty. The library automatically calculates the FOV for each zoom position.
Serialize lens params
The LensParams class provides the encode(…) method to serialize lens params. Serialization is required when you need to send lens params via a communication channel. The method does not encode the initString field or fovPoints. The method also provides an option to exclude particular parameters from serialization: to do so it inserts a binary mask (7 bytes) where each bit represents a particular parameter, and the decode(…) method recognizes it. Method declaration:
bool encode(uint8_t* data, int bufferSize, int& size, LensParamsMask* mask = nullptr);
| Parameter | Value |
|---|---|
| data | Pointer to data buffer. |
| size | Size of encoded data. |
| bufferSize | Data buffer size. Buffer size must be >= 201 bytes. |
| mask | Parameters mask - pointer to LensParamsMask structure. LensParamsMask (declared in Lens.h file) determines flags for each field (parameter) declared in LensParams class. If the user wants to exclude any parameters from serialization, he can put a pointer to the mask. If the user wants to exclude a particular parameter from serialization, he should set the corresponding flag in the LensParamsMask structure. |
LensParamsMask structure declaration:
typedef struct LensParamsMask
{
bool zoomPos{true};
bool zoomHwPos{true};
bool focusPos{true};
bool focusHwPos{true};
bool irisPos{true};
bool irisHwPos{true};
bool focusMode{true};
bool filterMode{true};
bool afRoiX0{true};
bool afRoiY0{true};
bool afRoiX1{true};
bool afRoiY1{true};
bool zoomSpeed{true};
bool zoomHwSpeed{true};
bool zoomHwMaxSpeed{true};
bool focusSpeed{true};
bool focusHwSpeed{true};
bool focusHwMaxSpeed{true};
bool irisSpeed{true};
bool irisHwSpeed{true};
bool irisHwMaxSpeed{true};
bool zoomHwTeleLimit{true};
bool zoomHwWideLimit{true};
bool focusHwFarLimit{true};
bool focusHwNearLimit{true};
bool irisHwOpenLimit{true};
bool irisHwCloseLimit{true};
bool focusFactor{true};
bool isConnected{true};
bool afHwSpeed{true};
bool focusFactorThreshold{true};
bool refocusTimeoutSec{true};
bool afIsActive{true};
bool irisMode{true};
bool autoAfRoiWidth{true};
bool autoAfRoiHeight{true};
bool autoAfRoiBorder{true};
bool afRoiMode{true};
bool extenderMode{true};
bool stabiliserMode{true};
bool afRange{true};
bool xFovDeg{true};
bool yFovDeg{true};
bool logMode{true};
bool temperature{true};
bool isOpen{false};
bool type{true};
bool custom1{true};
bool custom2{true};
bool custom3{true};
} LensParamsMask;
Example without parameters mask:
// Encode data.
LensParams in;
in.logMode = 3;
uint8_t data[1024];
int size = 0;
in.encode(data, 1024, size);
cout << "Encoded data size: " << size << " bytes" << endl;
Example with parameters mask:
// Prepare params.
LensParams in;
in.logMode = 3;
// Prepare mask.
LensParamsMask mask;
mask.logMode = false; // Exclude logMode. Others by default.
// Encode.
uint8_t data[1024];
int size = 0;
in.encode(data, 1024, size, &mask);
cout << "Encoded data size: " << size << " bytes" << endl;
Deserialize lens params
The LensParams class provides the decode(…) method to deserialize lens params. Deserialization is required when you need to receive lens params via a communication channel. The method automatically recognizes which parameters were serialized by the encode(…) method. The method does not decode the initString field or fovPoints. Method declaration:
bool decode(uint8_t* data, int dataSize);
| Parameter | Value |
|---|---|
| data | Pointer to data buffer. |
| dataSize | Size of data. |
Returns: TRUE if data decoded (deserialized) or FALSE if not.
Example:
// Encode data.
LensParams in;
uint8_t data[1024];
int size = 0;
in.encode(data, 1024, size);
cout << "Encoded data size: " << size << " bytes" << endl;
// Decode data.
LensParams out;
if (!out.decode(data, size))
cout << "Can't decode data" << endl;
Read and write lens params to JSON file
Lens interface class library depends on ConfigReader library which provides methods to read params from a JSON file and to write params to a JSON file. Example of writing and reading params to a JSON file:
// Prepare random params.
LensParams in;
for (int i = 0; i < 5; ++i)
{
FovPoint pt;
pt.hwZoomPos = rand() % 255;
pt.xFovDeg = rand() % 255;
pt.yFovDeg = rand() % 255;
in.fovPoints.push_back(pt);
}
// Write params to file.
cr::utils::ConfigReader inConfig;
inConfig.set(in, "lensParams");
inConfig.writeToFile("TestLensParams.json");
// Read params from file.
cr::utils::ConfigReader outConfig;
if(!outConfig.readFromFile("TestLensParams.json"))
{
cout << "Can't open config file" << endl;
return false;
}
TestLensParams.json will look like:
{
"lensParams": {
"afHwSpeed": 93,
"afRange": 128,
"afRoiMode": 239,
"afRoiX0": 196,
"afRoiX1": 252,
"afRoiY0": 115,
"afRoiY1": 101,
"autoAfRoiBorder": 70,
"autoAfRoiHeight": 125,
"autoAfRoiWidth": 147,
"custom1": 91.0,
"custom2": 236.0,
"custom3": 194.0,
"extenderMode": 84,
"filterMode": 49,
"focusFactorThreshold": 98.0,
"focusHwFarLimit": 228,
"focusHwMaxSpeed": 183,
"focusHwNearLimit": 47,
"focusMode": 111,
"fovPoints": [
{
"hwZoomPos": 55,
"xFovDeg": 6.0,
"yFovDeg": 51.0
},
{
"hwZoomPos": 63,
"xFovDeg": 249.0,
"yFovDeg": 33.0
},
{
"hwZoomPos": 4,
"xFovDeg": 121.0,
"yFovDeg": 144.0
},
{
"hwZoomPos": 53,
"xFovDeg": 214.0,
"yFovDeg": 153.0
},
{
"hwZoomPos": 143,
"xFovDeg": 15.0,
"yFovDeg": 218.0
}
],
"initString": "dfhglsjirhuhjfb",
"irisHwCloseLimit": 221,
"irisHwMaxSpeed": 79,
"irisHwOpenLimit": 211,
"irisMode": 206,
"logMode": 216,
"refocusTimeoutSec": 135,
"stabiliserMode": 137,
"type": 125,
"zoomHwMaxSpeed": 157,
"zoomHwTeleLimit": 68,
"zoomHwWideLimit": 251
}
}
CameraParams class description
The CameraParams class is used for camera controller initialization or to get all current params. CameraParams also provides a structure to write/read params from JSON files (JSON_READABLE macro) and methods to encode and decode params.
CameraParams Class declaration
The CameraParams interface class is declared in the Camera.h file. Class declaration:
namespace cr
{
namespace camera
{
class CameraParams
{
public:
/// Initialization string.
std::string initString{"/dev/ttyUSB0;9600;7"};
/// Video frame width. Value from 0 to 16384.
int width{0};
/// Video frame height Value from 0 to 16384.
int height{0};
/// Display menu mode.
int displayMode{0};
/// Video output type.
int videoOutput{0};
/// Logging mode.
int logMode{0};
/// Exposure mode.
int exposureMode{1};
/// Exposure time of the camera sensor.
int exposureTime{0};
/// White balance mode.
int whiteBalanceMode{1};
/// White balance area.
int whiteBalanceArea{0};
/// White dynamic range mode.
int wideDynamicRangeMode{0};
/// Image stabilization mode.
int stabilisationMode{0};
/// ISO sensitivity.
int isoSensetivity{0};
/// Scene mode.
int sceneMode{0};
/// FPS.
float fps{0.0f};
/// Brightness mode.
int brightnessMode{1};
/// Brightness. Value 0 - 100%.
int brightness{0};
/// Contrast. Value 1 - 100%.
int contrast{0};
/// Gain mode.
int gainMode{1};
/// Gain. Value 1 - 100%.
int gain{0};
/// Sharpening mode.
int sharpeningMode{0};
/// Sharpening. Value 1 - 100%.
int sharpening{0};
/// Palette.
int palette{0};
/// Analog gain control mode.
int agcMode{1};
/// Shutter mode.
int shutterMode{1};
/// Shutter position. 0 (full close) - 65535 (full open).
int shutterPos{0};
/// Shutter speed. Value: 0 - 100%.
int shutterSpeed{0};
/// Digital zoom mode.
int digitalZoomMode{0};
/// Digital zoom. Value 1.0 (x1) - 20.0 (x20).
float digitalZoom{1.0f};
/// Exposure compensation mode.
int exposureCompensationMode{0};
/// Exposure compensation position.
int exposureCompensationPosition{0};
/// Defog mode.
int defogMode{0};
/// Dehaze mode.
int dehazeMode{0};
/// Noise reduction mode.
int noiseReductionMode{0};
/// Black and white filter mode.
int blackAndWhiteFilterMode{0};
/// Filter mode.
int filterMode{0};
/// NUC mode for thermal cameras.
int nucMode{0};
/// Auto NUC interval for thermal cameras.
int autoNucIntervalMsec{0};
/// Image flip mode.
int imageFlip{0};
/// DDE mode.
int ddeMode{0};
/// DDE level.
float ddeLevel{0};
/// ROI top-left horizontal position, pixels.
int roiX0{0};
/// ROI top-left vertical position, pixels.
int roiY0{0};
/// ROI bottom-right horizontal position, pixels.
int roiX1{0};
/// ROI bottom-right vertical position, pixels.
int roiY1{0};
/// Camera temperature, degree.
float temperature{0.0f};
/// ALC gate.
int alcGate{0};
/// Sensor sensitivity.
float sensitivity{0};
/// Changing mode (day / night).
int changingMode{0};
/// Changing level (day / night).
float changingLevel{0.0f};
/// Chroma level. Values: 0 - 100%.
int chromaLevel{0};
/// Details, enhancement. Values: 0 - 100%.
int detail{0};
/// Camera settings profile.
int profile{0};
/// Connection status (read only).
bool isConnected{false};
/// Open status (read only).
bool isOpen{false};
/// Camera type.
int type{0};
/// Camera custom param.
float custom1{0.0f};
/// Camera custom param.
float custom2{0.0f};
/// Camera custom param.
float custom3{0.0f};
JSON_READABLE(CameraParams, initString, width, height, displayMode,
videoOutput, logMode, exposureMode, exposureTime,
whiteBalanceMode, whiteBalanceArea, wideDynamicRangeMode,
stabilisationMode, isoSensetivity, sceneMode, fps,
brightnessMode, brightness, contrast, gainMode, gain,
sharpeningMode, sharpening, palette, agcMode, shutterMode,
shutterPos, shutterSpeed, digitalZoomMode, digitalZoom,
exposureCompensationMode, exposureCompensationPosition,
defogMode, dehazeMode, noiseReductionMode,
blackAndWhiteFilterMode, filterMode, nucMode,
autoNucIntervalMsec, imageFlip, ddeMode, ddeLevel,
roiX0, roiY0, roiX1, roiY1, alcGate, sensitivity,
changingMode, changingLevel, chromaLevel, detail,
profile, type, custom1, custom2, custom3)
/// operator =
CameraParams& operator= (const CameraParams& src);
/// Encode params. The method doesn't encode initString.
bool encode(uint8_t* data, int bufferSize, int& size,
CameraParamsMask* mask = nullptr);
/// Decode params. The method doesn't decode initString.
bool decode(uint8_t* data, int dataSize);
};
}
}
The CameraParams class fields description is equivalent to the CameraParam enum description, except for initString. initString can take 3 different forms:
- [serial port name];[baudrate];[camera address]
- [serial port name];[baudrate]
- [serial port name]
When the camera address is not given, it is set to 7 by default; the same applies to baudrate, which defaults to 9600.
Serialize camera params
The CameraParams class provides the encode(…) method to serialize camera params. Serialization is required when you need to send camera params via a communication channel. The method does not encode the initString field. The method also provides an option to exclude particular parameters from serialization: to do so it inserts a binary mask (8 bytes) where each bit represents a particular parameter, and the decode(…) method recognizes it. Method declaration:
bool encode(uint8_t* data, int bufferSize, int& size, CameraParamsMask* mask = nullptr);
| Parameter | Value |
|---|---|
| data | Pointer to data buffer. Buffer size must be >= 237 bytes. |
| bufferSize | Data buffer size. Buffer size must be >= 237 bytes. |
| size | Size of encoded data. |
| mask | Parameters mask - pointer to CameraParamsMask structure. CameraParamsMask (declared in Camera.h file) determines flags for each field (parameter) declared in CameraParams class. If the user wants to exclude any parameters from serialization, he can put a pointer to the mask. If the user wants to exclude a particular parameter from serialization, he should set the corresponding flag in the CameraParamsMask structure. |
Returns: TRUE if params encoded (serialized) or FALSE if not.
CameraParamsMask structure declaration:
typedef struct CameraParamsMask
{
bool width{true};
bool height{true};
bool displayMode{true};
bool videoOutput{true};
bool logMode{true};
bool exposureMode{true};
bool exposureTime{true};
bool whiteBalanceMode{true};
bool whiteBalanceArea{true};
bool wideDynamicRangeMode{true};
bool stabilisationMode{true};
bool isoSensetivity{true};
bool sceneMode{true};
bool fps{true};
bool brightnessMode{true};
bool brightness{true};
bool contrast{true};
bool gainMode{true};
bool gain{true};
bool sharpeningMode{true};
bool sharpening{true};
bool palette{true};
bool agcMode{true};
bool shutterMode{true};
bool shutterPos{true};
bool shutterSpeed{true};
bool digitalZoomMode{true};
bool digitalZoom{true};
bool exposureCompensationMode{true};
bool exposureCompensationPosition{true};
bool defogMode{true};
bool dehazeMode{true};
bool noiseReductionMode{true};
bool blackAndWhiteFilterMode{true};
bool filterMode{true};
bool nucMode{true};
bool autoNucIntervalMsec{true};
bool imageFlip{true};
bool ddeMode{true};
bool ddeLevel{true};
bool roiX0{true};
bool roiY0{true};
bool roiX1{true};
bool roiY1{true};
bool temperature{true};
bool alcGate{true};
bool sensitivity{true};
bool changingMode{true};
bool changingLevel{true};
bool chromaLevel{true};
bool detail{true};
bool profile{true};
bool isConnected{true};
bool isOpen{true};
bool type{true};
bool custom1{true};
bool custom2{true};
bool custom3{true};
} CameraParamsMask;
Example without parameters mask:
// Encode data.
CameraParams in;
in.profile = 10;
uint8_t data[1024];
int size = 0;
in.encode(data, 1024, size);
cout << "Encoded data size: " << size << " bytes" << endl;
Example with parameters mask:
// Prepare params.
CameraParams in;
in.profile = 3;
// Prepare mask.
CameraParamsMask mask;
mask.profile = false; // Exclude profile. Others by default.
// Encode.
uint8_t data[1024];
int size = 0;
in.encode(data, 1024, size, &mask);
cout << "Encoded data size: " << size << " bytes" << endl;
Deserialize camera params
The CameraParams class provides the decode(…) method to deserialize camera params (fields of the CameraParams class, see Table 5). Deserialization is required when you need to receive params via a communication channel. The method automatically recognizes which parameters were serialized by the encode(…) method. The method does not decode the initString field. Method declaration:
bool decode(uint8_t* data, int dataSize);
| Parameter | Value |
|---|---|
| data | Pointer to data buffer with serialized camera params. |
| dataSize | Size of command data. |
Returns: TRUE if params decoded (deserialized) or FALSE if not.
Example:
// Encode data.
CameraParams in;
uint8_t data[1024];
int size = 0;
in.encode(data, 1024, size);
cout << "Encoded data size: " << size << " bytes" << endl;
// Decode data.
CameraParams out;
if (!out.decode(data, size))
cout << "Can't decode data" << endl;
Read and write camera params to JSON file
Camera library depends on ConfigReader library which provides methods to read params from a JSON file and to write params to a JSON file. Example of writing and reading params to a JSON file:
// Write params to file.
cr::utils::ConfigReader inConfig;
inConfig.set(in, "cameraParams");
inConfig.writeToFile("TestCameraParams.json");
// Read params from file.
cr::utils::ConfigReader outConfig;
if(!outConfig.readFromFile("TestCameraParams.json"))
{
cout << "Can't open config file" << endl;
return false;
}
TestCameraParams.json will look like:
{
"cameraParams": {
"agcMode": 252,
"alcGate": 125,
"autoNucIntervalMsec": 47,
"blackAndWhiteFilterMode": 68,
"brightness": 67,
"brightnessMode": 206,
"changingLevel": 84.0,
"changingMode": 239,
"chromeLevel": 137,
"contrast": 65,
"custom1": 216.0,
"custom2": 32.0,
"custom3": 125.0,
"ddeLevel": 25,
"ddeMode": 221,
"defogMode": 155,
"dehazeMode": 239,
"detail": 128,
"digitalZoom": 47.0,
"digitalZoomMode": 157,
"displayMode": 2,
"exposureCompensationMode": 213,
"exposureCompensationPosition": 183,
"exposureMode": 192,
"exposureTime": 16,
"filterMode": 251,
"fps": 19.0,
"gain": 111,
"gainMode": 130,
"height": 219,
"imageFlip": 211,
"initString": "dfhglsjirhuhjfb",
"isoSensetivity": 32,
"logMode": 252,
"noiseReductionMode": 79,
"nucMode": 228,
"palette": 115,
"profile": 108,
"roiX0": 93,
"roiX1": 135,
"roiY0": 98,
"roiY1": 206,
"sceneMode": 195,
"sensitivity": 70.0,
"sharpening": 196,
"sharpeningMode": 49,
"shutterMode": 101,
"shutterPos": 157,
"shutterSpeed": 117,
"stabilisationMode": 170,
"type": 55,
"videoOutput": 18,
"whiteBalanceArea": 236,
"whiteBalanceMode": 30,
"wideDynamicRangeMode": 21,
"width": 150
}
}
Build and connect to your project
Typical commands to build FujiSxCamera library:
cd FujiSxCamera
mkdir build
cd build
cmake ..
make
If you want to connect the FujiSxCamera library to your CMake project as source code, you can do the following. For example, if your repository has the structure:
CMakeLists.txt
src
CMakeList.txt
yourLib.h
yourLib.cpp
Create a 3rdparty folder in your repository folder and copy the FujiSxCamera repository folder there. The new structure of your repository:
CMakeLists.txt
src
CMakeList.txt
yourLib.h
yourLib.cpp
3rdparty
FujiSxCamera
Create a CMakeLists.txt file in the 3rdparty folder. The CMakeLists.txt should contain:
cmake_minimum_required(VERSION 3.13)
################################################################################
## 3RD-PARTY
## dependencies for the project
################################################################################
project(3rdparty LANGUAGES CXX)
################################################################################
## SETTINGS
## basic 3rd-party settings before use
################################################################################
# To inherit the top-level architecture when the project is used as a submodule.
SET(PARENT ${PARENT}_YOUR_PROJECT_3RDPARTY)
# Disable self-overwriting of parameters inside included subdirectories.
SET(${PARENT}_SUBMODULE_CACHE_OVERWRITE OFF CACHE BOOL "" FORCE)
################################################################################
## CONFIGURATION
## 3rd-party submodules configuration
################################################################################
SET(${PARENT}_SUBMODULE_FUJI_SX_CAMERA ON CACHE BOOL "" FORCE)
if (${PARENT}_SUBMODULE_FUJI_SX_CAMERA)
SET(${PARENT}_FUJI_SX_CAMERA ON CACHE BOOL "" FORCE)
SET(${PARENT}_FUJI_SX_CAMERA_TEST OFF CACHE BOOL "" FORCE)
SET(${PARENT}_FUJI_SX_CAMERA_EXAMPLE OFF CACHE BOOL "" FORCE)
endif()
################################################################################
## INCLUDING SUBDIRECTORIES
## Adding subdirectories according to the 3rd-party configuration
################################################################################
if (${PARENT}_SUBMODULE_LENS)
add_subdirectory(FujiSxCamera)
endif()
The 3rdparty/CMakeLists.txt file adds the FujiSxCamera folder to your project and excludes the test application and example from compiling (by default, the test application and example are excluded from compiling if FujiSxCamera is included as a sub-repository). The new structure of your repository:
CMakeLists.txt
src
CMakeList.txt
yourLib.h
yourLib.cpp
3rdparty
CMakeLists.txt
FujiSxCamera
Next, you need to include the 3rdparty folder in the main CMakeLists.txt file of your repository. Add the following line at the end of your main CMakeLists.txt:
add_subdirectory(3rdparty)
Next, you have to include the FujiSxCamera library in your src/CMakeLists.txt file:
target_link_libraries(${PROJECT_NAME} FujiSxCamera)
Done!
Simple example
The simple example is an application that initializes the controller and provides the user with a few options to control the camera.
#include <iostream>
#include "FujiSxCamera.h"
int main(void)
{
// Init camera controller.
cr::fuji::FujiSxCamera controller;
if (!controller.openCamera("/dev/ttyUSB0;9600;1"))
return -1;
while (true)
{
// Main dialog.
int option = -1;
std::cout << "Options (1:Zoom tele, 2:Zoom wide, 3:Zoom stop, "
<< "4:Brightness+1, 5:Brightness-1) : ";
std::cin >> option;
// Get all camera params.
cr::camera::CameraParams cameraParams;
controller.getParams(cameraParams);
// Get all lens params.
cr::lens::LensParams lensParams;
controller.getParams(lensParams);
switch (option)
{
case 1: // Zoom tele.
controller.executeCommand(cr::lens::LensCommand::ZOOM_TELE);
break;
case 2: // Zoom wide.
controller.executeCommand(cr::lens::LensCommand::ZOOM_WIDE);
break;
case 3: // Zoom stop.
controller.executeCommand(cr::lens::LensCommand::ZOOM_STOP);
break;
case 4:
controller.setParam(cr::camera::CameraParam::BRIGHTNESS,
(cameraParams.brightness + 1.0f));
break;
case 5:
controller.setParam(cr::camera::CameraParam::BRIGHTNESS,
(cameraParams.brightness - 1.0f));
break;
default:
break;
}
}
return 1;
}
Test application
The FujiSxCamera/test folder contains the test application files. The test application allows the user to set params, get params and execute commands. The user must enter the serial port name (full name for Linux or just the port number for Windows), baudrate and camera address.
The test application output will look like:
========================================
FujiSxCamera v2.4.1 test.
========================================
Enter serial port name: /dev/ttyUSB0
Enter baudrate: 9600
Enter camera address: 7
Choose option:
1 - Set lens param
2 - Get lens param
3 - Set camera param
4 - Get camera param
5 - Execute lens command
6 - Execute camera command
-1 - Exit
1
Lens params:
44 - LOG_MODE
1 - ZOOM_POS
3 - FOCUS_POS
8 - FILTER_MODE
13 - ZOOM_SPEED
16 - FOCUS_SPEED
34 - IRIS_MODE
41 - AF_RANGE
7 - FOCUS_MODE
Choose param to set (-1 to exit to main menu): 1
Set zoom position (0 - 65535):
Speed test application
The FujiSxCamera/speedTester folder contains the speed test application files. The test application allows the user to measure the camera reaction speed to the stop command. The user must enter the serial port name (full name for Linux or just the port number for Windows), baudrate and camera address.
The test application output will look like:
========================================
FujiSxCamera v2.4.1 speed test.
========================================
Enter serial port name: /dev/ttyUSB0
Enter baudrate: 9600
Enter camera address: 7
Use focus commands? If not, the app will use zoom commands. (y/n): y
Waiting for lens connection...
Start test, safe time window: 200 ms
Focus position: 0
Focus position: 65535
Focus position: 65535
Focus position: 65535
Focus position: 65107
Focus position: 64074
...
Focus position: 39039
Focus position: 37996
Focus position: 37683
Focus position: 37046
Focus position: 36316
Time difference between command stop and actual stop: 138 ms