Lens distortion
This commit is contained in:
1 parent
d0cec6572e
commit
49e0500007
24 files changed
+1146
-133
No files matched your search
@@ -57,7 +57,7 @@ struct RenderArgs {
|
||||
#[arg(long, default_value = "L0")]
|
||||
lighting: LightingTier,
|
||||
/// Camera fidelity tier: C0, or C1 (adds pixels that collect light over their area,
|
||||
/// for graded edges and continuous thin parts, and lens blur).
|
||||
/// for graded edges and continuous thin parts, lens distortion and lens blur).
|
||||
#[arg(long, default_value = "C0")]
|
||||
camera: CameraTier,
|
||||
/// From camera C1: render each pixel as N x N finer ones (1 to 4; default 2), which
|
||||
|
||||
@@ -10,8 +10,8 @@ use std::path::{Path, PathBuf};
|
||||
use resolved::bodies::Appearance;
|
||||
use resolved::nalgebra::{Quaternion, UnitQuaternion, Vector2, Vector3};
|
||||
use resolved::{
|
||||
CameraConfig, LoadOptions, Material, Mesh, ModelId, Pose, Psf, Renderer, Scene, Spectrum,
|
||||
Target,
|
||||
BrownConrady, CameraConfig, LoadOptions, Material, Mesh, ModelId, Pose, Psf, Renderer, Scene,
|
||||
Spectrum, Target,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -64,6 +64,8 @@ pub struct CameraFile {
|
||||
/// The Gaussian blur's sigma in pixels, from camera C1: one for every channel, one
|
||||
/// per channel, or 0 for none.
|
||||
pub psf_sigma: Option<Sigma>,
|
||||
/// Lens distortion from camera C1, in OpenCV's order: [k1, k2, p1, p2, k3].
|
||||
pub distortion: Option<[f64; 5]>,
|
||||
}
|
||||
|
||||
/// One sigma, or one per channel.
|
||||
@@ -157,6 +159,9 @@ impl SceneFile {
|
||||
if let Some(t) = c.transmission {
|
||||
camera.transmission = Spectrum::constant(t);
|
||||
}
|
||||
if let Some([k1, k2, p1, p2, k3]) = c.distortion {
|
||||
camera.distortion = Some(BrownConrady { k1, k2, k3, p1, p2 });
|
||||
}
|
||||
camera.psf = match &c.psf_sigma {
|
||||
None => camera.psf,
|
||||
Some(Sigma::All(s)) if *s == 0.0 => Psf::None,
|
||||
@@ -410,6 +415,21 @@ mod tests {
|
||||
toml::from_str(&format!("{MINIMAL}\n[camera]\n{line}\n")).unwrap();
|
||||
assert_eq!(file.camera().psf, psf, "{line}");
|
||||
}
|
||||
|
||||
let file: SceneFile = toml::from_str(&format!(
|
||||
"{MINIMAL}\n[camera]\ndistortion = [-0.1, 0.02, 1e-3, -2e-3, 0.005]\n"
|
||||
))
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
file.camera().distortion,
|
||||
Some(BrownConrady {
|
||||
k1: -0.1,
|
||||
k2: 0.02,
|
||||
k3: 0.005,
|
||||
p1: 1e-3,
|
||||
p2: -2e-3,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user