View my account

What is depth_pixel_index in rs-align-advanced.cpp?

Comments

3 comments

  • MartyG

    Have you gone through the step by step explanation of the script, please?

    https://github.com/IntelRealSense/librealsense/tree/master/examples/align-advanced

    0
    Comment actions Permalink
  • Nguyen Tnhoang

    I did Marty, but I still couldn't understand.

    So we have width and height.  You go over each pixel by looping with the corresponding x and y.  Then we have:

        depth_pixel_index = y * width

    Why would you need a value that is the product of the current height multiplied by the width?  Perhaps, understanding this would help me with pixels_distance and offset.

    0
    Comment actions Permalink
  • MartyG

    RealSense programming is not one of my specialist areas, so I am not the best person to provide an analysis of this script, but I will certainly try. 

    My reading of it is that it is calculating the coordinates of each pixel in the image as a depth_pixel_index, going through each pixel in turn.  The 'projection' system of RealSense can describe an image in terms of the number of rows (height) and columns (width) that an image has.   

    As the image updates in real-time based on the user's depth slider settings, I would guess that once it has checked through each of the pixels in turn using the for loop, it goes back to the start (the first pixel row / column) and uses the for loop to cycle through each of the pixels from first to last again to see if they have changed.  

    It looks as though once the details of a pixel coordinate are stored in depth_pixel_index, this variable is used in the pixels_distance formula to determine the depth of the pixel.  It then goes through a subsequent check.  If its depth is equal to or less than zero, or greater than the maximum background observation distance set by the user on the slider, then that pixel is removed from the image.  And so thanks to this check, the program can add to or reduce the level of detail in the image.

    My expectation would be then that the program:

    (a) Determines the coordinates of a pixel.

    (b) Stores the result in depth_pixel_index

    (c) Uses the value of depth_pixel_index to check whether the depth of a particular pixel is within allowed parameters (not equal / less than 0 or greater than the user-specified maximum distance), excludes that pixel if necessary and then begins the A to C cycle again for the next pixel in the image.

    I apologize that I cannot provide a more confident analysis!  I recommend asking @dorodnic (Dorodnic the RealSense SDK Manager) on the RealSense GitHub site for further details if you need them, as this example program was authored under his name.   You can do so by visiting the link below and clicking on the New Issue button to post a question there.

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

    0
    Comment actions Permalink

Please sign in to leave a comment.