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.

Disparity computation using VLIB?

Dear experts,

 

Has anyone tried the VLIB for stereo matching?

There is an example codes "VLIB_testDisparity8" for disparity computation,

but it is hard to understand the codes?  Could you let me know the flow of the example

and the meanings of parameters?  When I tried the example codes, the results are

not good.

 

Thanks,

Kevin.

  • Hello Kevin, I'm sorry for your trouble. Can you please describe more about your setup?

    * What device are you using?
    * What version of library are you using?
    * Did you run the example out of the box or did you do any modification?
    * What do you mean when you say results are not good?

    Thank you,
    Gagan

  • Hi Gagan,

    Thank you for your quick reply. I'll need your help for a while to settle down the development

    environment.

     

    Regarding your questioins,

    * What device are you using?

        =>  We obtained the results using PC (Windows XP), but eventually targeting at C6748 EVM.


    * What version of library are you using?

        =>  We are using VLIB 2.1


    * Did you run the example out of the box or did you do any modification?

        => We changed only some parameters, such as WINDOW_SIZE and BLOCK_SIZE

             for tests.


    * What do you mean when you say results are not good?

       => We hope that the disparity map will be a decent result, but the results from using

            the example "VLIB_testDisparity8" were not good (for a variety of parameters).

            The disparity map has big white spots (probably due to using signed char for the disparity?),

             as well as unknown bar-like artifacts (probably due to using block-wise data-reading?).

            It would be nice to have a description about the "VLIB_testDisparity8" test esample.

  •  

    Hello Kevin,

    Did you try running with the default parameters? If not, please do that to verify the implementation as the test function is already validated with these default parameters.

    You can also remove the block-wise implementation and use large buffers for simulation.

        for(d = DMIN; d <= DMAX; d++)
        {
            VLIB_disparity_SAD_firstRow8
            (
                    left+WINDOW_SIZE*W+DMAX+WS_BY_2,
                    rght+WINDOW_SIZE*W+DMAX+WS_BY_2-d,
                    pCost + (d - DMIN)*(W+ARRAY_PAD - DMAX - WS_BY_2),
                    minCost,
                    versum,
                    disparity+ (DMAX+WS_BY_2),
                    d, (W - DMAX - WS_BY_2), W, WINDOW_SIZE
            );
        }

        rndx += 1;

        for (i = 1; i < H; ++i)
        {
            memset(minCost, 0x7f, sizeof(minCost));
           
            for(d = DMIN; d <= DMAX; d++)
            {
                VLIB_disparity_SAD8
                (
                    left+rndx*W+(DMAX+WS_BY_2),
                    rght+rndx*W+(DMAX+WS_BY_2) -d,
                    pCost + (d - DMIN)*(W+ARRAY_PAD - DMAX - WS_BY_2),
                    minCost,
                    disparity+i*W + (DMAX+WS_BY_2),
                    d, (W- DMAX - WS_BY_2), W, WINDOW_SIZE
                );
            }

            rndx += 1;

            if (rndx + WS_BY_2 >= RBLINES)
            {
            readimage_rows8(left, leftIm8 , &rl,W, W,H, BLOCK_SIZE, WINDOW_SIZE);
            readimage_rows8(rght, rghtIm8 , &rr,W, W,H, BLOCK_SIZE, WINDOW_SIZE);
            rndx = WS_BY_2 + 1;
            }

           }

    In the above code segments, you can replace left and rght by leftIm8 and rghtim8 and remove the calls to readimage_rows8.

     

     

     

    Regarding the parameters, please refer to the VLIB documentation for the parameters related to the disparity API.

    I will try to give a short description of the other parameters in the test code.

    BLOCK_SIZE - Number of rows that are loaded from the image to the local buffer for the image

    RBLINES - Local buffer size which holds BLOCK_SIZE new lines and WINDOW_SIZE old lines.

    ARRAY_PAD - It is the size of array padding at the end of array which is required when the array size is not a multiple of 8. As data is loaded using mem8 which loads 8 bytes at a time, it will cause an overflow if array size is not a multiple of 8.

     

     

    Please let me know if you have any more queries or need any help.

    P.S: I was on an official trip and hence the delay in the reply. Sorry for that.

     

    Regards,

    Senthil

     

     

  • Sentil, 

     

    I am also trying to implement the VLIB disparity function into my application, but I am having a little bit of trouble.

    First of all, when I go to run the example code as is, I get an error stating that "readimage_rows8" is an unresolvable symbol.  Using your notes above, I took it out of the code, and it seems to run fine.  Can you point me to where I can find this function?  Is there a library or a header that I forgot to include?

     

    Further, I am wondering what type of image data the disparity_SAD8 function needs as inputs.  I have tried to look through the documentation, but I can't seem to find that info.  Can you point me towards those resources please?

     

    Thanks, 

    John

  •  

    John,

    The function 'readimage_rows8' is present in the file 'VLIB_testDisparityUtils.c'.

    The input images should be unsigned char arrays. Please see the data in 'VLIB_disparity8Data.c' file.

    VLIB_testDisparity8 contains a wrapper code to illustrate the usage of the API.

    Regards,

    Senthil

  • Senthil, 

     

    Thanks for the quick reply.  I was able to find the readImage function.

    I still have some question about the input image data though.  I can see that the data is stored in unsigned char arrays.  And from what I understand, that is just the luminance data for each pixel. I guess my question is that if I have a monochrome bitmap, how do I strip out all of the header info so that I am left with just the pixel data?  Is there a function or example code out there for that?   

     

    Thanks, 

     

    John

  •  

    John,

    If you have access to Matlab or Octave, its pretty easy to do the above.

    You can use imread( ) function to read the image into a matrix and you can write a script to write it as an array in a text file.

    There are also open-source libraries like OpenCV which could be used to convert the image into an array.

    You can also use free software like irfanview to convert the bitmap image to pgm format which has very minimal header info and you can find lots of scripts online to read pgm files into an array.

    Regards,

    Senthil