krm104 / SPAAM_BaseCode

Base code for performing the basic mathematical operations of a Single Point Active Alignment Method (SPAAM) calibration.
8 stars 2 forks source link

Hi, Questions with your SPAAM_BaseCode #1

Open YXY1988 opened 8 years ago

YXY1988 commented 8 years ago

Hi,

I've rewriten the spaam using Eigen instead ublas and lapack, and get same results on the console as that in your image, however, the results seems unlike an camera Intrinsic multiply a rigid transformation matrix, and I'm afraid the result in the image, which is computed by your code, may somehow is wrong.

result in your image: -6640.58 225.343 -302.319 -112.316 111.294 1646.66 -6008.17 166.372 -0.306 0.921 -0.247 0.0879792

and when input your data into another spaam program in matlab the result is:

-5011.83592420330 3277.53874457985 -24829.3300605858 -272.608821243473 3106.06558443247 -14029.8151377142 -0.199795239916805 2.90148610393814 -18.4909279146322

and put their test dummy data into your code, the result is :

1221.34480062549 1455.62848882666 163.977489681255 867.658235903777
-265.687219302871 1863.57437678419 72.8259723257632 455.263014346237
0.0513078895212466 1.81743549648163 0.0210378747931705 1

where their result is:

8358.21279518851 2604.83124287841 -2768.33203171552 1547.33007894000
-1251.75655642416 8648.38650737823 -1134.58213259435 1240.30189551315
0.476205339417076 1.82625151808872 -5.10238334338816 1

which seems more like an intrinsic matrix multiply a rigid transform matrix.

I get confused and post my test results above, and want to find out where I am wrong. I urgently need to calibrate a stereo OST-HMD in C++ program. If you like to help, please contact asuka2013@sjtu.edu.cn.

Thanks.

krm104 commented 8 years ago

Hi Yin Xuyue,

I can confirm that the SPAAM base code on github is absolutely correct and will provide a 3x4 projection matrix. SPAAM does not provide an intrinsic matrix times a rigid transform but determines all 12 parameters of the projection directly, though you are correct that the projection represents intrinsics and a transform, the values themselves do not denote specific characteristics of either in the end. This 3x4 projection matrix is not used directly in OpenGL or other graphics programs. There is another function in the code to convert the 3x4 matrix into the 4x4 normalized projection matrix for a specific screen resolution and clipping planes.

Every set of data points will produce a different projection matrix result. I don't know what matlab code you are referring to. If you can send me a link to this matlab code I'd be happy to check that for you, but I can confirm that my code works and will produce a good calibration for an ost-hmd.

The SPAAM Base Code source has been used in a number of projects in C++: https://www.youtube.com/watch?v=CLe7JkoKpto https://www.youtube.com/watch?v=FCblJACs7sQ

There is even another sample source converted into JAVA for use on the Moverio BT-200 display.

If you've converted my code to use another package, then your package should produce the same output as my code with the same input. If it doesn't than something is different in your code. I'd be glad to check the matlab code if you send it to me.

Thank you,

Kenny Moser Ph.D Candidate Computer Science & Engineering Mississippi State University (moserk@acm.org)

On Sat, May 21, 2016 at 6:22 AM, Yin Xuyue notifications@github.com wrote:

Hi,

I've rewriten the spaam using Eigen instead ublas and lapack, and get same results on the console as that in your image, however, the results seems unlike an camera Intrinsic multiply a rigid transformation matrix, and I'm afraid the result in the image, which is computed by your code, may somehow is wrong.

result in your image: -6640.58 225.343 -302.319 -112.316 111.294 1646.66 -6008.17 166.372 -0.306 0.921 -0.247 0.0879792

and when input your data into another spaam program in matlab https://github.com/YutaItoh/HMD-Calibration the result is:

-5011.83592420330 3277.53874457985 -24829.3300605858 -272.608821243473 3106.06558443247 -14029.8151377142 -0.199795239916805 2.90148610393814 -18.4909279146322

and put their test dummy data into your code, the result is : 1221.34480062549 1455.62848882666 163.977489681255 867.658235903777 -265.687219302871 1863.57437678419 72.8259723257632 455.263014346237 0.0513078895212466 1.81743549648163 0.0210378747931705 1

where their result is: 8358.21279518851 2604.83124287841 -2768.33203171552 1547.33007894000 -1251.75655642416 8648.38650737823 -1134.58213259435 1240.30189551315 0.476205339417076 1.82625151808872 -5.10238334338816 1

which seems more like an intrinsic matrix multiply a rigid transform matrix.

I get confused and post my test results above, and want to find out where I am wrong. I urgently need to calibrate a stereo OST-HMD in C++ program. If you like to help, please contact asuka2013@sjtu.edu.cn.

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/krm104/SPAAM_BaseCode/issues/1

YXY1988 commented 8 years ago

Thank you for replying so soon ^_^

  1. My package using Eigen have same results as yours.
  2. The matlab version: https://github.com/YutaItoh/HMD-Calibration, I put your 2D and 3D point data in the DLT(uv,xyz) function and get the different result.

Thank you !

krm104 commented 8 years ago

Hi Yin,

If your Eigen version gets the same result as mine with the same data, then you're implementation is good, and you should be able to perform the calibration with no problem.

I know when I first started on OST-HMD calibration work, the biggest hurdle for me was getting all of the data straight, exactly what I needed and in what coordinate frame.

