i connect the D435 camera to PC(windows 7), install the realsense sdk 2.0, open the intel realsense viewer(win 7), it works fine ,i can see both depth and rgb image, the i open the example program; there is a hello-world program:
using namespace rs2;
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
std::cout << "The camera is facing an object " << dist_to_center << " meters away \r";
}
}
the depth is always NULL, the program cannot output the distance value;
then i open the realsense viewer, it show usb cam overflow.
why is that?
Did i miss something, or config the vs studio? i am using vs 2015 community version.
連結已複製
Hi Michael,
Have you tried running any of the C or C++ examples included in the SDK? The code you provided is just a code snippet and isn't meant to be a full program. The rs-distance example uses the code snippet above in a full program.
Regards,
Sahira
