DJI cameras have many operational functions available for users to operate, such as taking photos/videos/tap zoom, etc.
This page is to introduce how to use a typical function of camera - tap zoom function, by using synchronous and asynchronous APIs of CameraManager.
Zoom capabilities include optical zoom, digital zoom, and Hybrid zoom, which, like conventional camera designs, depending on the focal length of the lens, leaving resolution and image quality unchanged. Digital zoom reduces the size of the original image, making it larger on the LCD screen, but it doesn't help to make details clearer.
This sample support Z30 in Matrice 210 V2 or Matrice 210 RTK V2. More details about Z30 please refer to here.
Demonstrate a typical sample about how to execute tap zoom 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 II: Z30
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:
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 f and then the aperture sample will begin to run.
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 f or
./camera_manager_sync_sample UserConfig.txt f
Then the sample will automatically run the sample f.
CameraManager.asyncSampleCallBack as a callback to call setTapZoomPointAsyncSample to set the
tap zoom multiplier as 5 and tap zoom point as (0.3,0.3).asyncSampleCallBack will be called when the related ack was returned.asyncSampleCallBack, the result will be printed out to the console.asyncSampleCallBack as a callback to call setTapZoomPointAsyncSample to set the
tap zoom multiplier as 5 and tap zoom point as (0.8,0.7).asyncSampleCallBack will be called when the related ack was returned.asyncSampleCallBack, the result will be printed out to the console.CameraManager.setTapZoomPointSyncSample to set the tap zoom multiplier as 5 and tap zoom point as (0.3,0.3).
The result will be printed out to the console after the related ack was returned or timeout.setTapZoomPointSyncSample to set the tap zoom multiplier as 5 and tap zoom point as (0.8,0.7).
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 initialize Onboard SDK environment. The main steps are as follows:
- 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 the initialization contains two camera modules, the index is PAYLOAD_INDEX_0 and PAYLOAD_INDEX_1.
CameraManagerSyncSample *p = new CameraManagerSyncSample(vehicle); |
Create the instance of
CameraManagerAsyncSample. And then developers can use this instance to get the asynchronous use sample ofCameraManagerquickly.
case 'f': |
Passing
asyncSampleCallBackas a callback to callsetTapZoomPointAsyncSampleto set the tap zoom multiplier as 5 and tap zoom point as (0.3,0.3). Then callbackasyncSampleCallBackwill be called when the related ack was returned. The result will be printed out to the console Callback functionasyncSampleCallBack.Do the sample operation again to the point (0.8,0.7).
CameraManagerSyncSample *p = new CameraManagerSyncSample(vehicle); |
Create the instance of CameraManagerSyncSample. And then developers can use this instance to get the synchronous use sample of
CameraManagerquickly.
case 'f': |
Call
setTapZoomPointSyncSampleto set the tap zoom multiplier as 5 and tap zoom point as (0.3,0.3). The result will be printed out to the console after the related ack was returned or timeout. Sleep for 5 seconds.Do the sample operation again to the point (0.8,0.7).
/*! @brief Sample to set tap-zoom point for camera, using async api |
setTapZoomPointSyncSampleis a demonstration showing how to execute the tap zoom function of camera by the synchronous interface ofCameraManager. User can set the target zoom multiplier and tap zoom point in a blocking way, and the result will be returned when this API returned. Users can observe the result on the screen of mobile APP.
ErrorCode::ErrorCodeType CameraManagerSyncSample::setTapZoomPointSyncSample( |
In the sample
setTapZoomPointSyncSample, here are the main processes:
- Check the validity of the handlers
vehicleandvehicle->cameraManager.- Call the interface
setTapZoomEnabledSyncto set the tap zoom function to be enable.- Call the interface
setTapZoomMultiplierSyncto set the tap zoom multiplier to be target valuemultiplier.- Call the interface
tapZoomAtTargetSyncto set the tap zoom point to be the target point(x, y).
/*! @brief Sample to set tap-zoom point for camera, using async api |
setTapZoomPointAsyncSampleis a demonstration showing how to execute the tap zoom function of camera by the asynchronous interface ofCameraManager. Users can set the target zoom multiplier and tap zoom point in a non-blocking way, and the result will be announced by a callback which passed by the user.
void CameraManagerAsyncSample::setTapZoomPointAsyncSample( |
In the sample
setTapZoomPointAsyncSample, here are the main processes:
- Check the validity of the handlers
vehicleandvehicle->cameraManager.- Call the interface
setTapZoomMultiplierAsyncto set the tap zoom multiplier.setTapZoomMultiplierCbwill be registered as a callback and complete the following tap zoom setting processes.
void CameraManagerAsyncSample::setTapZoomMultiplierCb( |
- Callback function
setTapZoomMultiplierCbwill check the tap zoom multiplier is set successfully or not.- If fail, the user callback will return the error code.
- If success then calling the interface
setTapZoomEnabledAsyncwith callbacksetTapZoomEnableCbto set the tap zoom function as enable.
void CameraManagerAsyncSample::setTapZoomEnableCb( |
- Callback function
setTapZoomEnableCbwill check the tap zoom function is enabled successfully or not.- If fail, the user callback will return the error code.
- If success then calling the interface
tapZoomAtTargetAsyncwith the user callback to set the tap zoom point.
The log of the camera manager async sample f is as shown below.

The target payload index should match Z30 Camera.
Please refer to the "Camera Functions Support List" in what-is-CameraManager.html