Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
Usgscsm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aflab
astrogeology
Usgscsm
Commits
0917cec8
Commit
0917cec8
authored
1 year ago
by
Oleg Alexandrov
Browse files
Options
Downloads
Plain Diff
Fix conflict
parents
45c8ee47
4c8ce703
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Distortion.cpp
+37
-40
37 additions, 40 deletions
src/Distortion.cpp
tests/DistortionTests.cpp
+17
-8
17 additions, 8 deletions
tests/DistortionTests.cpp
with
54 additions
and
48 deletions
src/Distortion.cpp
+
37
−
40
View file @
0917cec8
...
...
@@ -165,13 +165,11 @@ void removeDistortion(double dx, double dy, double &ux, double &uy,
case
RADIAL
:
{
double
rr
=
dx
*
dx
+
dy
*
dy
;
if
(
rr
>
tolerance
)
{
double
dr
=
opticalDistCoeffs
[
0
]
+
(
rr
*
(
opticalDistCoeffs
[
1
]
+
rr
*
opticalDistCoeffs
[
2
]));
ux
=
dx
*
(
1.0
-
dr
);
uy
=
dy
*
(
1.0
-
dr
);
}
}
break
;
// Computes undistorted focal plane (x,y) coordinates given a distorted
...
...
@@ -363,13 +361,12 @@ void applyDistortion(double ux, double uy, double &dx, double &dy,
switch
(
distortionType
)
{
// Compute distorted focal plane coordinate given undistorted
// focal plane coordinate. This case works by iteratively adding distortion
// focal plane coordinate
s
. This case works by iteratively adding distortion
// until the new distorted point, r, undistorts to within a tolerance of the
// original point, rp.
case
RADIAL
:
{
double
rp2
=
(
ux
*
ux
)
+
(
uy
*
uy
);
if
(
rp2
>
tolerance
)
{
double
rp
=
sqrt
(
rp2
);
// Compute first fractional distortion using rp
double
drOverR
=
...
...
@@ -407,7 +404,7 @@ void applyDistortion(double ux, double uy, double &dx, double &dy,
dx
=
ux
/
(
1.0
-
drOverR
);
dy
=
uy
/
(
1.0
-
drOverR
);
}
}
break
;
case
TRANSVERSE
:
{
computeTransverseDistortion
(
ux
,
uy
,
dx
,
dy
,
opticalDistCoeffs
);
...
...
This diff is collapsed.
Click to expand it.
tests/DistortionTests.cpp
+
17
−
8
View file @
0917cec8
...
...
@@ -124,17 +124,26 @@ TEST(transverse, removeDistortion_AlternatingOnes) {
EXPECT_NEAR
(
uy
,
7.5
,
1e-8
);
}
TEST
(
Radial
,
testRemoveDistortion
)
{
csm
::
ImageCoord
imagePt
(
0.0
,
4.0
);
TEST
(
Radial
,
testUndistortDistort
)
{
double
ux
,
uy
;
std
::
vector
<
double
>
coeffs
=
{
0
,
0
,
0
}
;
// Distorted pixel
csm
::
ImageCoord
imagePt
(
0.0
,
1e-1
)
;
// Undistort
double
ux
,
uy
;
std
::
vector
<
double
>
coeffs
=
{
0.03
,
0.00001
,
0.000004
};
double
tolerance
=
1e-2
;
removeDistortion
(
imagePt
.
samp
,
imagePt
.
line
,
ux
,
uy
,
coeffs
,
DistortionType
::
RADIAL
);
DistortionType
::
RADIAL
,
tolerance
);
EXPECT_NEAR
(
ux
,
4
,
1e-8
);
EXPECT_NEAR
(
uy
,
0
,
1e-8
);
// Distort back
double
desiredPrecision
=
1e-6
;
double
dx
,
dy
;
applyDistortion
(
ux
,
uy
,
dx
,
dy
,
coeffs
,
DistortionType
::
RADIAL
,
desiredPrecision
,
tolerance
);
EXPECT_NEAR
(
dx
,
imagePt
.
samp
,
1e-8
);
EXPECT_NEAR
(
dy
,
imagePt
.
line
,
1e-8
);
}
// If coeffs are 0 then this will have the same result as removeDistortion
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment