Perception

2023-03-29
No Rating

The header file for obtaining the functions related to perceptual grayscale images is dji_perception.h. This document describes the key information and usage of the structure and function prototypes in the dji_perception.h file.

Catalog

Definition, Enum and Struct

  • define IMAGE_MAX_DIRECTION_NUM 6
  • define DJI_PERCEPTION_INTRINSICS_PARAM_ARRAY_NUM 9
  • define DJI_PERCEPTION_ROTATION_PARAM_ARRAY_NUM 9
  • define DJI_PERCEPTION_TRANSLATION_PARAM_ARRAY_NUM 3

####typedef enum E_DjiPerceptionDirection

typedef enum {
    DJI_PERCEPTION_RECTIFY_DOWN = 0,
    DJI_PERCEPTION_RECTIFY_FRONT = 1,
    DJI_PERCEPTION_RECTIFY_REAR = 2,
    DJI_PERCEPTION_RECTIFY_UP = 3,
    DJI_PERCEPTION_RECTIFY_LEFT = 4,
    DJI_PERCEPTION_RECTIFY_RIGHT = 5
} E_DjiPerceptionDirection;

typedef enum E_DjiPerceptionCameraPosition

typedef enum {
    RECTIFY_DOWN_LEFT = 1,
    RECTIFY_DOWN_RIGHT = 2,
    RECTIFY_FRONT_LEFT = 3,
    RECTIFY_FRONT_RIGHT = 4,
    RECTIFY_REAR_LEFT = 5,
    RECTIFY_REAR_RIGHT = 6,
    RECTIFY_UP_LEFT = 21,
    RECTIFY_UP_RIGHT = 22,
    RECTIFY_LEFT_LEFT = 23,
    RECTIFY_LEFT_RIGHT = 24,
    RECTIFY_RIGHT_LEFT = 25,
    RECTIFY_RIGHT_RIGHT = 26
} E_DjiPerceptionCameraPosition;

typedef struct T_DjiPerceptionRawImageInfo

typedef struct {
    uint32_t index;
    uint8_t direction;
    uint8_t bpp;
    uint32_t width;
    uint32_t height;
} T_DjiPerceptionRawImageInfo;

typedef struct T_DjiPerceptionImageInfo

typedef struct {
    T_DjiPerceptionRawImageInfo rawInfo;
    uint16_t dataId;
    uint16_t sequence;
    //see enum E_DjiPerceptionCamPosition
    uint32_t dataType;
    uint64_t timeStamp;
} T_DjiPerceptionImageInfo;

typedef struct T_DjiPerceptionCameraParameters

typedef struct {
    uint8_t direction;
    float leftIntrinsics[DJI_PERCEPTION_INTRINSICS_PARAM_ARRAY_NUM];
    float rightIntrinsics[DJI_PERCEPTION_INTRINSICS_PARAM_ARRAY_NUM];
    float rotationLeftInRight[DJI_PERCEPTION_ROTATION_PARAM_ARRAY_NUM];
    float translationLeftInRight[DJI_PERCEPTION_TRANSLATION_PARAM_ARRAY_NUM];
} T_DjiPerceptionCameraParameters;

typedef struct T_DjiPerceptionCameraParametersPacket

typedef struct {
    uint32_t timeStamp;
    uint32_t directionNum;
    T_DjiPerceptionCameraParameters cameraParameters[IMAGE_MAX_DIRECTION_NUM];
} T_DjiPerceptionCameraParametersPacket;

typedef function DjiPerceptionImageCallback

typedef void(*DjiPerceptionImageCallback)(T_DjiPerceptionImageInfo imageInfo, uint8_t *imageRawBuffer,
                                          uint32_t bufferLen);

Function

function DjiPerception_Init

Function:Initialize the perception module. product:all
T_DjiReturnCode DjiPerception_Init(void);


Return
The details for the return code please refer to: DjiErrorCode

function DjiPerception_Deinit

Function: Deinitialize the perception module. product:all
T_DjiReturnCode DjiPerception_Deinit(void);


Return
The details for the return code please refer to: DjiErrorCode

function DjiPerception_SubscribePerceptionImage

Function:Subscribe the raw images of both stereo cameras in the same direction. Default frequency at 20 Hz. product:all
T_DjiReturnCode DjiPerception_SubscribePerceptionImage(E_DjiPerceptionDirection direction,
                                                       DjiPerceptionImageCallback callback);
Parameter
direction:direction to specify the direction of the subscription. Ref to E_DjiPerceptionDirection
callback:callback to observer the stereo camera image and info.
Return
The details for the return code please refer to: DjiErrorCode

function DjiPerception_UnsubscribePerceptionImage

Function:Unsubscribe the raw image of both stereo cameras in the same direction. product:all
T_DjiReturnCode DjiPerception_UnsubscribePerceptionImage(E_DjiPerceptionDirection direction);
Parameter
direction:direction to specify the direction of the subscription. Ref to E_DjiPerceptionDirection
Return
The details for the return code please refer to: DjiErrorCode

function DjiPerception_GetStereoCameraParameters

Function:Get the internal and external parameters of all stereo cameras. product:all
T_DjiReturnCode DjiPerception_GetStereoCameraParameters(T_DjiPerceptionCameraParametersPacket *packet);


Return
The details for the return code please refer to: DjiErrorCode

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.