# 同步对齐示例
功能描述:本示例演示了对Sensor数据流控制对齐的操作,显示对齐后的图像,并通过ESC_KEY键退出程序
本示例基于C++ High Level API进行演示
ob::Pipeline pipe;
std::shared_ptr<ob::VideoStreamProfile> colorProfile = nullptr;
try {
// Get all stream profiles of the color camera, including stream resolution, frame rate, and frame format
auto colorProfiles = pipe.getStreamProfileList(OB_SENSOR_COLOR);
if(colorProfiles) {
colorProfile = std::const_pointer_cast<ob::StreamProfile>(colorProfiles->getProfile(OB_PROFILE_DEFAULT))->as<ob::VideoStreamProfile>();
}
config->enableStream(colorProfile);
}
catch(...) {
std::cerr << "Current device is not support color sensor!" << std::endl;
exit(EXIT_FAILURE);
}
// Get all stream profiles of the depth camera, including stream resolution, frame rate, and frame format
auto depthProfiles = pipe.getStreamProfileList(OB_SENSOR_DEPTH);
std::shared_ptr<ob::VideoStreamProfile> depthProfile = nullptr;
if(depthProfiles) {
depthProfile = std::const_pointer_cast<ob::StreamProfile>(depthProfiles->getProfile(OB_PROFILE_DEFAULT))->as<ob::VideoStreamProfile>();
}
config->enableStream(depthProfile);
std::shared_ptr<ob::Config> config = std::make_shared<ob::Config>();
config->enableStream(colorProfile);
config->enableStream(depthProfile);
// 配置对齐模式为软件D2C对齐
config->setAlignMode(ALIGN_D2C_SW_MODE);
pipe.start(config);
pipe.stop();
程序正常退出之后资源将会自动释放