View my account

About RealSense Depth Camera D435i SDK

Comments

5 comments

  • MartyG

    The RealSense tutorials, which quote parts from a complete script, are best read in the context of the entire script so that you can see the instructions that come before and after the quoted section.  For example:

    https://github.com/IntelRealSense/librealsense/blob/master/examples/record-playback/rs-record-playback.cpp#L42 

    An old programming technique is to take the complete script and then remove sections from it until it stops working, and then put that part back and remove something else.  Eventually you end up with a stripped-down, easier to understand script that you can then refine further to get it doing exactly what you want.

    Having said that, the RealSense GitHub forum may be the best place to get advice about creating custom code of your own.

    https://github.com/IntelRealSense/librealsense/issues 

     

     

    0
    Comment actions Permalink
  • Yoichi Hagiwara

    An exception occurs at pipe-> start (); in the following program, and it is said that Camera already streaming.

     

    void rs2start(const char *str)
    {
     try{
      // Create a shared pointer to a pipeline
      auto pipe = std::make_shared<rs2::pipeline>();
      // Start streaming with default configuration
      pipe->start();

      // Initialize a shared pointer to a device with the current device on the pipeline
      rs2::device device = pipe->get_active_profile().get_device();

      if (!device.as<rs2::playback>()) // Disable recording while device is playing
      {
       if (!device.as<rs2::recorder>())
       {
        pipe->stop(); // Stop the pipeline with the default configuration
        pipe = std::make_shared<rs2::pipeline>();
        rs2::config cfg; // Declare a new configuration
        cfg.enable_record_to_file(str);
        pipe->start(cfg); //File will be opened at this point
       }
      }
     }
     catch (const rs2::error & e)
     {
      std::cout << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl;
     }
     catch (const std::exception& e)
     {
      std::cerr << e.what() << std::endl;
     }
    }

    0
    Comment actions Permalink
  • MartyG

    Your version of the program does not seem to be asking the camera to wait for frames.

    https://github.com/IntelRealSense/librealsense/blob/master/examples/record-playback/rs-record-playback.cpp#L71 

    0
    Comment actions Permalink
  • Yoichi Hagiwara

    Even if you request the camera to wait for a frame, an exception will be generated by pipe-> start ();#L12  in the following program, and it is said that Camera already streaming.

     

    void rs2start(const char *str)
    {
     try{

           // Declare frameset and frames which will hold the data from the camera
           rs2::frameset frames;
           rs2::frame depth;

           // Declare depth colorizer for pretty visualization of depth data
           rs2::colorizer color_map;

      // Create a shared pointer to a pipeline
      auto pipe = std::make_shared<rs2::pipeline>();
      // Start streaming with default configuration
      pipe->start();

      // Initialize a shared pointer to a device with the current device on the pipeline
      rs2::device device = pipe->get_active_profile().get_device();

           // If the device is sreaming live and not from a file
           if (!device.as<rs2::playback>())
           {
               frames = pipe->wait_for_frames(); // wait for next set of frames from the camera
               depth = color_map.process(frames.get_depth_frame()); // Find and colorize the depth data
           }

      if (!device.as<rs2::playback>()) // Disable recording while device is playing
      {
       if (!device.as<rs2::recorder>())
       {
        pipe->stop(); // Stop the pipeline with the default configuration
        pipe = std::make_shared<rs2::pipeline>();
        rs2::config cfg; // Declare a new configuration
        cfg.enable_record_to_file(str);
        pipe->start(cfg); //File will be opened at this point
       }
      }
     }
     catch (const rs2::error & e)
     {
      std::cout << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl;
     }
     catch (const std::exception& e)
     {
      std::cerr << e.what() << std::endl;
     }

    0
    Comment actions Permalink
  • MartyG

    RealSense programming is not one of my specialist areas, which is why I suggested that the GitHub may be a better place to ask this particular question.  If you want to avoid the exception though, you could look at the scripts in this link for checking if the camera is streaming:

    https://github.com/IntelRealSense/librealsense/issues/2240 

    0
    Comment actions Permalink

Please sign in to leave a comment.