This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DLPLCR4500EVM: Hybrid Three phase Point cloud Generation

Part Number: DLPLCR4500EVM

Hi guys,

Is there a document that goes into the theory behind the hybrid thee phase + gray code algorithm implement by TI. I am looking for a really low level explanation. Does such a document exist?

Basically I am looking for an in depth explanation on what is happening in the function DecodeCaptureSequence in ThreePhase.cpp

I understand most of the function but there are a couple of lines to do with the phase unwrapping that I don't understand. The section of code that I am trying to better understand is below

// Calculate the wrapped phase
            phase_value = atan( sqrt(3.0) * (intensity_phase_n120 - intensity_phase_p120) /
                               (2.0*(intensity_phase_0)-(intensity_phase_n120)-(intensity_phase_p120)) )
                                / THREE_PHASE_PI;
            if((phase_value >= 0.5) || (phase_value <= -0.5)){
                // Pixel is invalid
                disparity_value = dlp::DisparityMap::INVALID_PIXEL;
            }
            else{
                // Convert the phase to a wrapped pixel value
                disparity_value = lroundf(over_sample*(phase_value + 0.5) * ((float)this->resolution_) / this->phase_counts_); // not sure what this line is doing
                if(this->use_hybrid_.Get()){
                    // Get the gray code disparity pixel value
                    gray_code_disparity.Unsafe_GetPixel(xCol,yRow,&gray_code_disparity_value);
                    //disparity_vals[(unsigned int)gray_code_disparity_value]++;
                    if((gray_code_disparity_value != dlp::DisparityMap::INVALID_PIXEL) &&
                       (gray_code_disparity_value != dlp::DisparityMap::EMPTY_PIXEL)){
                        // Check that the phase change regions are correct
                        if(((gray_code_disparity_value+1) % 4) == 0){ // Not sure on this line
                            // The fourth region of a period should be greater than
                            // 0.25 and absolutely greater than 0. If it is less than
                            // zero the phase has been missclassified
                            if(phase_value < 0) gray_code_disparity_value++; // not sure what this line is doing
                        }
                        else if(((gray_code_disparity_value+1) % 4) == 1){
                            // The first region of a period should be less than
                            // -0.25 and absolutely less than 0. If it is greater than
                            // zero the phase has been missclassified
                            if(phase_value > 0) gray_code_disparity_value--; // not sure what this line is doing
                        }
                        // Adjust the GrayCode disparity value to the phase regions
                        gray_code_disparity_value = gray_code_disparity_value / 4; // not sure what this line is doing
                        // Add the GrayCode disparity value to unwrap the values
                        disparity_value += (over_sample*gray_code_disparity_value*this->resolution_/this->phase_counts_); // not sure what this line is doing
                    }
                    else{
                        disparity_value = dlp::DisparityMap::INVALID_PIXEL;
                    }
                }
                else{
                    // Non hybrid method not implemented
                    disparity_value = dlp::DisparityMap::INVALID_PIXEL;
                }
            }
            // Save the calculated pixel value
            this->disparity_map_.Unsafe_SetPixel(xCol,yRow,disparity_value);
        }
    }

Any help would be greatly appreciated

Thanks

