1using System.Collections;
2using System.Globalization;
118 double[] radialDistortion,
119 double[] tangentialDistortion,
120 double[] prismDistortion)
150 double[] radialDistortion,
151 double[] tangentialDistortion,
152 double[] prismDistortion,
153 double[] tiltDistortion)
167 RadialDistortion = Utils.FromFixedArray(distortionCoefficients.radial_distortion.coefficients,
170 distortionCoefficients.tangential_distortion.coefficients,
172 PrismDistortion = Utils.FromFixedArray(distortionCoefficients.prism_distortion.coefficients,
174 TiltDistortion = Utils.FromFixedArray(distortionCoefficients.tilt_distortion.coefficients,
209 if (ReferenceEquals(other,
null))
return false;
220 public override bool Equals(
object? other)
222 if (other is
null)
return false;
223 if (ReferenceEquals(
this, other))
return true;
234 StructuralComparisons.StructuralEqualityComparer.GetHashCode(
RadialDistortion),
236 StructuralComparisons.StructuralEqualityComparer.GetHashCode(
PrismDistortion),
237 StructuralComparisons.StructuralEqualityComparer.GetHashCode(
TiltDistortion)).GetHashCode();
251 string FormatDistortion(
double[] distortionArray)
253 return "(" +
string.Join(
", ",
254 distortionArray.Select(d => d.ToString(
"0.0", CultureInfo.InvariantCulture))) +
")";
258 internal Backend.Types.peak_icv_distortion_coefficients ToCType()
262 var result =
new Backend.Types.peak_icv_distortion_coefficients();
264 Utils.ToFixedArray(
RadialDistortion, result.radial_distortion.coefficients);
266 Utils.ToFixedArray(
PrismDistortion, result.prism_distortion.coefficients);
267 Utils.ToFixedArray(
TiltDistortion, result.tilt_distortion.coefficients);
273 private static void ValidateArraySizes(
274 double[] radialDistortion,
275 double[] tangentialDistortion,
276 double[] prismDistortion,
277 double[] tiltDistortion)
285 void ValidateSize(
double[] distortionArray,
int maxSize,
string name)
287 if (distortionArray.Length > maxSize)
290 $
"The given {name} array size is incorrect. Expected to be smaller than or equal to size: {maxSize}, but got: {distortionArray.Length}.");
Holds lens distortion coefficients.
const int RadialDistortionMaxElements
Maximum number of radial distortion coefficients.
const int PrismDistortionMaxElements
Maximum number of prism distortion coefficients.
override bool Equals(object? other)
Compares the distortion coefficients by value.
DistortionCoefficients(double[] radialDistortion, double[] tangentialDistortion, double[] prismDistortion)
Creates distortion coefficients from radial, tangential and prism distortion coefficients.
double[] RadialDistortion
Provides the radial distortion.
double[] TangentialDistortion
Provides the tangential distortion.
override int GetHashCode()
Generates a hash code from the coefficients.
double[] PrismDistortion
Provides the prism distortion.
bool Equals(DistortionCoefficients? other)
Compares the distortion coefficients by value.
override string ToString()
Returns a string representation of the distortion coefficients.
DistortionCoefficients(double[] radialDistortion, double[] tangentialDistortion)
Creates distortion coefficients from radial and tangential distortion coefficients.
DistortionCoefficients(double[] radialDistortion, double[] tangentialDistortion, double[] prismDistortion, double[] tiltDistortion)
Creates distortion coefficients from radial, tangential, prism and tilt distortion coefficients.
const int TangentialDistortionMaxElements
Maximum number of tangential distortion coefficients.
double[] TiltDistortion
Provides the tilt distortion.
const int TiltDistortionMaxElements
Maximum number of tilt distortion coefficients.
Occurs when an operation cannot be performed due to logical constraints (e.g., camera calibration wit...