View my account

rs-measure.cpp funcrion dist_3d()

Comments

13 comments

  • MartyG

    There is a simple sample script in the documentation for using get_distance to measure the distance from camera to object without deprojection.

    https://github.com/IntelRealSense/librealsense#ready-to-hack 

    You can also speed up processing by offloading work from the CPU to a GPU.

    https://github.com/IntelRealSense/librealsense/issues/5440#issuecomment-565124976 

    1
    Comment actions Permalink
  • A Rothenberg

    So I'm seeing that  using the depth_frame I don't need to  bother with the deprojection process in rs-measure. Is that right?

    I am NVIDIA so I'll also l look at the  CUDA support and try and figure out what that means.

    Are "aligned" frames where color and depth data  are aligned? I only need depth data so I'll want to use "unalignd" frames. Is there something specific I have to do to have the frames unaligned or is that implied when using the depth_frame?

    0
    Comment actions Permalink
  • MartyG

    My understanding is that deprojection is of use when converting 2D to 3D (such as a 2D image to a 3D point cloud) but may be unnecessary if measuring the distance from camera to object in a 3D real-world scene, or if you do not need to get the XYZ coordinates of points in a scene.

    Alignment between depth and color frames is something that has to be specifically programmed.  It would be unaligned by default.

     

    0
    Comment actions Permalink
  • A Rothenberg

    It just occurred to me that since I'll never need a color stream, is there sensor functionality that I  can disable(?) in order to achieve efficiency?

    0
    Comment actions Permalink
  • A Rothenberg

    Good, Thanks. 

    I do need X,Y and Z. The CUDA thread's OP mentioned aligned frames being a problem. I'm glad I don't have to worry about that.

    Thank you.

    0
    Comment actions Permalink
  • MartyG

    You can override the default configuration of the camera and define your own, with only a depth stream, by placing 'cfg' (config) instructions directly before the pipe.start instruction.

    The link below has example code for defining a cfg for the depth stream (leave out the line that defines a color stream).

    https://github.com/IntelRealSense/librealsense/issues/5194#issuecomment-550297207 

    0
    Comment actions Permalink
  • A Rothenberg

    Yeah, I played with that for fps and it worked nicely. I was more wondering what options I would even need to disable for depth only streams.

    I'll look into the options. Thanks a lot. Great support.

    0
    Comment actions Permalink
  • MartyG

    With a cfg definition, the only streams that get defined are the ones you specify. If there is no cfg defined then the camera automatically uses the default settings for that particular RealSense model.

    You're very welcome. Feel free to ask questions any time you need to. Good luck!

    0
    Comment actions Permalink
  • A Rothenberg

    last post on this - the 3d distance code makes sense. It's uses the same get_distance function as in the link you posted.

    I was confused by the comments in the function.

    // Note: this can be optimized
    // It is not recommended to issue an API call for each pixel
    // (since the compiler can't inline these)
    // However, in this example it is not one of the bottlenecks

    it's not important though. I'm sure it will all make more sense as I use the product.

     

     

    0
    Comment actions Permalink
  • MartyG

    I wonder if using sub-sampling post processing might help.  A quote of documentation is below.

    ****************

    We usually recommend doing a non-zero mean for a pixel and its neighbors. All stereo algorithms do involve some convolution operations, so reducing the (X, Y) resolution after capture is usually very beneficial for reducing the required compute for higher-level apps. A factor of 2 reduction in resolution will speed subsequent processing up by 4x, and a scale factor of 4 will decrease compute by 16x.

    Moreover, the subsampling can be used to do some rudimentary hole filling and smoothing of data using either a non-zero mean or non-zero median function. Finally, sub-sampling actually tends to help with the visualization of the point-cloud as well.

     

    ***************

    Section 1.  Sub-Sampling in the post-processing documentation in the link below expands upon this information.

    https://dev.intelrealsense.com/docs/depth-post-processing 

    0
    Comment actions Permalink
  • A Rothenberg

    I see. That makes sense. Good information. The filters are part of the sdk , demonstrated in rs-post-processing.

    The sub-sampling seems to be something I need to do myself(?).

    That explains the comments though. Thanks.

     

     

     

     

    0
    Comment actions Permalink
  • MartyG

    As the post-processing guide mentions, the Decimation Filter does sub-sampling, and Intel have a sample program tutorial in the link below.

    https://github.com/IntelRealSense/librealsense/tree/master/examples/post-processing 

    A look through the source code of the SDK's Decimation Filter found that it already has use of medians built in.   The "Measure" program that you looked at earlier has Decimation Filter code that you should be able to adapt for your own program.

     

     

    0
    Comment actions Permalink
  • A Rothenberg

    Good. the decimation filter sub samples the depth table. Excellent. Thanks.

    It's in rs-post-processing. A nice program.  That's a better app then the depth quality tool for demonstrating the filters. 

    0
    Comment actions Permalink

Please sign in to leave a comment.