You know that you need the 2D pixel coordinates of the screen points, and the 3D (X, Y, Z) coordinate of the physical alignment point. Don't forget though, that the 3D (X, Y, Z) point needs to be the location relative to the HMD. That is, in reference to the tracking marker on the HMD, not the world coordinate system. If you already have all this figured out, then you're all set! You should be able to take the points, and then use your code to produce a projection matrix. Don't forget though, that the 3x4 matrix needs to be converted into a 4x4 matrix for use in opengl. There's a function in my code that performs this operation using the aspect ratio and resolution of the HMD you're using if you need it.

If you're not quite sure about how to get the 3D (X, Y, Z) points relative to the HMD let me know and I can give you an example to help you out with it.

I thought the matlab might have been Yuta's code. I'll look through his code and see what is causing the difference. I can assure you, though, that if your implementation is getting the same results as mine with the same data, that your result with your system data will be good and usable.

Kenny Moser Ph.D Candidate Computer Science & Engineering Mississippi State University (moserk@acm.org)

On Sun, May 22, 2016 at 8:41 AM, Yin Xuyue notifications@github.com wrote:

Thank you for replying so soon ^_^

  1. My package using Eigen have same results as yours.
  2. The matlab version: https://github.com/YutaItoh/HMD-Calibration, I put your 2D and 3D point data in the DLT(uv,xyz) function and get the different result.

Thank you !

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/krm104/SPAAM_BaseCode/issues/1#issuecomment-220833111

YXY1988 commented 8 years ago

Thank you for replying. I upload my Eigen-spaam on git, where I use

buildVt_mb(vt)
buildVf_mb(vf)

to import the second group data of the matlab datasets. Config an Eigen library is very easy, which is even free from compiling, just include the Eigen folder is OK. http://eigen.tuxfamily.org/index.php?title=Main_Page Here is my result using my code: image

Would you please test your datasets on my code and tell me if it is right? For currently, I'm struggling with data collection using OpenSceneGraph, and have no more data to do the test and check results. And I don't know how to use the openGL projection matrix either, it must be useful to verify the calibration results, and currently I haven't go that far. You say the GLmatrix is calculated according to HMD's ratio and resolution, however, I couldn't associate the "ratio and resolution" with "ne,fr,right,left,top,bottom" in the BuidGLMatrix3x4. More help needed! >"<

Thanks a lot ! Nice to discuss with you ^_^

krm104 commented 8 years ago

Hi Yin,

Here is a quick explanation of how to make and use the 4x4 matrix for opengl.


Once you have the data points collected, just like in the sample code, you call the following function (spaam_calibL is the variable name of the SPAAM_SVD object):

spaam_calibL.projectionDLTImpl( );

This will perform the mathematical calculations to build the 3x4 projection matrix. In order to build the 4x4 matrix you need to call this function:

spaam_calibL.BuildGLMatrix3x4( NeaR, FaR, right, left, top, bottom);

Near is the value of the near clipping plane, how far in front of the camera do you want objects to start being rendered. Far is the far clipping plane, har far away from the camera do you want objects to no longer be rendered

The next 4 parameters describe the resolution of the window.

right - left = window horizontal resolution top - bottom = window vertical resolution

So if you have a viewport that is 1280 x 720, you could use: right = 1280, left = 0 top = 720, bottom = 0


Now you can use the 4 x 4 projection matrix in your rendering

//////clear buffers and do other operations//////

//Switch Matrix Mode to Projection// glMatrixMode(GL_PROJECTION);

//Clear current projection matrix// glLoadIdentity();

//Load 4x4 projection matrix// glMultMatrixd(spaam_calibL.projMat3x4);

//Change the viewport if you're doing side by side rendering for a binocular system// glViewport(0, 0, WINDOW_WIDTH/2, HEIGHT);

//Switch Matrix Mode back to Model// glMatrixMode(GL_MODELVIEW);

//Do other rending operations//


Kenny Moser Ph.D Candidate Computer Science & Engineering Mississippi State University (moserk@acm.org)

On Mon, May 23, 2016 at 8:08 AM, Yin Xuyue notifications@github.com wrote:

Thank you for replying. I upload my Eigen-spaam on git, where I use

buildVt_mb(vt) buildVf_mb(vf)

to import the second group data of the matlab datasets. Config an Eigen library is very easy, which is even free from compiling, just include the Eigen folder is OK. http://eigen.tuxfamily.org/index.php?title=Main_Page Here is my result using my code: [image: image] https://cloud.githubusercontent.com/assets/6929416/15471608/5d4a1ac0-2129-11e6-9e55-a9835c96e810.png

Would you please test your datasets on my code and tell me if it is right? For currently, I'm struggling with data collection using OpenSceneGraph, and have no more data to do the test and check results. And I don't know how to use the openGL projection matrix either, it must be useful to verify the calibration results, and currently I haven't go that far. You say the GLmatrix is calculated according to HMD's ratio and resolution, however, I couldn't associate the "ratio and resolution" with "ne,fr,right,left,top,bottom" in the BuidGLMatrix3x4. More help needed! >"<

Thanks a lot ! Nice to discuss with you ^_^

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/krm104/SPAAM_BaseCode/issues/1#issuecomment-220975199

YXY1988 commented 8 years ago

So, have you found the reason that causes the difference between C++ version and matlab version ?

haithink commented 7 years ago

Kenny Moser, thanks for your opengl demo code!

krm104 commented 7 years ago

You're welcome! I'm happy that it has been a useful starting point for you