Skip to main content

Camera IMU

Introduction​

These functions are responsible for configuring and retrieving motion data from the IMU sensor.

warning
  • These IMU APIs are supported only on VCM and TEVM cameras. Ensure your device hardware is compatible before calling these functions.
  • Frame-sync IMU data requires an active camera stream and flash mode enabled. Set ISP_IMAGE_FLASH_MODE to VX_FLASH_MODE::ENABLE (value 0), start streaming, then read acceleration or gyroscope data with VX_IMU_SELF_TEST_MODE::NONE.

VxEnableIMUMode​

Function:

int VxEnableIMUMode(std::shared_ptr<VxCamera> vxcam, VX_IMU_MODE mode)

Function Description:

  • This function is used to activate the IMU sensor on the VxCamera.
warning

This is a required initialization step before the SDK can access IMU data.

Parameter Description:

  • vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().

  • mode : A VX_IMU_MODE format variable which stored the mode value.

  • VX_IMU_MODE format:

    enum class VX_IMU_MODE{
    DISABLE,
    ISPU,
    SELF_TEST,
    FRAME_SYNC
    }

Return Values:

  • return 0 = PASS, return -1 = FAIL

Example:

VX_IMU_MODE mode = VX_IMU_MODE::ISPU;
// enable the imu mode
VxEnableIMUMode(vxcam, mode);

VxRebootIMUMode​

Function:

int VxRebootIMUMode(std::shared_ptr<VxCamera> vxcam, VX_IMU_MODE mode)

Function Description:

  • This function reboots the IMU mode and enables it as part of the same operation.
warning

This function also enables the IMU mode. A separate call to enable the IMU mode is not required.

Parameter Description:

  • vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().

  • mode : A VX_IMU_MODE format variable which stored the mode value.

  • VX_IMU_MODE format:

    enum class VX_IMU_MODE{
    DISABLE,
    ISPU,
    SELF_TEST,
    FRAME_SYNC
    }

Return Values:

  • return 0 = PASS, return -1 = FAIL

Example:

VX_IMU_MODE mode = VX_IMU_MODE::ISPU;
// reboot the imu mode
VxRebootIMUMode(vxcam, mode);

VxGetIMUAccData​

Function:

int VxGetIMUAccData(std::shared_ptr<VxCamera> vxcam, std::vector<float>& accArr, VX_IMU_SELF_TEST_MODE mode)

Function Description:

  • This function retrieves a list of 3-axis IMU acceleration data (x, y, z) from the VxCamera device.
info
  • Enable IMU SELF_TEST mode for self-test measurements, or FRAME_SYNC mode for acceleration data without changing self-test settings.
  • C# : The caller must create a FloatVector instance before calling this function.
  • C : The float list need to release by vx_release_imu_data function.

Parameter Description:

  • vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().

  • accArr : A vector of float type. The function will populate this vector with 3-axis IMU acceleration data.

  • mode : Use NONE (IMU_SELF_TEST_NONE in C) to read sensor data without writing IMU_SELF_TEST_CTRL. Other values select a self-test setting.

  • Return:

    • return 0 = PASS, return -1 = FAIL
    • Python : tuple(return_code, accArr)

      return_code : return 0 = PASS, return -1 = FAIL

  • VX_IMU_SELF_TEST_MODE format:

    enum class VX_IMU_SELF_TEST_MODE {
    NORMAL,
    POSITIVE,
    NEGATIVE,
    NOT_ALLOWED,
    NONE
    }

Example:

// enable IMU mode
VxEnableIMUMode(vxcam, VX_IMU_MODE::SELF_TEST);
std::vector<float> accArr;
// get IMU acceleration data
VxGetIMUAccData(vxcam, accArr, VX_IMU_SELF_TEST_MODE::POSITIVE);

VxGetIMUGyrData​

Function:

int VxGetIMUGyrData(std::shared_ptr<VxCamera> vxcam, std::vector<float>& gyrArr, VX_IMU_SELF_TEST_MODE mode)

Function Description:

  • This function retrieves a list of 3-axis IMU gyroscope data (x, y, z) from the VxCamera device.
