RealSense(2)——rs-capture Sample

博客介绍了Github上Realsense相关项目的环境配置方法,包括在项目属性管理器中加入intel.realsense.props文件,在包含目录中加入指定路径或直接添加头文件。还给出了代码,并针对调试中example.hpp文件报错,提出将字符集从unicode改成多字节的解决办法。

Github项目网址:
https://github.com/IntelRealSense/librealsense/tree/master/examples

1.环境配置:

(1)在项目属性管理器中加入C:\Program Files (x86)\Intel RealSense SDK 2.0
目录下的intel.realsense.props文件
如下图:
这里写图片描述
(2)为引用头文件example.hpp,在项目-属性-VC++目录-包含目录中加入
C:\Program Files (x86)\Intel RealSense SDK 2.0\samples
或者,直接在头文件添加现有项example.hpp即可

2.代码如下:

#include "stdafx.h"
#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API
#include "example.hpp"          // Include short list of convenience functions for rendering

// Capture Example demonstrates how to
// capture depth and color video streams and render them to the screen
int main(int argc, char * argv[]) try
{
    rs2::log_to_console(RS2_LOG_SEVERITY_ERROR);
    // Create a simple OpenGL window for rendering:
    window app(1280, 720, "RealSense Capture Example");
    // Declare two textures on the GPU, one for color and one for depth
    texture depth_image, color_image;

    // Declare depth colorizer for pretty visualization of depth data
    //声明深度着色器,以增强深度数据的颜色可视化
    rs2::colorizer color_map;

    // Declare RealSense pipeline, encapsulating(封装) the actual device and sensors
    rs2::pipeline pipe;
    // Start streaming with default recommended configuration
    pipe.start();

    while (app) // Application still alive?
    {
        rs2::frameset data = pipe.wait_for_frames(); // Wait for next set of frames from the camera

         // Find and colorize the depth data查找深度数据并给其上色
        rs2::frame depth = color_map(data.get_depth_frame());
        rs2::frame color = data.get_color_frame();            // Find the color data

                                                              // For cameras that don't have RGB sensor, we'll render infrared frames instead of color
        if (!color)
            color = data.get_infrared_frame();

        // Render depth on to the first half of the screen and color on to the second
        depth_image.render(depth, { 0,               0, app.width() / 2, app.height() });
        color_image.render(color, { app.width() / 2, 0, app.width() / 2, app.height() });
    }

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

3.注意:调试过程中,example.hpp文件会出现如下报错“

error C2664:“HWND CreateWindowExW
(DWORD,LPCWSTR,LPCWSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID)”: 
无法将参数3从“const char”转换为“LPCWSTR”

解决办法:将项目使用的字符集从unicode改成多字节。

这里写图片描述

<think>嗯,用户想要检查在Ubuntu上通过dpkg列出的已安装的Intel RealSense ROS Noetic驱动及相关组件。首先,我需要回忆一下dpkg的用法,以及RealSense ROS包的名称可能是什么。 用户提到的ROS Noetic对应的是Ubuntu 20.04,所以应该确认系统版本是否正确。然后,使用dpkg命令列出已安装的包,可能需要用grep过滤出RealSense相关的包名。比如,RealSense的ROS包可能包含“realsense”或者“ros-noetic”之类的关键词。 另外,用户可能还安装了相关的依赖项,比如librealsense2这样的库,所以也要检查这些。除了dpkg之外,还可以用apt list --installed来查看,但dpkg更直接一些。另外,可能还需要检查ROS的工作空间是否安装了其他非系统包,比如通过catkin_make或colcon构建的包,这些可能需要手动查看安装目录。 用户可能还关心这些包的版本是否兼容,所以需要提醒他们注意版本号。最后,可能需要验证ROS节点是否能正常运行,比如启动相机节点查看输出。如果有问题的话,可能需要检查日志或者重新安装。</think>### 验证已安装的RealSense相关ROS包及依赖项步骤 1. **确认ROS环境版本** ROS Noetic对应Ubuntu 20.04系统[^1],首先检查系统版本: ```bash lsb_release -a ``` 输出应包含`Ubuntu 20.04 LTS`。 2. **列出所有RealSense相关ROS包** 使用`dpkg`命令过滤`realsense`和`ros-noetic`关键词: ```bash dpkg -l | grep -E 'realsense|ros-noetic' | grep -i intel ``` 示例输出可能包含: ``` ii ros-noetic-realsense2-camera 1.2.0-1focal amd64 Intel RealSense camera ROS package ii librealsense2 2.50.0-0~realsense amd64 Intel RealSense SDK 2.0 ``` 3. **检查关键组件** - **ROS驱动包**:确认存在`ros-noetic-realsense2-camera`或`ros-noetic-realsense2-description` - **SDK依赖**:验证`librealsense2`及其开发包`librealsense2-dev`是否安装 - **ROS工具**:检查`ros-noetic-rgbd-launch`等依赖项 4. **验证ROS包功能** 启动相机节点测试: ```bash roslaunch realsense2_camera rs_camera.launch ``` 若出现`depth`和`color`的topic,则驱动正常[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值