#include "stdafx.h"
#include <iostream>
#include "librealsense2/rs.hpp"
#pragma comment(lib,"realsense2.lib")
using namespace rs2;
using namespace std;
void main() {
pipeline p;
p.start;
while (true)
{
frameset frames = p.wait_for_frames();
depth_frame depth = frames.get_depth_frame();
if (!depth)continue;
float width = depth.get_width();
float heigh = depth.get_height();
float dist_to_center = depth.get_distance(width / 2, heigh / 2);
cout << "The Camera is facing an object" << dist_to_center << "meters away \r";
}
}