日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

opencv读取realsense

發布時間:2024/3/26 编程问答 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 opencv读取realsense 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

代碼如下:

#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API #include <opencv2/opencv.hpp> // Include OpenCV APIint main(int argc, char * argv[]) try {// Declare depth colorizer for pretty visualization of depth datars2::colorizer color_map;// Declare RealSense pipeline, encapsulating the actual device and sensorsrs2::pipeline pipe;// Start streaming with default recommended configurationpipe.start();using namespace cv;const auto window_name = "depth Image";const auto window_name1 = "color Image";namedWindow(window_name, WINDOW_AUTOSIZE);namedWindow(window_name1, WINDOW_AUTOSIZE);while (waitKey(1) < 0 && getWindowProperty(window_name, WND_PROP_AUTOSIZE) >= 0&&getWindowProperty(window_name1, WND_PROP_AUTOSIZE) >= 0){rs2::frameset data = pipe.wait_for_frames(); // Wait for next set of frames from the camerars2::frame depth = data.get_depth_frame().apply_filter(color_map);rs2::frame color=data.get_color_frame().apply_filter(color_map);// Query frame size (width and height)const int w = depth.as<rs2::video_frame>().get_width();const int h = depth.as<rs2::video_frame>().get_height();const int w1 = color.as<rs2::video_frame>().get_width();const int h1 = color.as<rs2::video_frame>().get_height();// Create OpenCV matrix of size (w,h) from the colorized depth dataMat image(Size(w, h), CV_8UC3, (void*)depth.get_data(), Mat::AUTO_STEP);Mat images(Size(w1, h1), CV_8UC3, (void*)color.get_data(), Mat::AUTO_STEP);// Update the window with new dataimshow(window_name1, images);imshow(window_name, image);}return EXIT_SUCCESS; } catch (const rs2::error & e) {std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl;return EXIT_FAILURE; } catch (const std::exception& e) {std::cerr << e.what() << std::endl;return EXIT_FAILURE; }在這里插入代碼片

總結

以上是生活随笔為你收集整理的opencv读取realsense的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。