@@ -189,7 +189,6 @@ TEST_F(GaussianProjectionUTTestFixture, CenteredGaussian_NoDistortion_AnalyticMe
189189 nearPlane,
190190 farPlane,
191191 minRadius2d,
192- false ,
193192 false );
194193
195194 auto means2d_cpu = means2d.cpu ();
@@ -219,6 +218,78 @@ TEST_F(GaussianProjectionUTTestFixture, CenteredGaussian_NoDistortion_AnalyticMe
219218 EXPECT_NEAR (conics_cpu[0 ][0 ][2 ].item <float >(), expected_c, 1e-3f );
220219}
221220
221+ TEST_F (GaussianProjectionUTTestFixture, Orthographic_NoDistortion_AnalyticMeanAndDepth) {
222+ const int64_t C = 1 ;
223+
224+ const float x = 1 .0f , y = -2 .0f , z = 10 .0f ;
225+ means = torch::tensor ({{x, y, z}}, torch::kFloat32 );
226+ quats = torch::tensor ({{1 .0f , 0 .0f , 0 .0f , 0 .0f }}, torch::kFloat32 );
227+ logScales = torch::log (torch::tensor ({{0 .2f , 0 .3f , 0 .4f }}, torch::kFloat32 ));
228+
229+ worldToCamMatricesStart =
230+ torch::eye (4 , torch::TensorOptions ().dtype (torch::kFloat32 )).unsqueeze (0 ).expand ({C, 4 , 4 });
231+ worldToCamMatricesEnd = worldToCamMatricesStart.clone ();
232+
233+ const float fx = 123 .0f , fy = 77 .0f , cx = 320 .0f , cy = 240 .0f ;
234+ projectionMatrices = torch::zeros ({C, 3 , 3 }, torch::TensorOptions ().dtype (torch::kFloat32 ));
235+ auto projectionMatricesAcc = projectionMatrices.accessor <float , 3 >();
236+ projectionMatricesAcc[0 ][0 ][0 ] = fx;
237+ projectionMatricesAcc[0 ][1 ][1 ] = fy;
238+ projectionMatricesAcc[0 ][0 ][2 ] = cx;
239+ projectionMatricesAcc[0 ][1 ][2 ] = cy;
240+ projectionMatricesAcc[0 ][2 ][2 ] = 1 .0f ;
241+
242+ cameraModel = CameraModel::ORTHOGRAPHIC;
243+ distortionCoeffs = torch::zeros ({C, 0 }, torch::kFloat32 );
244+
245+ imageWidth = 640 ;
246+ imageHeight = 480 ;
247+ eps2d = 0 .3f ;
248+ nearPlane = 0 .1f ;
249+ farPlane = 100 .0f ;
250+ minRadius2d = 0 .0f ;
251+
252+ utParams = UTParams{};
253+ utParams.inImageMargin = 0 .1f ;
254+ utParams.requireAllSigmaPointsInImage = true ;
255+
256+ means = means.cuda ();
257+ quats = quats.cuda ();
258+ logScales = logScales.cuda ();
259+ worldToCamMatricesStart = worldToCamMatricesStart.cuda ();
260+ worldToCamMatricesEnd = worldToCamMatricesEnd.cuda ();
261+ projectionMatrices = projectionMatrices.cuda ();
262+ distortionCoeffs = distortionCoeffs.cuda ();
263+
264+ const auto [radii, means2d, depths, conics, compensations] =
265+ dispatchGaussianProjectionForwardUT<torch::kCUDA >(means,
266+ quats,
267+ logScales,
268+ worldToCamMatricesStart,
269+ worldToCamMatricesEnd,
270+ projectionMatrices,
271+ RollingShutterType::NONE,
272+ utParams,
273+ cameraModel,
274+ distortionCoeffs,
275+ imageWidth,
276+ imageHeight,
277+ eps2d,
278+ nearPlane,
279+ farPlane,
280+ minRadius2d,
281+ false );
282+
283+ auto means2d_cpu = means2d.cpu ();
284+ auto depths_cpu = depths.cpu ();
285+ auto radii_cpu = radii.cpu ();
286+
287+ EXPECT_GT (radii_cpu[0 ][0 ].item <int32_t >(), 0 );
288+ EXPECT_NEAR (depths_cpu[0 ][0 ].item <float >(), z, 1e-4f );
289+ EXPECT_NEAR (means2d_cpu[0 ][0 ][0 ].item <float >(), fx * x + cx, 1e-3f );
290+ EXPECT_NEAR (means2d_cpu[0 ][0 ][1 ].item <float >(), fy * y + cy, 1e-3f );
291+ }
292+
222293TEST_F (GaussianProjectionUTTestFixture, OffAxisTinyGaussian_NoDistortion_MeanMatchesPinhole) {
223294 const int64_t C = 1 ;
224295
@@ -283,7 +354,6 @@ TEST_F(GaussianProjectionUTTestFixture, OffAxisTinyGaussian_NoDistortion_MeanMat
283354 nearPlane,
284355 farPlane,
285356 minRadius2d,
286- false ,
287357 false );
288358
289359 auto means2d_cpu = means2d.cpu ();
@@ -379,7 +449,6 @@ TEST_F(GaussianProjectionUTTestFixture, MultiCamera_RadTanDistortion_PerCameraPa
379449 nearPlane,
380450 farPlane,
381451 minRadius2d,
382- false ,
383452 false );
384453
385454 auto radii_cpu = radii.cpu ();
@@ -475,7 +544,6 @@ TEST_F(GaussianProjectionUTTestFixture,
475544 nearPlane,
476545 farPlane,
477546 minRadius2d,
478- false ,
479547 false );
480548
481549 auto radii_cpu = radii.cpu ();
@@ -569,7 +637,6 @@ TEST_F(GaussianProjectionUTTestFixture,
569637 nearPlane,
570638 farPlane,
571639 minRadius2d,
572- false ,
573640 false );
574641
575642 auto radii_cpu = radii.cpu ();
@@ -671,7 +738,6 @@ TEST_F(GaussianProjectionUTTestFixture,
671738 nearPlane,
672739 farPlane,
673740 minRadius2d,
674- false ,
675741 false );
676742
677743 auto radii_cpu = radii.cpu ();
@@ -768,7 +834,6 @@ TEST_F(GaussianProjectionUTTestFixture,
768834 nearPlane,
769835 farPlane,
770836 minRadius2d,
771- false ,
772837 false );
773838
774839 auto radii_cpu = radii.cpu ();
@@ -837,7 +902,6 @@ TEST_F(GaussianProjectionUTTestFixture, RadTanThinPrism_IgnoresK456EvenIfNonZero
837902 nearPlane,
838903 farPlane,
839904 minRadius2d,
840- false ,
841905 false );
842906
843907 auto radii_cpu = radii.cpu ();
@@ -922,7 +986,6 @@ TEST_F(GaussianProjectionUTTestFixture,
922986 nearPlane,
923987 farPlane,
924988 minRadius2d,
925- false ,
926989 false );
927990
928991 // When the UT kernel discards a Gaussian, only radii are defined to be 0; other outputs are
@@ -997,7 +1060,6 @@ TEST_F(GaussianProjectionUTTestFixture,
9971060 nearPlane,
9981061 farPlane,
9991062 minRadius2d,
1000- false ,
10011063 false );
10021064
10031065 auto radii_cpu = radii.cpu ();
@@ -1069,7 +1131,6 @@ TEST_F(GaussianProjectionUTTestFixture, RollingShutterNone_DepthUsesStartPoseNot
10691131 nearPlane,
10701132 farPlane,
10711133 minRadius2d,
1072- false ,
10731134 false );
10741135
10751136 auto depths_cpu = depths.cpu ();
0 commit comments