DJI cameras have many parameters available for users to modify, such as ISO/aperture/shutter/exposure values, etc.
This page is to introduce how to set a typical parameter of the camera - aperture parameter, by using synchronous and asynchronous APIs of CameraManager.
The camera aperture controls how large the window the sensor can see the world through. Increasing the aperture will increase the amount of light incident on the camera, and therefore increase the exposure.
More details about camera parameter please refer to here.
Demonstrate a typical sample about how to set the aperture of the camera by using CameraManager synchronous and asynchronous APIs.
The devices which is used in this sample are as follows:
Aircraft type: Matrice 210 V2 or Matrice 210 RTK V2
Gimbal Connector I: X7/X5S/X4S
Onboard SDK Device: Manifold 2-G
Please prepare your aircraft and camera according to the above preparation conditions. You can also connect the aircraft to the mobile APP - DJI Pilot and observe the changing of aperture.
As to how to build the Onboard SDK project, please refer to here.
After building your Onboard SDK project code, you will find two sample bin files
named camera_manager_sync_sample and camera_manager_async_sample.
Copy your UserConfig.txt file into the current path and run sample like ways below:
Run synchronous sample: ./camera_manager_sync_sample UserConfig.txt
Run asynchronous sample: ./camera_manager_sync_sample UserConfig.txt
If all the conditions are all right, you will see this log screen:

Enter b and then the aperture sample will begin to run.
Actually, camera-manager sample supports a new way to execute the sample. You can directly type your sample choice after
./camera_manager_sync_sample UserConfig.txt or ./camera_manager_async_sample UserConfig.txt, just like:
./camera_manager_sync_sample UserConfig.txt b or
./camera_manager_sync_sample UserConfig.txt b
Then the sample will automatically run the sample b.
CameraManager.callbackToSetAperture as a callback to call SetExposureModeAsyncSample to set exposure mode as APERTURE_PRIORITY.callbackToSetAperture will be called after related ack was returned.callbackToSetAperture, set the aperture parameter as target value by asynchronous API, passing user callback and data as callback handler.CameraManager.SetExposureModeSyncSample to set exposure mode as APERTURE_PRIORITY.
The result will be printed out to the console after the related ack was returned or timeout.setApertureSyncSample to set the aperture parameter as target value by synchronous API.
The result will be printed out to the console after the related ack was returned or timeout.// Setup the OSDK: Read config file, create vehicle, activate. |
First part of the sample, here it will do a initialization for Onboard SDK environment, including:
- Read the environment parameters including baudrate/communication device/app id/app key/test case choice, etc.
- Initialize the
vehicleand related components.- Do activation for the aircraft with app id and app key.
- Get the handler instance
vehicle.
/*! init camera modules for cameraManager */ |
Initialize the camera module and register them in
vehicle->cameraManager. Here initialization is including two camera modules, the index is PAYLOAD_INDEX_0 and PAYLOAD_INDEX_1.
CameraManagerAsyncSample *p = new CameraManagerAsyncSample(vehicle); |
Create the instance of 'CameraManagerAsyncSample'. And then developers can use this instance to get the asynchronous use sample of
CameraManagerquickly.
case 'b': |
If you want to modify the aperature value, exposureMode must be in MANUAL or APERTURE_PRIORITY. So here it calls the
setExposureModeAsyncSampleto set the exposure mode to beAPERTURE_PRIORITY. As a callback,callbackToSetAperturewill be called after the exposure mode set successfully and do the following setting.
void callbackToSetAperture(ErrorCode::ErrorCodeType retCode, |
Here calls
setApertureAsyncSampleto finish setting the aperture value of camera.
CameraManagerSyncSample *p = new CameraManagerSyncSample(vehicle); |
Create the instance of
CameraManagerSyncSample. And then developer can use this instance to get the synchronous use sample ofCameraManagerquickly.
case 'b': |
Here calls the
setExposureModeSyncSampleto set the exposure mode to beAPERTURE_PRIORITY. And then call thesetApertureSyncSampleto finish setting the aperture value of the camera.
/*! @brief Sample to set shutter aperture value for camera, using async api |
setApertureSyncSampleis a demonstration showing how to set the aperture of camera by the synchronous interface ofCameraManager. User can set the target aperture on the target camera in a blocking way, and the result will be returned when this API return.
ErrorCode::ErrorCodeType CameraManagerSyncSample::setApertureSyncSample( |
In the sample setApertureSyncSample, here are the main processes:
- Check the validity of the handlers
vehicleandvehicle->cameraManager.- Call the interface
getApertureSyncto get the current aperture parameter value.- Check the aperture parameter value is got successfully or not.
- Compare the current aperture value to the target aperture value.
- If the current aperture value is not equal to the target value, call the
CameraManagerAPIsetApertureSyncto set the aperture parameter value.
/*! @brief Sample to set shutter aperture value for camera, using async api |
setApertureAsyncSampleis a demonstration showing how to set the aperture of camera by the asynchronous interface ofCameraManager. Users can set the target aperture on the target camera in a non-blocking way, and the result will be announced by a callback which passed by users.
void CameraManagerAsyncSample::setApertureAsyncSample( |
In the sample
setApertureAsyncSample, here are the main processes:
- Check the validity of the handlers
vehicleandvehicle->cameraManager.- Call the interface
getApertureAsyncto get the current aperture parameter value,getApertureCbwill be registered as a callback and complete the following aperture setting processes.
void CameraManagerAsyncSample::getApertureCb(ErrorCode::ErrorCodeType retCode, |
- In the callback
getApertureCbwill check the aperture parameter value is got successfully or not.- Compare the current aperture value to the target aperture value.
- If the current aperture value is not equal to the target value, call the interface
setApertureAsyncto set the aperture parameter value.- Finally, pass the user callback and userdata into the
CameraManagerAPIsetApertureAsyncto set the aperture value.
The log of the camera manager async sample a is as shown below.

The target camera support aperture setting and the exposure mode must be in MANUAL or APERTURE_PRIORITY.
Please refer to the "Camera Functions Support List" in what-is-CameraManager.html