在项目属性管理器中加入C:\Program Files (x86)\Intel RealSense SDK 2.0
目录下的intel.realsense.props文件即可放心 安全使用RealSense了。 不用再添加包含目录,库目录以及dll文件,是不是很好啊。哈哈!
如下图:
VS2015使用realsense简单有效的方法
新建realsensetest控制台空程序(win32 控制台)官方helloword代码写进来。
#include “stdafx.h”
#include
#include “librealsense2/rs.hpp”
#pragma comment(lib, “realsense2.lib”) //等同于在链接器的输入中添加附加依赖项
using namespace rs2;
using namespace std;

void main()
{
// Create a Pipeline, which serves as a top-level API for streaming and processing frames
pipeline p;
// Configure and start the pipeline
p.start();
while (true)
{
// Block program until frames arrive
frameset frames = p.wait_for_frames();
// Try to get a frame of a depth image
depth_frame depth = frames.get_depth_frame();
// The frameset might not contain a depth frame, if so continue until it does
if (!depth) continue;
// Get the depth frame’s dimensions
float width = depth.get_width();
float height = depth.get_height();
// Query the distance from the camera to the object in the center of the image
float dist_to_center = depth.get_distance(width / 2, height / 2);
// Print the distance
cout << “The camera is facing an object " << dist_to_center << " meters away \r”;
}
}
VS2015使用realsense简单有效的方法如图用X64。但第一行#include "stdafx.h"提示打不开,有错误怎么办?奇怪了,这个经常见的头,竟然不存在。哎,年久失忆,新建一个头文件,解决问题。内容如下:
#pragma once
//只编译一次防止重复包含
#define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料
#include <stdio.h>
#include <tchar.h>//这里就是你要用到的头文件

//这个文件的作用就是包含一些必要的头文件,放在一起便于管理,你这种小程序没必要用到了。

// TODO: 在此处引用程序需要的其他头文件
位置如下图:
VS2015使用realsense简单有效的方法运行成功,截图如下:
VS2015使用realsense简单有效的方法以后注意算法就行了,这些表面体力活就可以省去了。

相关文章:

  • 2021-11-26
  • 2021-03-28
  • 2021-06-11
  • 2021-08-30
  • 2021-08-11
  • 2021-10-05
  • 2021-10-22
  • 2021-06-15
猜你喜欢
  • 2021-08-12
  • 2021-06-21
  • 2021-11-14
  • 2022-02-18
  • 2021-05-18
  • 2021-06-02
相关资源
相似解决方案