Basic Camera Management

2025-01-08
No Rating

Overview

In order to facilitate developers to quickly develop the function of controlling cameras on DJI drones based on PSDK, DJI PSDK provides a camera management function. The interface based on camera management allows developers to set and obtain the sensitivity of multiple cameras on drones at the same time. , Aperture, Shutter, Exposure, and other parameters to control the camera to achieve functions such as taking pictures, recording videos, and pointing and zooming.

Camera management function

When using the camera management function, the developer needs to initialize the camera management function module in the PSDK first, then set the camera mode according to the actual user needs, and finally realize the required use according to the user's use logic. Functions, such as setting camera parameters or checking the status of functions, etc.

FunctionH30H30TH20H20TH20NL1P1PSDKXT2XTSZ30M30M30TM3EM3TL2M3DM3TDM4EM4T
Basic InformationGet camera type--
Get firmware version--
Get camera connection status--
Shot FunctionsSet/Get working mode--
Set/Get shooting photo mode--
Start/Stop shooting photo--
Set/Get burst parameter-----------------
Set/Get AEB burst shooting parameter--------------------
Set/Get interval shooting parameter--
Start/Stop recording video--
Camera shooting status----
Multi-lens shooting save setting--------
Get photo format range--
Set/Get photo format--
Get interval shooting countdown------
Record status------
Current recording video length------
Multi-lens recording save setting----------
Get recording format range--
Set/Get support video format--
Get video source range--
Set video source range------
Get camera lens photo ratio range--
Set camera lens photo ratio--
Get camera lens video resolution and frame rate--
Set night mode open-------------
Zoom/Focus FunctionsSet/Get focus mode----
Set/Get focus target-----
Start/Stop continuous optical zoom-------
Set/Get optical zoom parameter-------
Set/Get tap zoom switch------
Set/Get tap zoom parameter--------
Execute tap zoom based on target---------
Get minium setting parameter for manual focus----
Get maximum setting parameter for manual focus----
Set manual focus parameter----
Camera Basic ParameterSet/Get exposure mode-----
Set/Get ISO-----
Set/Get aperture-----
Set/Get shutter speed-----
Set/Get exposure compensation parameter-----
Lens automatic exposure lock-----
Reset Camera Parameter--
Media File ManagementDownload media file list--
Download media file list by slices-------
Download media file--
Delete media file--
Set/Get custom file folder name suffix------
Set/Get custom file name suffix-------
Get camera SD card storage information------
Format storage--
Laser Rangefinder FunctionsGet laser rangefinder information-------------
Infrared Camera FunctionsSet coordinate points of infrared temperature management
Get data of infrared temperature management
-----------------
Set the region of infrared temperature management
Get the region data of infrared temperature management
-----------------
Set infrared zoom parameter-----------------
Set/Get thermal gain mode-------------
Get thermal gain mode temperature range-------------
Set FFC calibration mode-------------
Manual trigger FFC calibration mode for once-------------
Enable/Disable cooperation zoom function---------------
Metering FunctionsSet camera lens metering mode-----
camera lens spot metering--

Table. Differences for functional support of cameras

Using the camera management function

1. Camera management module initialization

If the payload device developed with PSDK needs to control the camera function, it needs to call the DjiCameraManager_Init() interface to initialize the camera management module.

USER_LOG_INFO("--> Step 1: Init camera manager module");
DjiTest_WidgetLogAppend("--> Step 1: Init camera manager module");
returnCode = DjiCameraManager_Init();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
    USER_LOG_ERROR("Init camera manager failed, error code: 0x%08X\r\n", returnCode);
    goto exitCameraModule;
}

2. Get the camera type and version

