奥比中光Astra Pro Demo示例
生活随笔
收集整理的這篇文章主要介紹了
奥比中光Astra Pro Demo示例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Orbbec Astra Pro 設備調試 Demo
- 使用奧比中光Astra Pro捕獲深度圖與彩色圖代碼
使用奧比中光Astra Pro捕獲深度圖與彩色圖代碼
#include <astra/astra.hpp> #include <opencv2/opencv.hpp>int main(int argc, char** argv) {//初始化Astra SDKastra::initialize();astra::StreamSet streamset;astra::StreamReader reader = streamset.create_reader();//獲取深度流auto depthStream = reader.stream<astra::DepthStream>();//配置深度流分辨率、格式和幀率astra::ImageStreamMode depthMode;depthMode.set_width(640);depthMode.set_height(480);depthMode.set_pixel_format(astra_pixel_formats::ASTRA_PIXEL_FORMAT_DEPTH_MM);depthMode.set_fps(30);//設置深度流模式并打開深度流depthStream.set_mode(depthMode);depthStream.start();//獲取彩色流auto colorStream = reader.stream<astra::ColorStream>();//配置彩色流的分辨率、格式和幀率astra::ImageStreamMode colorMode;colorMode.set_width(640);colorMode.set_height(480);colorMode.set_pixel_format(astra_pixel_formats::ASTRA_PIXEL_FORMAT_RGB888);colorMode.set_fps(30);//設置彩色流模式并打開彩色流colorStream.set_mode(colorMode);colorStream.start();while (true){//更新數據流astra_update();if (!reader.has_new_frame()){continue;}//獲取最后一幀auto frame = reader.get_latest_frame(100);//獲取深度幀數據auto depthFrame = frame.get<astra::DepthFrame>();auto depth = depthFrame.data();//獲取深度幀的寬高auto depthWidth = depthFrame.width();auto depthHeight = depthFrame.height();//處理并渲染深度幀數據if (depthFrame.is_valid()){cv::Mat rawMat(depthHeight, depthWidth, CV_16UC1, (void*)depth);cv::Mat depthMat;rawMat.convertTo(depthMat, CV_8UC1);cv::imshow("Depth Viewer", depthMat);}//獲取彩色幀數據auto colorFrame = frame.get<astra::ColorFrame>();auto color = colorFrame.data();//獲取彩色幀的寬高auto colorWidth = colorFrame.width();auto colorHeight = colorFrame.height();//處理并渲染彩色幀數據if (colorFrame.is_valid()){cv::Mat rawMat(colorHeight, colorWidth, CV_8UC3, (void*)color);cv::Mat colorMat;cv::cvtColor(rawMat, colorMat, cv::COLOR_BGR2RGB);cv::imshow("Color Viewer", colorMat);}//按ESC退出int key = cv::waitKey(100);if (key == 27)break;}//釋放Astra SDK資源astra::terminate(); }總結
以上是生活随笔為你收集整理的奥比中光Astra Pro Demo示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 移动端框架php,React移动端框架有
- 下一篇: libcurl库简介