0

我是英特尔 Realsense SDK 的新手,并在 Visual Studio 2017(C 或 C++)中为英特尔 Realsense 摄像头 D435 进行编码。

在我的示例中,我有以下内容,

static rs2::frameset current_frameset;
auto color = current_frameset.get_color_frame();
frame = cvQueryFrame(color);

我在第 3 行遇到错误,因为“无法将 'rs2::video_frame' 转换为 'CvCapture'”

我无法找到解决此问题的方法,事实证明这很困难并导致更多错误。

有谁知道我可以如何克服这个问题?

谢谢您的帮助!

4

1 回答 1

0

cvQueryFrame 接受 cvCapture 实例,它用于从相机中检索帧。在 LibRS 中,您检索回来的框架已经可以使用,您不必再次取回它。附上 LibRS 中的 CV 示例片段,您可以在此处参考完整代码

rs2::pipeline pipe;
// Start streaming with default recommended configuration
pipe.start();

using namespace cv;
const auto window_name = "Display Image";
namedWindow(window_name, WINDOW_AUTOSIZE);

while (waitKey(1) < 0 && cvGetWindowHandle(window_name))
{
    rs2::frameset data = pipe.wait_for_frames(); // Wait for next set of frames from the camera
    rs2::frame depth = color_map(data.get_depth_frame());

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

    // Create OpenCV matrix of size (w,h) from the colorized depth data
    Mat image(Size(w, h), CV_8UC3, (void*)depth.get_data(), Mat::AUTO_STEP);

    // Update the window with new data
    imshow(window_name, image);
}
于 2018-05-25T02:41:51.097 回答