info
  • Enable IMU SELF_TEST mode for self-test measurements, or FRAME_SYNC mode for gyroscope data without changing self-test settings.
  • C# : The caller must create a FloatVector instance before calling this function.
  • C : The float list need to release by vx_release_imu_data function.

Parameter Description:

  • vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().

  • gyrArr : A vector of float type. The function will populate this vector with 3-axis IMU gyroscope data.

  • mode : Use NONE (IMU_SELF_TEST_NONE in C) to read sensor data without writing IMU_SELF_TEST_CTRL. Other values select a self-test setting.

  • Return:

    • return 0 = PASS, return -1 = FAIL
    • Python : tuple(return_code, gyrArr)

      return_code : return 0 = PASS, return -1 = FAIL

  • VX_IMU_SELF_TEST_MODE format:

    enum class VX_IMU_SELF_TEST_MODE {
    NORMAL,
    POSITIVE,
    NEGATIVE,
    NOT_ALLOWED,
    NONE
    }

Example:

// enable IMU mode
VxEnableIMUMode(vxcam, VX_IMU_MODE::SELF_TEST);
std::vector<float> gyrArr;
// get IMU gyroscope data
VxGetIMUGyrData(vxcam, gyrArr, VX_IMU_SELF_TEST_MODE::POSITIVE);

vx_release_imu_data​

warning

This function is only supported in C.

Function:

void vx_release_imu_data(float* imu_data)

Function Description:

  • This function release IMU list retrieved from vx_get_imu_acc_data() and vx_get_imu_gyr_data().

Parameter Description:

  • format_list : A float type IMU data list.

Example:

float* accArr;
vx_get_imu_acc_data(cam, &accArr, POSITIVE);
vx_release_imu_data(accArr);

VxGetISPUData​

Function:

int VxGetISPUData(std::shared_ptr<VxCamera> vxcam, VxImuIspu& ispuData)

Function Description:

  • This function retrieves a structure containing IMU ISPU data from the VxCamera device.
info
  • Ensure that the IMU ISPU mode is enabled before calling this function.

Parameter Description:

  • vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().

  • ispuData : A VxImuIspu structure that is populated by the function with IMU ISPU data.

  • Return:

    • return 0 = PASS, return -1 = FAIL
    • Python : tuple(return_code, ispuData)

      return_code : return 0 = PASS, return -1 = FAIL

  • VxImuIspu structures:

    struct VxImuIspu{
    float x;
    float y;
    float z;
    float w;
    float yaw;
    float pitch;
    float roll;
    }

Example:

// enable imu ISPU mode
VxEnableIMUMode(vxcam, VX_IMU_MODE::ISPU);
VxImuIspu ispuData;
// get IMU ISPU data
VxGetISPUData(vxcam, ispuData);

VxGetIMUTemperature​

Function:

int VxGetIMUTemperature(std::shared_ptr<VxCamera> vxcam, float& temperature)

Function Description:

  • This function retrieves the temperature from the camera IMU sensor.

Parameter Description:

  • vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
  • temperature : A float variable that will be populated by the function with temperature data.
  • Return:
    • return 0 = PASS, return -1 = FAIL
    • Python : tuple(return_code, temperature)

      return_code : return 0 = PASS, return -1 = FAIL

Example:

float temperature;
// get IMU temperature
VxGetIMUTemperature(vxcam, temperature);

VxGetIMUSensorTime​

Function:

int VxGetIMUSensorTime(std::shared_ptr<VxCamera> vxcam, float& sensorTime)

Function Description:

  • This function retrieves the sensor time from the camera IMU sensor.

Parameter Description:

  • vxcam : A pointer shared ownership of a camera obtained from VxInitialCameraDevice().
  • sensorTime : A float variable that will be populated by the function with IMU sensor time data.
  • Return:
    • return 0 = PASS, return -1 = FAIL
    • Python : tuple(return_code, sensorTime)

      return_code : return 0 = PASS, return -1 = FAIL

Example:

float sensorTime;
// get IMU sensor time
VxGetIMUSensorTime(vxcam, sensorTime);