External Camera Drivers
Cameras that aren't already supported by the Sensor Framework for QNX SDP can be supported by an external camera driver library.
You must write hooks and create a library to support your external camera driver. To use this library, you must:
-
Provide your library with implementations for the following functions (mandatory):
- open_external_camera_func_t()
- close_external_camera_func_t()
- init_camera_func_t()
- deinit_camera_func_t()
- start_preview_func_t()
- stop_preview_func_t()
- get_preview_frame_func_t()
- get_preview_num_buffers_func_t()
- get_supported_vf_frametypes_func_t()
- get_supported_vf_resolutions_func_t()
- get_supported_vf_framerates_func_t()
Optionally, you can provide implementations for these functions:For more information about the specifics to implement, see external_camera_api.h in the
Camera Library Reference
chapter. -
Create an instance called
external_camera_defsand assign your camera driver functions using the camera_external_camera_t structure. For optional functions you didn't implement, you can assign NULL.typedef struct { open_external_camera_func_t open; close_external_camera_func_t close; init_camera_func_t init; deinit_camera_func_t deinit; start_preview_func_t start_preview; stop_preview_func_t stop_preview; get_preview_frame_func_t get_preview_frame; get_preview_num_buffers_func_t get_preview_num_buffers; get_supported_vf_frametypes_func_t get_supported_vf_frametype; get_supported_vf_resolutions_func_t get_supported_vf_resolution; get_supported_vf_framerates_func_t get_supported_vf_framerates; get_time_func_t get_time; set_framerate_func_t set_framerate; get_framerate_func_t get_framerate; parse_config_func_t parse_config; register_status_callback_func_t register_status_callback; restart_preview_func_t restart_preview; set_isp_config_func_t set_isp_config; get_supported_brightness_func_t get_supported_brightness; set_brightness_func_t set_brightness; get_supported_contrast_func_t get_supported_contrast; set_contrast_func_t set_contrast; set_standby_mode_func_t set_standby_mode; is_whitebalance_mode_valid_func_t is_whitebalance_mode_valid; set_whitebalance_mode_func_t set_whitebalance_mode; get_supported_whitebalance_func_t get_supported_whitebalance; set_whitebalance_func_t set_whitebalance; get_whitebalance_func_t get_whitebalance; is_feature_capable_func_t is_feature_capable; allocate_preview_buffer_func_t allocate_preview_buffer; free_preview_buffer_func_t free_preview_buffer; get_supported_sharpness_func_t get_supported_sharpness; set_sharpness_func_t set_sharpness; get_supported_hue_func_t get_supported_hue; set_hue_func_t set_hue; get_supported_saturation_func_t get_supported_saturation; set_saturation_func_t set_saturation; get_default_image_attributes_func_t get_default_image_attributes; get_supported_wb_rb_gain_func_t get_supported_wb_rb_gain; set_manual_wb_rb_gain_func_t set_manual_wb_rb_gain; get_manual_wb_rb_gain_func_t get_manual_wb_rb_gain; get_default_wb_mode_func_t get_default_wb_mode; set_exposure_mode_func_t set_exposure_mode; is_exposure_mode_valid_func_t is_exposure_mode_valid; get_supported_shutter_speeds_func_t get_supported_shutter_speeds; get_default_shutter_speed_func_t get_default_shutter_speed; get_supported_ISO_values_func_t get_supported_ISO_values; get_default_ISO_value_func_t get_default_ISO_value; get_manual_shutter_speed_func_t get_manual_shutter_speed; get_manual_ISO_value_func_t get_manual_ISO_value; set_manual_shutter_speed_func_t set_manual_shutter_speed; set_manual_ISO_value_func_t set_manual_ISO_value; get_supported_ev_offsets_func_t get_supported_ev_offsets; set_ev_offset_func_t set_ev_offset; get_ev_offset_func_t get_ev_offset; configure_preview_func_t configure_preview; get_preview_buffer_size_func_t get_preview_buffer_size; get_metadata_func_t get_metadata; get_supported_gamma_func_t get_supported_gamma; set_gamma_func_t set_gamma; set_callbacks_func_t set_callbacks; set_custom_property_func_t set_custom_property; get_custom_property_func_t get_custom_property; get_sensor_property_func_t get_sensor_property; } camera_external_camera_t;Note:The Sensor service dynamically loads the structure to retrieve the function pointers so that it can interface with your camera driver library.In your camera driver library, you must useexternal_camera_defsto declare your variable name for the structure camera_external_camera_t. -
In the file that declares
external_camera_defs, you need to specify#define EXTERNAL_CAMERA_API_IMPLEMENTprior to including external_camera_api.h or any other Camera library header file. This is necessary to ensure backwards compatibility with future versions of the library. This can be done as follows:#define EXTERNAL_CAMERA_API_IMPLEMENT #include <camera/external_camera_api.h> - Configure the type as external_camera
and the address with the path to your camera driver library in
the sensor configuration file and the input representing your camera. See the
Sensor configuration file
in theSensor
chapter of the Sensor Framework Services Guide for more information.
An example of an external camera driver implementation is available with the Sensor Framework for QNX SDP
from the QNX Software Center. For more information, see the source
directory in your host installation at $QNX_BASE/source/adas-camera-examples-version.zip.
After you extract the ZIP file, you'll find the example at:
extraction_directory/source_package_adas_camera/lib/sensor_drivers/external_camera_example
