External Camera Drivers

Updated: April 19, 2023

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:

  1. Provide your library with implementations for the following functions (mandatory):
    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.

  2. Create an instance called external_camera_defs and assign your camera driver functions using the camera_external_camera_t structure. For optional functions you didn't implement, you can assign NULL.
    camera_external_camera_t external_camera_defs = {
    open :                        my_open_external_camera,
    close :                       my_close_external_camera,
    init :                        my_init_camera,
    deinit :                      my_deinit_camera,
    start_preview :               my_start_preview,
    stop_preview :                my_stop_preview,
    get_preview_frame :           my_get_preview_frame,
    get_preview_num_buffers :     my_get_preview_num_buffers,
    get_supported_vf_frametype :  my_get_supported_vf_frame_types,
    get_supported_vf_resolution : my_get_supported_vf_resolutions,
    get_supported_vf_framerates : my_get_supported_vf_frame_rates,
    get_time :                    my_get_time,
    set_framerate :               my_set_framerate,
    get_framerate :               my_get_framerate,
    parse_config :                NULL
    };
    Note: In your camera driver library, you must use external_camera_defs to declare your variable name for the structure camera_external_camera_t.
    The Sensor service dynamically loads the structure to retrieve the function pointers so that it can interface with your camera driver library.
  3. In the file that declares external_camera_defs, you need to specify #define EXTERNAL_CAMERA_API_IMPLEMENT prior 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>
  4. 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 the Sensor 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