-
-
Notifications
You must be signed in to change notification settings - Fork 959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undistort 2D points function #1026
Conversation
@jhacsonmeza could you add some uni tests? Check the ones e.g. in geometry epipolar |
I've added a unit test |
Hi @jhacsonmeza , As you probably have noticed that some tests failed, so to be able to move forward we need to fix them:
|
@jhacsonmeza @dkoguciuk as for the format we don’t have to worry that much any more since we have not the pre-commit bot (update your pr with master for that). As for gradcheck, make sure that any operations doesn’t contain possible zero divisions. Besides, I’d suggest as discussed in slack to provide batched functionality to make easier to compute e.g loss functions |
@dkoguciuk thank you. I'm going to modify the code to be aligned with pep8. I've used pytest to check my unit test, and I'm working in a problem. |
@jhacsonmeza code format shouldn’t be a problem any more since the precommit-ci will fix fir you every time you push a commit to the branch |
for more information, see https://pre-commit.ci
def test_opencv(self, device, dtype): | ||
# ----- Test 1: using 5 distortion coefficients | ||
pts = torch.tensor( | ||
[[1028.0374, 788.7520], [1025.1218, 716.8726], [1022.1792, 645.1857]], device=device, dtype=dtype |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[[1028.0374, 788.7520], [1025.1218, 716.8726], [1022.1792, 645.1857]], device=device, dtype=dtype | |
[[[1028.0374, 788.7520], [1025.1218, 716.8726], [1022.1792, 645.1857]]], device=device, dtype=dtype |
# ptsu_expected = cv2.undistortPoints(pts.numpy().reshape(-1,1,2), K.numpy(), | ||
# dist1.numpy(), None, None, K.numpy()).reshape(-1,2) | ||
ptsu_expected = torch.tensor( | ||
[[1030.5992, 790.65533], [1027.3059, 718.10020], [1024.0700, 645.90600]], device=device, dtype=dtype |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[[1030.5992, 790.65533], [1027.3059, 718.10020], [1024.0700, 645.90600]], device=device, dtype=dtype | |
[[[1030.5992, 790.65533], [1027.3059, 718.10020], [1024.0700, 645.90600]]], device=device, dtype=dtype |
assert points.shape == (B, N, 2) | ||
|
||
def test_opencv(self, device, dtype): | ||
# ----- Test 1: using 5 distortion coefficients |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also Split in three different tests
test_opencv_five_coeff
test_opencv_all_coeff
test_opencv_stereo
for more information, see https://pre-commit.ci
* 2D undistort points function * Doctumentation and comments added * Unit test for undistort_points function * Optional batch inputs for undistortion * Code aligned with PEP8 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * split opencv_test into three different test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update kornia/geometry/calibration/undistort.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Edgar Riba <edgar.riba@gmail.com>
Description
undistort_points
function to compensate for lens distortion a set of 2D points. Radial, tangential, thin prism, and tilt distortion are considered. AdditionallyinverseTiltProjection
function is used for the tilt distortion compensation.