Developers can obtain the camera type and version of the specified mount location on the drone by calling the DjiCameraManager_GetCameraType and DjiCameraManager_GetFirmwareVersion interfaces respectively.

    USER_LOG_INFO("--> Step 2: Get camera type and version");
    DjiTest_WidgetLogAppend("--> Step 2: Get camera type and version");
    returnCode = DjiCameraManager_GetCameraType(mountPosition, &cameraType);
    if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
        USER_LOG_ERROR("Get mounted position %d camera's type failed, error code: 0x%08X\r\n",
                       mountPosition, returnCode);
        goto exitCameraModule;
    }
    USER_LOG_INFO("Mounted position %d camera's type is %s",
                  mountPosition,
                  s_cameraTypeStrList[DjiTest_CameraManagerGetCameraTypeIndex(cameraType)].cameraTypeStr);

    returnCode = DjiCameraManager_GetFirmwareVersion(mountPosition, &firmwareVersion);
    if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
        USER_LOG_ERROR("Get mounted position %d camera's firmware version failed, error code: 0x%08X\r\n",
                       mountPosition, returnCode);
        goto exitCameraModule;
    }
    USER_LOG_INFO("Mounted position %d camera's firmware is V%d.%d.%d.%d\r\n", mountPosition,
                  firmwareVersion.firmware_version[0], firmwareVersion.firmware_version[1],
                  firmwareVersion.firmware_version[2], firmwareVersion.firmware_version[3]);

3. Set or get camera parameters

Camera management provides a series of Set or Get interfaces, you can set or get the camera parameters of the specified mount location. For example, you can get and set the ISO parameters of the camera by calling the DjiCameraManager_GetISO and DjiCameraManager_SetISO interfaces respectively.

T_DjiReturnCode returnCode;
E_DjiCameraManagerISO isoDataTemp;

returnCode = DjiCameraManager_GetISO(position, &isoDataTemp);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS &&
    returnCode != DJI_ERROR_CAMERA_MANAGER_MODULE_CODE_UNSUPPORTED_COMMAND) {
    USER_LOG_ERROR("Get mounted position %d camera's iso failed, error code: 0x%08X.",
                   position, returnCode);
    return returnCode;
}

if (isoDataTemp == isoData) {
    USER_LOG_INFO("The mounted position %d camera's iso is already what you expected.",
                  position);
    return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

returnCode = DjiCameraManager_SetISO(position, isoData);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS &&
    returnCode != DJI_ERROR_CAMERA_MANAGER_MODULE_CODE_UNSUPPORTED_COMMAND) {
    USER_LOG_ERROR("Set mounted position %d camera's iso %d failed, "
                   "error code: 0x%08X.", position, isoData, returnCode);
}

return returnCode;

4. Control the camera to perform the specified action

The developer can execute the specified camera action by calling the corresponding interface. For example, calling the DjiCameraManager_StartShootPhoto interface can control the camera at the specified location to take pictures.

/*!< start to shoot single photo */
USER_LOG_INFO("Mounted position %d camera start to shoot photo", position);
returnCode = DjiCameraManager_StartShootPhoto(position, DJI_CAMERA_MANAGER_SHOOT_PHOTO_MODE_SINGLE);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
    USER_LOG_ERROR("Mounted position %d camera shoot photo failed, "
                   "error code :0x%08X", position, returnCode);
}

5. Subscribe the real-time 3D point cloud data from the camera

Note: Only supported by the L2 camera, compatible with M300 RTK and M350 RTK.

Developers can subscribe the real-time 3D point cloud data from the L2 camera by invoking the following Sample. Note: When subscribing the real-time 3D point cloud data, you must shut down DJI Pilot 2; otherwise, PSDK will not be able to subscribe the real-time 3D point cloud data from the L2 camera.

returnCode = DjiTest_CameraManagerSubscribePointCloud(mountPosition);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
    USER_LOG_ERROR("Fail to download point cloud. position %d, error code 0x%08llX",
               mountPosition, returnCode);
    goto exitCameraModule;
}

6. Download and Delete Camera Raw Media Files

Developers can download and delete media files captured by DJI cameras by using the following sample code. Supported media file formats for download include: JPG, DNG, MOV, MP4, LDRT (point cloud decimation file, supported only by L2 cameras) ,and LDRT (point cloud original file, supported only by L2 cameras). Note that media files in LDRT or LDR format cannot be deleted.

DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(mountPosition);
If you have any comments or confusion about our documentation, you can click here to give feedback and we will get back to you as soon as possible.