John

  • John,

    Are you looking to understand the specific lines you have commented here? Or the entire code block? In the meantime we will check to see what documentation is available regarding the source code implementation, if any.

    Thanks in advance for your patience.

    Best Regards,
    Philippe Dollo
  • Hi Philippe,

    Thanks for the reply.

    Primarily the lines I have commented. I just can't figure out from the code the logic behind how each pixel is being unwrapped using the gray code patterns.

    I understand the code that creates a disparity map from the gray code pattern and I understand how the wrapped phase for each pixel is calculated. I am just not seeing the logic on how both techniques are combined.

    Hope this clarifies

    Thanks

    John
  • Hi John,

    I got your question. Please allow few days to get back you on this.Thank you for your understanding.

    Regards,

    Sanjeev

  • Thanks Sanjeev

    John

  • Hi Sanjeev,

    Any joy getting more information on this part of the code or even better chatting with the guy who originally wrote it?

    Thanks

    John
  • Hi John, Kindly allow us some time while we obtain more info about this.

    Thanks & Regards,
    Hirak.
  • Thanks Hirak & sorry for the impatience

    John

  • Hi guys,

    Just wondering if you have any updates. It's having an impact on our in house development

    Thanks

    John

  • Hi John,

    I want to let you know that we are looking for resources familiar with the implementation. Unfortunately the original developer no more with TI and this code was developed quite a while ago and no one touched that portion of the code.

    I found this training to material see if it is useful for you https://training.ti.com/sites/default/files/docs/dlp_3d_scannning_sdk_improvement-sec_2_0.pdf 

    Look the slide with heading "DLP ® Structured Light SDK – Hybrid pattern Decoding"

    One way would be to modify the logic like commenting out to see the difference in the algorithm final output for same set of images and compare. 

    At a high level the logic under discussion is aiding to increase the precision of the disparity map. 

    You can comment this portion -

    //-- from here to 

    // Check that the phase change regions are correct
    if(((gray_code_disparity_value+1) % 4) == 0){
    // The fourth region of a period should be greater than
    // 0.25 and absolutely greater than 0. If it is less than
    // zero the phase has been missclassified
    if(phase_value < 0) gray_code_disparity_value++;
    }
    else if(((gray_code_disparity_value+1) % 4) == 1){
    // The first region of a period should be less than
    // -0.25 and absolutely less than 0. If it is greater than
    // zero the phase has been missclassified
    if(phase_value > 0) gray_code_disparity_value--;
    }

    //--- till here

    // Adjust the GrayCode disparity value to the phase regions
    gray_code_disparity_value = gray_code_disparity_value / 4;

    // Add the GrayCode disparity value to unwrap the values
    disparity_value += (over_sample*gray_code_disparity_value*this->resolution_/this->phase_counts_);

    And then compare how the results looking.

    Assuming gray_code_disparity_value = X

    @ line gray_code_disparity_value = gray_code_disparity_value / 4; // this would refine the value by (X+1)/4 or (x-1)/4 ; by commenting out we are just taking out +/- 0.25 error to the value.

    I hope this helps to some extent.

    Regards,
    Sanjeev

  • Hi Sanjeev,

    I thought this might be the case. I'll try and step through the code in more detail and see if I can get a better handle on how it all works together,

    Thanks for the reply

    John
  • Hi John,

    You are welcome. Feel free to get in touch with us if you have suggestions/comments.

    Regards,

    Sanjeev

  • Hi John,
    In the meantime i got details from the original developer -

    The logic has to do with unwrapping the phase of the Sinusoidal pattern. The extra strips tell the algorithm which sinusoidal phase it is looking at.

    Regards,
    Sanjeev
  • Hi Sanjeev,

    Very much appreciate coming back to me on this. 

    Would you be able to ask the developer one last question for me? (I'm like the tv detective columbo!)

    So I get the Gray code patterns help to determine which phase it is looking at but I'm just not sure on the theory of it.  Could the original developer possibly explain briefly how he knows if a particular pixel is related to a particular fringe N number through the use of the Gray codes? Is there a possibility that it could unwrap incorrectly using his method?

    Again I'm just trying to get my head around the theory of it all.

    Thanks in advance and sorry for all the questions

    John

  • John,
    I can try but not sure to get the details. Best way to experiment ourselves and then determine the logic and/or reason.
    Regards,
    Sanjeev
  • Hi Sanjeev,

    I totally understand. If you can't we'll try and figure it out

    Thanks again

    John
  • Hi John, have you got any further queries? We'll be temporarily closing this thread due to inactivity. You can reopen anytime.

    Thanks & Regards,
    Hirak.