Skip to content
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

Distortion normalization improvement + fix "folding" on large distortions #3009

Merged
merged 25 commits into from
Jun 21, 2021
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9a3e7f8
Pixel coordinates projected to camera plane for distortion
May 13, 2021
ed7a417
Fixes wraparound issue for extreme distortions
May 22, 2021
ba51bac
Add test for extreme distortion
paudrow May 26, 2021
8a95b8d
Refactor SetCamera
paudrow May 27, 2021
eb4df36
Use old distortion method by default
paudrow Jun 9, 2021
77bb479
Update distortion to test using real distortion too
paudrow Jun 9, 2021
4a6781f
Apply feedback to distortion implementation
paudrow Jun 10, 2021
bc4fd70
Test new and legacy distortion
paudrow Jun 10, 2021
519e6b4
Remove empty line
paudrow Jun 11, 2021
f230f56
Make new variables constant
paudrow Jun 11, 2021
774bab3
Add a comment about bugfix
paudrow Jun 11, 2021
4fe9c4b
Remove duplication from distort methods
paudrow Jun 11, 2021
406b65e
Revert "Add test for extreme distortion"
paudrow Jun 11, 2021
b70d927
Set distortion crop to false if not using legacy distortion
paudrow Jun 15, 2021
0d4980d
Add warning if distortion crop is enabled with new mode
paudrow Jun 15, 2021
861f8eb
Update SpawnCamera's doc string
paudrow Jun 15, 2021
5de3259
Clean up white space
paudrow Jun 15, 2021
b0b627b
Fix minecart urls
paudrow Jun 15, 2021
fa809d5
Apply feedback
paudrow Jun 16, 2021
4fa5f30
Fix default lambda return
paudrow Jun 17, 2021
d291950
Make lines less than 81 characters
paudrow Jun 17, 2021
1c821cb
Avoid capturing const variables
paudrow Jun 17, 2021
fd01e14
Change static variable to const
paudrow Jun 18, 2021
c31c97e
Fix curly brace location
paudrow Jun 18, 2021
3caa105
Add docstring for _horizontalFov parameter
paudrow Jun 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use old distortion method by default
Signed-off-by: Audrow Nash <audrow@hey.com>
paudrow committed Jun 9, 2021
commit eb4df36c39ac40c9e206d8eae288007532428501
40 changes: 31 additions & 9 deletions gazebo/rendering/Distortion.cc
Original file line number Diff line number Diff line change
@@ -60,6 +60,12 @@ namespace gazebo
/// black pixels at the corners of the image.
public: bool distortionCrop = true;

/// \brief Modifies how Brown's distortion equations are applied to
/// better reflect real distortion. Image is projected from image plane
/// to camera plane to apply distortion equations, then projected back
/// to image plane. Note that this sets distortionCrop to false.
public: bool useRealDistortion = false;

/// \brief Lens distortion compositor
public: Ogre::CompositorInstance *lensDistortionInstance;

@@ -115,13 +121,21 @@ void Distortion::Load(sdf::ElementPtr _sdf)
this->dataPtr->p2 = _sdf->Get<double>("p2");
this->dataPtr->lensCenter = _sdf->Get<ignition::math::Vector2d>("center");

this->dataPtr->distortionCrop = this->dataPtr->k1 < 0;

const std::string compositorName = "ignition:compositor";
if (_sdf->HasElement(compositorName))
{
this->dataPtr->compositorName = _sdf->Get<std::string>(compositorName);
}
const std::string useRealDistortion = "ignition:use_real_distortion";
if (_sdf->HasElement(useRealDistortion))
{
this->dataPtr->useRealDistortion = _sdf->Get<bool>(useRealDistortion);
}
if (this->dataPtr->useRealDistortion) {
this->dataPtr->distortionCrop = false;
} else {
this->dataPtr->distortionCrop = this->dataPtr->k1 < 0;
}
}

//////////////////////////////////////////////////
@@ -204,13 +218,21 @@ void Distortion::SetCamera(CameraPtr _camera)
normalizedLocation[0] = normalizedColLocation;
normalizedLocation[1] = normalizedRowLocation;

distortedLocation = this->Distort(
normalizedLocation,
this->dataPtr->lensCenter,
this->dataPtr->k1, this->dataPtr->k2, this->dataPtr->k3,
this->dataPtr->p1, this->dataPtr->p2,
this->dataPtr->distortionTexWidth,
focalLength);
if (this->dataPtr->useRealDistortion) {
distortedLocation = this->Distort(
normalizedLocation,
this->dataPtr->lensCenter,
this->dataPtr->k1, this->dataPtr->k2, this->dataPtr->k3,
this->dataPtr->p1, this->dataPtr->p2,
this->dataPtr->distortionTexWidth,
focalLength);
} else {
audrow marked this conversation as resolved.
Show resolved Hide resolved
distortedLocation = this->Distort(
normalizedLocation,
this->dataPtr->lensCenter,
this->dataPtr->k1, this->dataPtr->k2, this->dataPtr->k3,
this->dataPtr->p1, this->dataPtr->p2);
}

// compute the index in the distortion map
distortedCol = distortedLocation.X() * this->dataPtr->distortionTexWidth;