前提・実現したいこと
現在、RealSenseでいろいろと遊んでいるのですが、複数台動かそうとしたとたんにうまく動作しなくなりました。同じような方法で1台のみなら動かせました…
発生している問題・エラーメッセージ
一瞬だけウィンドウに表示され、しばらく固まったあと、下のような例外が表示されます。
ハンドルされない例外が 0x00007FFBE0D6A388 で発生しました (MultiSense.exe 内): Microsoft C++ の例外: std::runtime_error (メモリの場所 0x000000F6428FF4C0)。
該当のソースコード
C++
1#include <librealsense2/rs.hpp> 2#include <opencv2/opencv.hpp> 3 4#include <iostream> 5#include <map> 6#include <vector> 7 8#define D415_SN "816312061925" 9#define T265_SN "845412111096" 10 11enum DeviceType { 12 DEPTH, 13 FISH 14}; 15 16 17class device { 18 19public: 20 rs2::colorizer colorizer; 21 22 rs2::pipeline pipe; 23 rs2::config cfg; 24 25 rs2::frameset frames; 26 27 std::vector<std::string> frame_name; 28 std::vector<rs2::video_frame> frame; 29 30 int width; 31 int height; 32 33 device(std::string serial) { 34 cfg.enable_device(serial); 35 pipe.start(cfg); 36 } 37 38 void getFrames(DeviceType type) { 39 pipe.try_wait_for_frames(&frames); 40 41 switch (type) { 42 case DEPTH: 43 frame_name.emplace_back("COLOR"); 44 frame_name.emplace_back("DEPTH"); 45 46 frame.emplace_back(frames.get_color_frame()); 47 frame.emplace_back(frames.get_depth_frame().apply_filter(colorizer)); 48 break; 49 50 case FISH: 51 frame_name.emplace_back("FISH_RIGHT"); 52 frame_name.emplace_back("FISH_LEFT"); 53 54 frame.emplace_back(frames.get_fisheye_frame(1)); 55 frame.emplace_back(frames.get_fisheye_frame(2)); 56 break; 57 } 58 } 59 60 void showFrame(DeviceType type) { 61 width = frame[0].get_width(); 62 height = frame[0].get_height(); 63 64 if (type == DEPTH) { 65 cv::Mat fream1(cv::Size(width, height), CV_8UC3, (void*)frame[0].get_data(), cv::Mat::AUTO_STEP); 66 cv::Mat fream2(cv::Size(width, height), CV_8UC3, (void*)frame[1].get_data(), cv::Mat::AUTO_STEP); 67 68 cv::imshow(frame_name[0], fream1); 69 cv::imshow(frame_name[1], fream2); 70 } 71 else if (type == FISH) { 72 cv::Mat fream1(cv::Size(width, height), CV_8UC1, (void*)frame[0].get_data(), cv::Mat::AUTO_STEP); 73 cv::Mat fream2(cv::Size(width, height), CV_8UC1, (void*)frame[1].get_data(), cv::Mat::AUTO_STEP); 74 75 cv::imshow(frame_name[0], fream1); 76 cv::imshow(frame_name[1], fream2); 77 } 78 } 79 80}; 81 82 83int main() { 84 device t265(T265_SN); 85 device d415(D415_SN); 86 87 while (cv::waitKey(1) < 0) { 88 t265.getFrames(FISH); 89 d415.getFrames(DEPTH); 90 91 t265.showFrame(FISH); 92 d415.showFrame(DEPTH); 93 } 94 95 return 0; 96}
試したこと
GitHubにあるサンプルコートだとOpenCVで表示していないのと、読んで理解できませんでした…
補足情報
使用したRealSense
・D415
・T265
動作環境
・Windows 10 Pro
・OpenCV 3.4.1
・Intel RealSense SDK 2.0
・Visual Studio Community 2017
回答お願いします!!!
あなたの回答
tips
プレビュー