RM新时代网站

C++ 流對齊處理單元示例代碼-Align Filter Viewer

# 流對齊處理單元-AlignFilterViewer

 

支持設備: Gemini 330系列相機,例如:Gemini G335

 

功能描述:演示傳感器數據流同步對齊的操作,顯示對齊后的圖像,并通過(guò)ESC_KEY鍵退出程序

 

>本示例基于C++ hign Level API進(jìn)行演示

 

創(chuàng )建pipeline

ob::Pipeline pipe;

 

開(kāi)啟color流

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

 

開(kāi)啟深度流

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);

 

開(kāi)啟pipeline

pipe.start(config);

 

獲取幀數據

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

 

進(jìn)行對齊處理

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

 

關(guān)閉pipeline

pipe.stop();

預期輸出:

image.png 


RM新时代网站