Added new unit test for cv::initInverseRectificationMap()#20259
Conversation
|
Included sample distortion coefficients from a DSLR camera and a Point Grey camera. Current parameters pass using an image of |
9ec0560 to
698fc4d
Compare
| EXPECT_LE(cvtest::norm(dst, mesh_uv, NORM_INF), 1e-3); | ||
| } | ||
|
|
||
| TEST(Calib3d_initInverseRectificationMap, regression_14467) |
There was a problem hiding this comment.
regression_14467
Please change this name
There was a problem hiding this comment.
fixed. Assumed number is arbitrary and changed it to regression_14468.
| EXPECT_LE(cvtest::norm(dst, mesh_uv, NORM_INF), 1e-3); | ||
| } | ||
|
|
||
| TEST(Calib3d_initInverseRectificationMap, regression_14467) |
There was a problem hiding this comment.
regression_14467
Please change this name
There was a problem hiding this comment.
Assumed this is a duplicate of the comment above.
|
|
||
| TEST(Calib3d_initInverseRectificationMap, regression_14467) | ||
| { | ||
| Size size_w_h(512 + 3, 512); |
There was a problem hiding this comment.
It makes sense to use a really different width/height. Use some regular resolution like 640x480 or 1280x720 (camera matrix should be updated too)
There was a problem hiding this comment.
Updated intrinsics and extrinsics specification to use experimentally collected values.
Size size_w_h(1280, 800);
// Camera Matrix
double k[9]={
1.5393951443032472e+03, 0., 6.7491727003047140e+02,
0., 1.5400748240626747e+03, 5.1226968329123963e+02,
0., 0., 1.
};
double d[5]={ // Non-zero distortion
-3.4134571357400023e-03, 2.9733267766101856e-03, // K1, K2
3.6653586399031184e-03, -3.1960714017365702e-03, // P1, P2
0. // K3
};
Note, K1 and K2 have been increased from -3.4134571357400023e-01, 2.9733267766101856e-01 to meet error threshold of 2e-1
double R[9]={ // Random transform
9.6625486010428052e-01, 1.6055789378989216e-02, 2.5708706103628531e-01,
-8.0300261706161002e-03, 9.9944797497929860e-01, -3.2237617614807819e-02,
-2.5746274294459848e-01, 2.9085338870243265e-02, 9.6585039165403186e-01
};
|
|
||
| // Rotation | ||
| //double R[9]={1., 0., 0., 0., 1., 0., 0., 0., 1.}; // Identity transform (none) | ||
| double R[9]={1., 0.05, 0., 0.05, 1.0, 0.005, 0.005, 0., 1.}; // Random transform |
There was a problem hiding this comment.
valid transforms have some idempotent properties, like det(rotation) = 1 or -1
There was a problem hiding this comment.
See above comment
c32c028 to
c768a7c
Compare
|
It seems someone added a shell script which tries I don't have a fork of -- edit -- |
|
Ignore CN* builders. They have sporadic network issues. opencv_extra/contrib forks are optional. This command just checks that. |
@alalek Ok! Then unless you think there is merit to the alternate unit test I wrote today, then I think it's good to go? |
| EXPECT_LE(cvtest::norm(dst, mesh_uv, NORM_INF), 1e-3); | ||
| } | ||
|
|
||
| TEST(Calib3d_initInverseRectificationMap, regression_14468) |
There was a problem hiding this comment.
14468
What does it mean?
Add PR/issue number. Use #20165 as reference on original code.
There was a problem hiding this comment.
Haha, I incorrectly assumed that was an arbitrary number. Correction has been applied.
| double Y = R[3]*x_ + R[4]*y_ + R[5]; | ||
| double Z = R[6]*x_ + R[7]*y_ + R[8]; | ||
| double x__ = X/Z; | ||
| double y__ = Y/Z; |
There was a problem hiding this comment.
Perhaps it makes sense to add check that Z value doesn't drops to zero (fabs(Z) > 1e-6)
There was a problem hiding this comment.
This undistort function performs a rough estimate and should not be used as an undistort method. There are numerous weaknesses, including lack of regression (undistort should be iterative for best results) and missing handling for distortion coefficients outside of radial distortion.
As the coefficients are hard-coded to the unit test, I don't believe it is necessary to be overly thorough. If that is desired, full replication of cvUndistortPointsInternal() is necessary. This was attempted in the proposed alternate unit test but, aside from increasing the length of the code, did not add significant value.
Function is validated. Included an update to DISABLED_Calib3d_InitInverseRectificationMap. Includes updates per input from @alalek and unit test regression # to reflect PR #
91f63f8 to
464441d
Compare
Added new unit test for cv::initInverseRectificationMap()
Replaces unit test from #20165 and completes the updating of cv::initInverseRectificationMap() started in #20247
Patch to opencv_extra has the same branch name.