Ask Your Question
0

prints the values of disparity map

asked 2015-04-25 08:37:01 -0600

updated 2015-04-25 20:19:37 -0600

I'm developing 3D application I have printed disparity map Mat data, but I'm having trash data with correct data (I think it’s correct). In order to generate 3D point cloud

  1. want to make sure I printed the correct disparity map data ( what are the point[0] ,point [1], point[2])
  2. In order to generate 3D point cloud how do I use these data

Please find below the code I used for data of disparity map and printed results ( some of ). Any help is appreciated.

   static void saveXYZ(const char* filename, const Mat& mat)

{

        Vec3f point = mat.at<Vec3f>(y, x);

        FILE* fp = fopen(filename, "wt");

        for (int y = 0; y < mat.rows; y++)

        {


                for (int x = 0; x < mat.cols; x++)

                {
                        fprintf(fp, "%f %f %f\n", point[0], point[1], point[2]);

                        printf("%f %f %f\n", point[0], point[1], point[2]);



                }

        }

        fclose(fp);

}

output

-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-17813.333984 -24426.666016 128000.000000
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-10181.818359 -14482.213867 75889.328125
-10015.748047 -14425.197266 75590.554688
-9928.853516 -14482.213867 75889.328125
-9763.779297 -14425.197266 75590.554688
-14400.000000 -21552.941406 112941.179688
-14046.511719 -21302.326172 111627.906250
-1.#INF00 -1.#INF00 1.#INF00
-261333.328125 -407111.125000 2133333.250000
-232000.000000 -366400.000000 1920000.000000
-228800.000000 -366400.000000 1920000.000000
-225600.000000 -366400.000000 1920000.000000
-222400.000000 -366400.000000 1920000.000000
-199272.734375 -333090.906250 1745454.500000
-10964.466797 -18598.984375 97461.929688
-10747.474609 -18505.050781 96969.695313
-11453.551758 -20021.857422 104918.031250
-11278.688477 -20021.857422 104918.031250
-11103.825195 -20021.857422 104918.031250
-10810.810547 -19805.406250 103783.781250
-10524.064453 -19593.582031 102673.796875
-10352.941406 -19593.582031 102673.796875
-10181.818359 -19593.582031 102673.796875
-10010.695313 -19593.582031 102673.796875
-20000.000000 -39826.085938 208695.656250
-19652.173828 -39826.085938 208695.656250
-19516.484375 -40263.734375 210989.015625
-19164.835938 -40263.734375 210989.015625
-18813.187500 -40263.734375 210989.015625
-46666.667969 -101777.781250 533333.312500
-1.#INF00 -1.#INF00 1.#INF00
-67333.335938 -152666.671875 800000.000000
-63360.000000 -146560.000000 768000.000000
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-5082.353027 -14368.627930 75294.117188
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-4454.901855 -14368.627930 75294.117188
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-1.#INF00 -1.#INF00 1.#INF00
-10042.552734 -38978.722656 204255.312500
-9600.000000 -38568.421875 202105.265625
-7652.173828 ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2015-04-26 03:26:52 -0600

berak gravatar image

updated 2015-04-26 03:28:45 -0600

reprojectImageTo3D() already produces NaN values, due to dividing by zero (wherever your disparity map is 0)

you can use patchNaNs() to replace those with a value of your choice.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-04-25 08:37:01 -0600

Seen: 302 times

Last updated: Apr 25 '15