---
title: "align-depth-color"
description: "## [https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#overview](https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#overview)Overview The depth sensor and the RGB sensor are positioned differently on the camera, resulting in a slight displacement between the images captured by each sensor. To align the depth and RGB images, we need to enable the \"Registration\"…"
url: "https://dev.lips-hci.com/lipsedge-sdk-c/align-depth-color/"
updated: "2025-09-05"
category: "LIPSedge™ SDK 1.x / LIPSedge™ SDK Languages & Libraries / C++"
tags:
  - LIPSedge SDK
---

# align-depth-color

## [https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#overview](https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#overview)Overview

The depth sensor and the RGB sensor are positioned differently on the camera, resulting in a slight displacement between the images captured by each sensor. To align the depth and RGB images, we need to enable the "Registration" setting.

## [https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#expect-output](https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#expect-output)Expect Output

- Registration disabled

![ADC1 | LIPS® Developer Documentation](https://dev.lips-hci.com/wp-content/uploads/2025/02/ADC1.png)

- Registration enabled

![ADC2 | LIPS® Developer Documentation](https://dev.lips-hci.com/wp-content/uploads/2025/02/ADC2.png)

## [https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#prerequisite](https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#prerequisite)Prerequisite

- [OpenCV Viewer](https://dev.lips-hci.com/lipsedge-sdk-c/opencv-viewer/)

## [https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#tutorial](https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#tutorial)Tutorial

Modify from [opencv_viewer](https://dev.lips-hci.com/lipsedge-sdk-c/opencv-viewer/). After getting color and depth frame, we use opencv `addWeighted` function to overlap these two images.

```
cv::addWeighted(colorMat, 0.8, depthMat, 0.2, 0.0, overlappingMat);
```

To turn on/off registraion, Use `setImageRegistrationMode` in SDK and give proper parameter.

```
// Enable
device.setImageRegistrationMode(openni::IMAGE_REGISTRATION_DEPTH_TO_COLOR);

//Disable
device.setImageRegistrationMode(openni::IMAGE_REGISTRATION_OFF);
```

Use variable `enableRegistration` to determinate whether to enable registration. When press 'a' on keyboard, turn on/off registration.

```
input = cv::waitKey(1);
if (input == 'a')
{
    enableRegistration = !enableRegistration;
    device.setImageRegistrationMode(enableRegistration ? openni::IMAGE_REGISTRATION_DEPTH_TO_COLOR openni::IMAGE_REGISTRATION_OFF);
    std::cout << "Image Registration: " << (enableRegistration ? "Enable" : "Disable") << std::endl;
}
```

## [https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#full-code](https://dev.lips-hci.com/lipsedge-tm-sdk-languages-and-libraries/overview/align-depth-color#full-code)Full code

[align-depth-color.cpp](https://github.com/lips-hci/dev-doc-code-samples/blob/master/c%2B%2B/align-depth-color/align-depth-color.cpp)
