-->

C++ 流对齐处理单元示例代码-Align Filter Viewer

# 流对齐处理单元-AlignFilterViewer

 

支持设备: Gemini 330系列相机,例如:Gemini G335

 

功能描述:演示传感器数据流同步对齐的操作,显示对齐后的图像,并通过ESC_KEY键退出程序

 

>本示例基于C++ hign Level API进行演示

 

创建pipeline

ob::Pipeline pipe;

 

开启color流

auto colorProfiles = pipe.getStreamProfileList(OB_SENSOR_COLOR);
if(colorProfiles) {
    colorProfile = colorProfiles->getVideoStreamProfile(1280, OB_HEIGHT_ANY, OB_FORMAT_RGB, 30);
}
config->enableStream(colorProfile);

 

开启深度流

auto                                    depthProfiles = pipe.getStreamProfileList(OB_SENSOR_DEPTH);
std::shared_ptr<ob::VideoStreamProfile> depthProfile  = nullptr;
if(depthProfiles) {
depthProfile = depthProfiles->getVideoStreamProfile(640, OB_HEIGHT_ANY, OB_FORMAT_Y16, 30);
//depthProfile = std::const_pointer_cast<ob::StreamProfile>(depthProfiles->getProfile(OB_PROFILE_DEFAULT))->as<ob::VideoStreamProfile>();
}
config->enableStream(depthProfile);

 

设置对齐模式

/* Config depth align to color or color align to depth.
OBStreamType align_to_stream = OB_STREAM_DEPTH; */
OBStreamType align_to_stream = OB_STREAM_COLOR;
ob::Align align(align_to_stream);

 

开启pipeline

pipe.start(config);

 

获取帧数据

auto colorFrame = frameSet->colorFrame();
auto depthFrame = frameSet->depthFrame();

 

进行对齐处理

aif(align_to_stream == OB_STREAM_COLOR) {
    app.resize(colorFrame->width(), colorFrame->height());
}
else {
    app.resize(depthFrame->width(), depthFrame->height());
}

 

关闭pipeline

pipe.stop();

预期输出:

image.png