Notifications
Clear all

[Closed] Calculating the projection matrix in MaxScript

Hi,

I have a MaxScript problem and would be most appreciative if anyone here could suggest a solution.

I am fairly new to MaxScript even though I’ve been using Max for some time. Primarily I work with computer vision and in particular multi-view 3D reconstuction systems. My aim is to use max to generate some synthetic scenes for measuring the accuracy of my reaconstruction system. Initially I wish to test the accuracy of the calibration algorithms that I am using. The calibration algorithms determine the mapping from 3D world coordinates to image plane coordinates in the form of a 4×3 projection matrix as described here:

http://www.vision.caltech.edu/mweber/research/CNS248/node26.html

I have calculated an accurate estimate of the projection matrix using computer vision methods and would like to verify the result by obtaining the equivalent matrix using maxscript. I have tried using $Camera0.transform and various other camera and node methods but am not sure how to obtain the projection matrix that I need. The end result should be able to multiply the world coordinate of a 3D vertex and produce the 2D coordinate at which the vertex will appear in a given camera, thus allowing me to compare both results and deduce the accuracy of my calibration.

Has anyone done this before or think that they might know how?

Thanks for taking the time to read this

1 Reply

If you multiply your point with (inverse camera.transform), you get the point’s coordinates in the camera coordinate system ([0,0,-z] in the image center, with z indicating the distance of the point from the camera). The x and y components of those coordinates are smallest in the lower left corner and need to be modified using the image resolution to get pixel coordinates.

Alternatively, you can get the point coordinates relative to the current viewport using this:


gw.setTransform (matrix3 1)
gw.transPoint myPoint

That will convert the point3 coordinate myPoint. Each component of the return value is in float format with the origin at the upper left. Note that this will only use the viewport information, so resizing the viewport will give you different coordinates!

– MartinB