Пример #1
0
    void enable_device(rs2::device dev)
    {
        std::string serial_number(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
        std::lock_guard<std::mutex> lock(_mutex);

        if (_devices.find(serial_number) != _devices.end())
        {
            return; //already in
        }

        // Ignoring platform cameras (webcams, etc..)
        if (platform_camera_name == dev.get_info(RS2_CAMERA_INFO_NAME))
        {
            return;
        }
        // Create a pipeline from the given device
        rs2::pipeline p;
        rs2::config c;
        c.enable_device(serial_number);
        // Start the pipeline with the configuration
        rs2::pipeline_profile profile = p.start(c);
        // Hold it internally
        _devices.emplace(serial_number, view_port{ {},{},{}, p, profile });

    }
Пример #2
0
float get_depth_scale(rs2::device dev)

{

	// Go over the device's sensors

	for (rs2::sensor& sensor : dev.query_sensors())

	{

		// Check if the sensor if a depth sensor

		if (rs2::depth_sensor dpt = sensor.as<rs2::depth_sensor>())

		{

			return dpt.get_depth_scale();

		}

	}

	throw std::runtime_error("Device does not have a depth sensor");

}
 /**
 * Creates a recording device to record the given device and save it to the given file as rosbag format
 * \param[in]  file                  The desired path to which the recorder should save the data
 * \param[in]  device                The device to record
 * \param[in]  compression_enabled   Indicates if compression is enabled
 */
 recorder(const std::string& file, rs2::device dev, bool compression_enabled)
 {
     rs2_error* e = nullptr;
     _dev = std::shared_ptr<rs2_device>(
         rs2_create_record_device_ex(dev.get().get(), file.c_str(), compression_enabled, &e),
         rs2_delete_device);
     rs2::error::handle(e);
 }
 /**
 * Creates a recording device to record the given device and save it to the given file as rosbag format
 * \param[in]  file      The desired path to which the recorder should save the data
 * \param[in]  device    The device to record
 */
 recorder(const std::string& file, rs2::device dev)
 {
     rs2_error* e = nullptr;
     _dev = std::shared_ptr<rs2_device>(
         rs2_create_record_device(dev.get().get(), file.c_str(), &e),
         rs2_delete_device);
     rs2::error::handle(e);
 }
Пример #5
0
static std::string get_device_information(const rs2::device& dev)
{

    std::stringstream ss;
    ss << "Device information: " << std::endl;

    for (int i = 0; i < static_cast<int>(RS2_CAMERA_INFO_COUNT); i++)
    {
        rs2_camera_info info_type = static_cast<rs2_camera_info>(i);
        ss << "  " << std::left << std::setw(20) << info_type << " : ";

        if (dev.supports(info_type))
            ss << dev.get_info(info_type) << std::endl;
        else
            ss << "N/A" << std::endl;
    }
    return ss.str();
}
Пример #6
0
bool try_get_depth_scale(rs2::device dev, float& scale)
{
    // Go over the device's sensors
    for (rs2::sensor& sensor : dev.query_sensors())
    {
        // Check if the sensor if a depth sensor
        if (rs2::depth_sensor dpt = sensor.as<rs2::depth_sensor>())
        {
            scale = dpt.get_depth_scale();
            return true;
        }
    }
    return false;
}
Пример #7
0
    void rebuild()
    try
    {
      auto& ctx = t_jit_realsense::context();
      // First cleanup if device is changing
      cleanup();
      dev = nullptr;

      // Try to get the new device
      auto devs = ctx.query_devices();
      auto n_dev = devs.size();
      post("There are %d connected RealSense devices.\n", n_dev);

      if(n_dev <= device)
      {
        post("Device %d is not connected.", device);
        return;
      }

      dev = devs[device];


      post("\nUsing device %d, an %s\n", device, dev.get_info(rs2_camera_info::RS2_CAMERA_INFO_NAME));
      post("    Serial number: %s\n", dev.get_info(rs2_camera_info::RS2_CAMERA_INFO_SERIAL_NUMBER));
      post("    Firmware version: %s\n", dev.get_info(rs2_camera_info::RS2_CAMERA_INFO_FIRMWARE_VERSION));

      rebuild_streams();

      device_cache = device;
      out_count_cache = out_count;
    }
    catch(const std::exception & e)
    {
      error("realsense: %s\n", e.what());
      if(dev)
        dev = nullptr;
    }