boost::shared_ptr<rs::device>
createCaptureDevice (rs::context &ctx, int device_number)
{
  rs::device* d;
  d = ctx.get_device(device_number);
  if (!d)
    pcl::io::THROW_IO_EXCEPTION ("unable to create RealSense capture device");
  return makeSharedPtr (d);
}
Esempio n. 2
0
state *initializePointerLib()
{
	if (ctx.get_device_count() > 0)
	{
		static rs::device & dev = *ctx.get_device(0);

		int inputWidth = 320, inputHeight = 240, frameRate = 60;
		dev.enable_stream(rs::stream::color, inputWidth, inputHeight, rs::format::rgb8, frameRate);
		dev.enable_stream(rs::stream::depth, inputWidth, inputHeight, rs::format::z16, frameRate);
		dev.start();

		// some placeholders were added for intrinsics and extrinsics.
		state initState = { 0, 0, 0, 0, false,{ rs::stream::color, rs::stream::depth, rs::stream::infrared }, dev.get_depth_scale(),
			dev.get_extrinsics(rs::stream::depth, rs::stream::color), dev.get_stream_intrinsics(rs::stream::depth),
			dev.get_stream_intrinsics(rs::stream::depth), 0, 0, &dev };
		app_state = initState;
		auto t0 = std::chrono::high_resolution_clock::now();
		return &app_state;
	}
	return 0;
}
Esempio n. 3
0
int SensorLibRealSense::initialize() {
    std::cout << "SensorLibRealSense::initialize()" << std::endl;


    if (ctx.get_device_count() == 0) return EXIT_FAILURE;

    dev = ctx.get_device(0);
    printf("\nUsing device 0, an %s\n", dev->get_name());
    printf("    Serial number: %s\n", dev->get_serial());
    printf("    Firmware version: %s\n", dev->get_firmware_version());

    dev->enable_stream(rs::stream::depth,  D_width, D_height, rs::format::z16, 60);
    dev->enable_stream(rs::stream::color, D_width, D_height, rs::format::rgb8, 60);

    printf("Enabled Streams:Depth and Color\n");

    dev->start();
    printf("Device Started\n");

    this->initialized = true;
    return true;
}