Added documentation for C# calibration types (#599)

* Added documentation for C# calibration types
This commit is contained in:
Brent Allen 2019-08-06 17:47:06 -07:00 коммит произвёл GitHub
Родитель c82126e3f0
Коммит 2795e354e8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 447 добавлений и 75 удалений

Просмотреть файл

@ -117,7 +117,11 @@ if (K4A_BUILD_DOCS)
find_package(Doxygen 1.8.14 EXACT)
if (DOXYGEN_FOUND)
set(DOXYGEN_MAINPAGE ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/mainpage.md)
set(DOXYGEN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/include/k4a ${CMAKE_CURRENT_SOURCE_DIR}/include/k4arecord ${DOXYGEN_MAINPAGE})
set(DOXYGEN_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/include/k4a
${CMAKE_CURRENT_SOURCE_DIR}/include/k4arecord
${CMAKE_CURRENT_SOURCE_DIR}/src/csharp/sdk
${DOXYGEN_MAINPAGE})
set(DOXYGEN_LAYOUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/DoxygenLayout.xml)
# These variables are used in Doxyfile.in
string(REPLACE ";" " " DOXYGEN_INPUT "${DOXYGEN_SOURCES}")

Просмотреть файл

@ -9,6 +9,7 @@ using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using Microsoft.Azure.Kinect.Sensor;
using Microsoft.Azure.Kinect.Sensor.WPF;
namespace Microsoft.Azure.Kinect.Sensor.Examples.WPFViewer
@ -50,8 +51,8 @@ namespace Microsoft.Azure.Kinect.Sensor.Examples.WPFViewer
CameraFPS = FPS.FPS30,
});
int colorWidth = device.GetCalibration().color_camera_calibration.resolution_width;
int colorHeight = device.GetCalibration().color_camera_calibration.resolution_height;
int colorWidth = device.GetCalibration().ColorCameraCalibration.ResolutionWidth;
int colorHeight = device.GetCalibration().ColorCameraCalibration.ResolutionHeight;
Stopwatch sw = new Stopwatch();
int frameCount = 0;

Просмотреть файл

@ -1,31 +1,109 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.InteropServices;
namespace Microsoft.Azure.Kinect.Sensor
{
/// <summary>
/// Device Calibration.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
[Native.NativeReference("k4a_calibration_t")]
public struct Calibration
public struct Calibration : IEquatable<Calibration>
{
// Struct used for serialization to native SDK
#pragma warning disable CA1051 // Do not declare visible instance fields
/// <summary>
/// Depth camera calibration.
/// </summary>
[MarshalAs(UnmanagedType.Struct)]
public CameraCalibration depth_camera_calibration;
public CameraCalibration DepthCameraCalibration;
/// <summary>
/// Color camera calibration.
/// </summary>
[MarshalAs(UnmanagedType.Struct)]
public CameraCalibration color_camera_calibration;
public CameraCalibration ColorCameraCalibration;
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct,
SizeConst = ((int)(CalibrationDeviceType.Num) * ((int)(CalibrationDeviceType.Num))))]
public Extrinsics[] device_extrinsics;
/// <summary>
/// Extrinsic transformation parameters.
/// </summary>
/// <remarks>
/// The extrinsic parameters allow 3D coordinate conversions between depth camera, color camera, the IMU's gyroscope and accelerometer.
///
/// To transform from a source to a target 3D coordinate system, use the parameters stored under DeviceExtrinsics[source][target].
/// </remarks>
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = (int)CalibrationDeviceType.Num * ((int)CalibrationDeviceType.Num))]
public Extrinsics[] DeviceExtrinsics;
public DepthMode depth_mode;
/// <summary>
/// Depth camera mode for which calibration was obtained.
/// </summary>
public DepthMode DepthMode;
public ColorResolution color_resolution;
/// <summary>
/// Color camera resolution for which calibration was obtained.
/// </summary>
public ColorResolution ColorResolution;
#pragma warning restore CA1051 // Do not declare visible instance fields
public Vector2? TransformTo2D(Vector2 sourcePoint2D,
/// <summary>
/// Compares two Calibrations.
/// </summary>
/// <param name="left">First Calibration to compare.</param>
/// <param name="right">Second Calibration to compare.</param>
/// <returns>True if equal.</returns>
public static bool operator ==(Calibration left, Calibration right)
{
return left.Equals(right);
}
/// <summary>
/// Compares two Calibrations.
/// </summary>
/// <param name="left">First Calibration to compare.</param>
/// <param name="right">Second Calibration to compare.</param>
/// <returns>True if not equal.</returns>
public static bool operator !=(Calibration left, Calibration right)
{
return !(left == right);
}
/// <summary>
/// Get the camera calibration for a device from a raw calibration blob.
/// </summary>
/// <param name="raw">Raw calibration blob obtained from a device or recording.</param>
/// <param name="depthMode">Mode in which depth camera is operated.</param>
/// <param name="colorResolution">Resolution in which the color camera is operated.</param>
/// <returns>Calibration object.</returns>
public static Calibration GetFromRaw(byte[] raw, DepthMode depthMode, ColorResolution colorResolution)
{
Calibration calibration = default;
AzureKinectException.ThrowIfNotSuccess(() => NativeMethods.k4a_calibration_get_from_raw(
raw,
(UIntPtr)raw.Length,
depthMode,
colorResolution,
out calibration));
return calibration;
}
/// <summary>
/// Transform a 2D pixel coordinate with an associated depth value of the source camera into a 2D pixel coordinate of the target camera.
/// </summary>
/// <param name="sourcePoint2D">The 2D pixel <paramref name="sourceCamera"/> coordinates.</param>
/// <param name="sourceDepth">The depth of <paramref name="sourcePoint2D"/> in millimeters.</param>
/// <param name="sourceCamera">The current camera.</param>
/// <param name="targetCamera">The target camera.</param>
/// <returns>The 2D pixel in <paramref name="targetCamera"/> coordinates, or null if the source point is not valid in the target coordinate system.</returns>
public Vector2? TransformTo2D(
Vector2 sourcePoint2D,
float sourceDepth,
CalibrationDeviceType sourceCamera,
CalibrationDeviceType targetCamera)
@ -45,6 +123,14 @@ namespace Microsoft.Azure.Kinect.Sensor
}
}
/// <summary>
/// Transform a 2D pixel coordinate with an associated depth value of the source camera into a 3D point of the target coordinate system.
/// </summary>
/// <param name="sourcePoint2D">The 2D pixel in <paramref name="sourceCamera"/> coordinates.</param>
/// <param name="sourceDepth">The depth of <paramref name="sourceCamera"/> in millimeters.</param>
/// <param name="sourceCamera">The current camera.</param>
/// <param name="targetCamera">The target camera.</param>
/// <returns>The 3D coordinate of the input pixel in the coordinate system of <paramref name="targetCamera"/> in millimeters or null if the input point is not valid in that coordinate system.</returns>
public Vector3? TransformTo3D(Vector2 sourcePoint2D, float sourceDepth, CalibrationDeviceType sourceCamera, CalibrationDeviceType targetCamera)
{
using (LoggingTracer tracer = new LoggingTracer())
@ -62,6 +148,13 @@ namespace Microsoft.Azure.Kinect.Sensor
}
}
/// <summary>
/// Transform a 3D point of a source coordinate system into a 2D pixel coordinate of the target camera.
/// </summary>
/// <param name="sourcePoint3D">The 3D coordinate in millimeters representing a point in <paramref name="sourceCamera"/> coordinate system.</param>
/// <param name="sourceCamera">The current camera.</param>
/// <param name="targetCamera">The target camera.</param>
/// <returns>The 2D pixel coordinate in <paramref name="targetCamera"/> coordinates or null if the point is not valid in that coordinate system.</returns>
public Vector2? TransformTo2D(Vector3 sourcePoint3D, CalibrationDeviceType sourceCamera, CalibrationDeviceType targetCamera)
{
using (LoggingTracer tracer = new LoggingTracer())
@ -78,6 +171,13 @@ namespace Microsoft.Azure.Kinect.Sensor
}
}
/// <summary>
/// Transform a 3D point of a source coordinate system into a 3D point of the target coordinate system.
/// </summary>
/// <param name="sourcePoint3D">The 3D coordinates in millimeters representing a point in <paramref name="sourceCamera"/>.</param>
/// <param name="sourceCamera">The current camera.</param>
/// <param name="targetCamera">The target camera.</param>
/// <returns>A point in 3D coordiantes of <paramref name="targetCamera"/> stored in millimeters.</returns>
public Vector3? TransformTo3D(Vector3 sourcePoint3D, CalibrationDeviceType sourceCamera, CalibrationDeviceType targetCamera)
{
using (LoggingTracer tracer = new LoggingTracer())
@ -93,22 +193,41 @@ namespace Microsoft.Azure.Kinect.Sensor
}
}
public static Calibration GetFromRaw(byte[] raw, DepthMode depthMode, ColorResolution colorResolution)
{
Calibration calibration = default;
AzureKinectException.ThrowIfNotSuccess(() => NativeMethods.k4a_calibration_get_from_raw(
raw,
(UIntPtr)raw.Length,
depthMode,
colorResolution,
out calibration));
return calibration;
}
/// <summary>
/// Creates a Transformation object from this calibration.
/// </summary>
/// <returns>A new Transformation object.</returns>
public Transformation CreateTransformation()
{
return new Transformation(this);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj is Calibration calibration && this.Equals(calibration);
}
/// <inheritdoc/>
public bool Equals(Calibration other)
{
return this.DepthCameraCalibration.Equals(other.DepthCameraCalibration) &&
this.ColorCameraCalibration.Equals(other.ColorCameraCalibration) &&
EqualityComparer<Extrinsics[]>.Default.Equals(this.DeviceExtrinsics, other.DeviceExtrinsics) &&
this.DepthMode == other.DepthMode &&
this.ColorResolution == other.ColorResolution;
}
/// <inheritdoc/>
public override int GetHashCode()
{
var hashCode = -454809512;
hashCode = (hashCode * -1521134295) + EqualityComparer<CameraCalibration>.Default.GetHashCode(this.DepthCameraCalibration);
hashCode = (hashCode * -1521134295) + EqualityComparer<CameraCalibration>.Default.GetHashCode(this.ColorCameraCalibration);
hashCode = (hashCode * -1521134295) + EqualityComparer<Extrinsics[]>.Default.GetHashCode(this.DeviceExtrinsics);
hashCode = (hashCode * -1521134295) + this.DepthMode.GetHashCode();
hashCode = (hashCode * -1521134295) + this.ColorResolution.GetHashCode();
return hashCode;
}
}
}

Просмотреть файл

@ -6,20 +6,46 @@ using System.Runtime.InteropServices;
namespace Microsoft.Azure.Kinect.Sensor
{
/// <summary>
/// Specifies a type of calibration.
/// </summary>
[Native.NativeReference("k4a_calibration_type_t")]
public enum CalibrationDeviceType
{
/// <summary>
/// Calibration type is unknown.
/// </summary>
[Native.NativeReference("K4A_CALIBRATION_TYPE_UNKNOWN")]
Unknown = -1,
/// <summary>
/// Depth sensor.
/// </summary>
[Native.NativeReference("K4A_CALIBRATION_TYPE_DEPTH")]
Depth,
/// <summary>
/// Color sensor.
/// </summary>
[Native.NativeReference("K4A_CALIBRATION_TYPE_COLOR")]
Color,
/// <summary>
/// Gyroscope sensor.
/// </summary>
[Native.NativeReference("K4A_CALIBRATION_TYPE_GYRO")]
Gyro,
/// <summary>
/// Accelerometer sensor.
/// </summary>
[Native.NativeReference("K4A_CALIBRATION_TYPE_ACCEL")]
Accel,
/// <summary>
/// Number of types excluding unknown type.
/// </summary>
[Native.NativeReference("K4A_CALIBRATION_TYPE_NUM")]
Num
Num,
}
}

Просмотреть файл

@ -6,18 +6,40 @@ using System.Runtime.InteropServices;
namespace Microsoft.Azure.Kinect.Sensor
{
/// <summary>
/// The model used to interpret the calibration parameters.
/// </summary>
[Native.NativeReference("k4a_calibration_model_type_t")]
public enum CalibrationModelType
{
/// <summary>
/// Calibration model is unknown.
/// </summary>
[Native.NativeReference("K4A_CALIBRATION_LENS_DISTORTION_MODEL_UNKNOWN")]
Unknown = 0,
/// <summary>
/// Calibration model is Theta (arctan).
/// </summary>
[Native.NativeReference("K4A_CALIBRATION_LENS_DISTORTION_MODEL_THETA")]
Theta,
/// <summary>
/// Calibration model is Polynomial 3K.
/// </summary>
[Native.NativeReference("K4A_CALIBRATION_LENS_DISTORTION_MODEL_POLYNOMIAL_3K")]
Polynomial3K,
/// <summary>
/// Calibration model is Rational 6KT.
/// </summary>
[Native.NativeReference("K4A_CALIBRATION_LENS_DISTORTION_MODEL_RATIONAL_6KT")]
Rational6KT,
/// <summary>
/// Calibration model is Brown Conrady.
/// </summary>
[Native.NativeReference("K4A_CALIBRATION_LENS_DISTORTION_MODEL_BROWN_CONRADY")]
BrownConrady
BrownConrady,
}
}

Просмотреть файл

@ -1,22 +1,98 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.InteropServices;
namespace Microsoft.Azure.Kinect.Sensor
{
/// <summary>
/// Camera calibration contains intrinsic and extrinsic calibration information for a camera.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct CameraCalibration
public struct CameraCalibration : IEquatable<CameraCalibration>
{
[MarshalAs(UnmanagedType.Struct)]
public Extrinsics extrinsics;
// Struct used for serialization to native SDK
#pragma warning disable CA1051 // Do not declare visible instance fields
/// <summary>
/// Extrinsic calibration data.
/// </summary>
[MarshalAs(UnmanagedType.Struct)]
public Intrinsics intrinsics;
public Extrinsics Extrinsics;
public int resolution_width;
public int resolution_height;
public float metric_radius;
/// <summary>
/// Intrinsic calibration data.
/// </summary>
[MarshalAs(UnmanagedType.Struct)]
public Intrinsics Intrinsics;
/// <summary>
/// Resolution width of the camera sensor.
/// </summary>
public int ResolutionWidth;
/// <summary>
/// Resolution height of the camera sensor.
/// </summary>
public int ResolutionHeight;
/// <summary>
/// Maximum FOV of the camera.
/// </summary>
public float MetricRadius;
#pragma warning restore CA1051 // Do not declare visible instance fields
/// <summary>
/// Compare two CameraCalibrations for equality.
/// </summary>
/// <param name="left">First CameraCalibration to compare.</param>
/// <param name="right">Second CameraCalibration to compare.</param>
/// <returns>True if equal.</returns>
public static bool operator ==(CameraCalibration left, CameraCalibration right)
{
return left.Equals(right);
}
/// <summary>
/// Compare two CameraCalibrations for inequality.
/// </summary>
/// <param name="left">First CameraCalibration to compare.</param>
/// <param name="right">Second CameraCalibration to compare.</param>
/// <returns>True if not equal.</returns>
public static bool operator !=(CameraCalibration left, CameraCalibration right)
{
return !(left == right);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj is CameraCalibration calibration && this.Equals(calibration);
}
/// <inheritdoc/>
public bool Equals(CameraCalibration other)
{
return this.Extrinsics.Equals(other.Extrinsics) &&
this.Intrinsics.Equals(other.Intrinsics) &&
this.ResolutionWidth == other.ResolutionWidth &&
this.ResolutionHeight == other.ResolutionHeight &&
this.MetricRadius == other.MetricRadius;
}
/// <inheritdoc/>
public override int GetHashCode()
{
var hashCode = 2125552744;
hashCode = (hashCode * -1521134295) + EqualityComparer<Extrinsics>.Default.GetHashCode(this.Extrinsics);
hashCode = (hashCode * -1521134295) + EqualityComparer<Intrinsics>.Default.GetHashCode(this.Intrinsics);
hashCode = (hashCode * -1521134295) + this.ResolutionWidth.GetHashCode();
hashCode = (hashCode * -1521134295) + this.ResolutionHeight.GetHashCode();
hashCode = (hashCode * -1521134295) + this.MetricRadius.GetHashCode();
return hashCode;
}
}
}

Просмотреть файл

@ -1,18 +1,79 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Linq;
namespace Microsoft.Azure.Kinect.Sensor
{
/// <summary>
/// Extrinsic calibration data.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct Extrinsics
public struct Extrinsics : IEquatable<Extrinsics>
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
public float[] rotation;
// Struct used for serialization to native SDK
#pragma warning disable CA1051 // Do not declare visible instance fields
/// <summary>
/// Gets 3x3 Rotation matrix stored in row major order.
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
public float[] Rotation;
/// <summary>
/// Gets translation vector, x,yz (in millimeters).
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public float[] translation;
public float[] Translation;
#pragma warning restore CA1051 // Do not declare visible instance fields
/// <summary>
/// Compares two Extrinsics for equality.
/// </summary>
/// <param name="left">First extrinsic to compare.</param>
/// <param name="right">Second extrinsic to compare.</param>
/// <returns>True if equal.</returns>
public static bool operator ==(Extrinsics left, Extrinsics right)
{
return left.Equals(right);
}
/// <summary>
/// Compares two Extrinsics for inequality.
/// </summary>
/// <param name="left">First extrinsic to compare.</param>
/// <param name="right">Second extrinsic to compare.</param>
/// <returns>True if not equal.</returns>
public static bool operator !=(Extrinsics left, Extrinsics right)
{
return !(left == right);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj is Extrinsics extrinsics && this.Equals(extrinsics);
}
/// <inheritdoc/>
public bool Equals(Extrinsics other)
{
return EqualityComparer<float[]>.Default.Equals(this.Rotation, other.Rotation) &&
EqualityComparer<float[]>.Default.Equals(this.Translation, other.Translation);
}
/// <inheritdoc/>
public override int GetHashCode()
{
var hashCode = 1370020195;
hashCode = (hashCode * -1521134295) + EqualityComparer<float[]>.Default.GetHashCode(this.Rotation);
hashCode = (hashCode * -1521134295) + EqualityComparer<float[]>.Default.GetHashCode(this.Translation);
return hashCode;
}
}
}

Просмотреть файл

@ -1,19 +1,82 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Numerics;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace Microsoft.Azure.Kinect.Sensor
{
/// <summary>
/// Camera sensor intrinsic calibration data.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct Intrinsics
public struct Intrinsics : IEquatable<Intrinsics>
{
public CalibrationModelType type;
// Struct used for serialization to native SDK
#pragma warning disable CA1051 // Do not declare visible instance fields
public int parameter_count;
/// <summary>
/// Type of calibration model used.
/// </summary>
public CalibrationModelType Type;
/// <summary>
/// Number of valid entries in parameters.
/// </summary>
public int ParameterCount;
/// <summary>
/// Calibration parameters.
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
public float[] parameters;
public float[] Parameters;
#pragma warning restore CA1051 // Do not declare visible instance fields
/// <summary>
/// Compare two Intrinsics for equality.
/// </summary>
/// <param name="left">First intrinsic to compare.</param>
/// <param name="right">Second intrinsic to compare.</param>
/// <returns>True if equal.</returns>
public static bool operator ==(Intrinsics left, Intrinsics right)
{
return left.Equals(right);
}
/// <summary>
/// Compare two Intrinsics for inequality.
/// </summary>
/// <param name="left">First intrinsic to compare.</param>
/// <param name="right">Second intrinsic to compare.</param>
/// <returns>True if not equal.</returns>
public static bool operator !=(Intrinsics left, Intrinsics right)
{
return !(left == right);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj is Intrinsics intrinsics && this.Equals(intrinsics);
}
/// <inheritdoc/>
public bool Equals(Intrinsics other)
{
return this.Type == other.Type &&
this.ParameterCount == other.ParameterCount &&
EqualityComparer<float[]>.Default.Equals(this.Parameters, other.Parameters);
}
/// <inheritdoc/>
public override int GetHashCode()
{
int hashCode = -426656627;
hashCode = (hashCode * -1521134295) + this.Type.GetHashCode();
hashCode = (hashCode * -1521134295) + this.ParameterCount.GetHashCode();
hashCode = (hashCode * -1521134295) + EqualityComparer<float[]>.Default.GetHashCode(this.Parameters);
return hashCode;
}
}
}

Просмотреть файл

@ -60,8 +60,8 @@ namespace Microsoft.Azure.Kinect.Sensor
Image image = new Image(
ImageFormat.Depth16,
this.calibration.color_camera_calibration.resolution_width,
this.calibration.color_camera_calibration.resolution_height)
this.calibration.ColorCameraCalibration.ResolutionWidth,
this.calibration.ColorCameraCalibration.ResolutionHeight)
{
DeviceTimestamp = depth.DeviceTimestamp,
};
@ -177,8 +177,8 @@ namespace Microsoft.Azure.Kinect.Sensor
Image transformed = new Image(
ImageFormat.ColorBGRA32,
this.calibration.depth_camera_calibration.resolution_width,
this.calibration.depth_camera_calibration.resolution_height)
this.calibration.DepthCameraCalibration.ResolutionWidth,
this.calibration.DepthCameraCalibration.ResolutionHeight)
{
Exposure = color.Exposure,
ISOSpeed = color.ISOSpeed,

Просмотреть файл

@ -16,16 +16,16 @@ namespace WrapperTests
int depthWidth, int depthHeight,
int colorWidth, int colorHeight)
{
Assert.AreEqual(depthMode, cal.depth_mode);
Assert.AreEqual(colorResolution, cal.color_resolution);
Assert.AreEqual(depthWidth, cal.depth_camera_calibration.resolution_width);
Assert.AreEqual(depthHeight, cal.depth_camera_calibration.resolution_height);
Assert.AreEqual(colorWidth, cal.color_camera_calibration.resolution_width);
Assert.AreEqual(colorHeight, cal.color_camera_calibration.resolution_height);
Assert.IsTrue(cal.depth_camera_calibration.intrinsics.type == CalibrationModelType.Rational6KT ||
cal.depth_camera_calibration.intrinsics.type == CalibrationModelType.BrownConrady);
Assert.IsTrue(cal.color_camera_calibration.intrinsics.type == CalibrationModelType.Rational6KT ||
cal.color_camera_calibration.intrinsics.type == CalibrationModelType.BrownConrady);
Assert.AreEqual(depthMode, cal.DepthMode);
Assert.AreEqual(colorResolution, cal.ColorResolution);
Assert.AreEqual(depthWidth, cal.DepthCameraCalibration.ResolutionWidth);
Assert.AreEqual(depthHeight, cal.DepthCameraCalibration.ResolutionHeight);
Assert.AreEqual(colorWidth, cal.ColorCameraCalibration.ResolutionWidth);
Assert.AreEqual(colorHeight, cal.ColorCameraCalibration.ResolutionHeight);
Assert.IsTrue(cal.DepthCameraCalibration.Intrinsics.Type == CalibrationModelType.Rational6KT ||
cal.DepthCameraCalibration.Intrinsics.Type == CalibrationModelType.BrownConrady);
Assert.IsTrue(cal.ColorCameraCalibration.Intrinsics.Type == CalibrationModelType.Rational6KT ||
cal.ColorCameraCalibration.Intrinsics.Type == CalibrationModelType.BrownConrady);
}
[Test]

Просмотреть файл

@ -496,32 +496,32 @@ k4a_result_t k4a_device_get_calibration(k4a_device_t device_handle, k4a_depth_mo
Assert.AreEqual(1, count.Calls("k4a_device_get_calibration"));
Assert.AreEqual(DepthMode.NFOV_Unbinned, calibration.depth_mode);
Assert.AreEqual(ColorResolution.R1440p, calibration.color_resolution);
Assert.AreEqual(DepthMode.NFOV_Unbinned, calibration.DepthMode);
Assert.AreEqual(ColorResolution.R1440p, calibration.ColorResolution);
for (int i = 0; i < 9; i++)
{
Assert.AreEqual(i * 1.2f, calibration.depth_camera_calibration.extrinsics.rotation[i]);
Assert.AreEqual(i * 1.2f, calibration.DepthCameraCalibration.Extrinsics.Rotation[i]);
}
for (int i = 0; i < 3; i++)
{
Assert.AreEqual(i * 1.3f, calibration.depth_camera_calibration.extrinsics.translation[i]);
Assert.AreEqual(i * 1.3f, calibration.DepthCameraCalibration.Extrinsics.Translation[i]);
}
Assert.AreEqual(81, calibration.depth_camera_calibration.intrinsics.parameter_count);
Assert.AreEqual(CalibrationModelType.BrownConrady, calibration.depth_camera_calibration.intrinsics.type);
Assert.AreEqual(81, calibration.DepthCameraCalibration.Intrinsics.ParameterCount);
Assert.AreEqual(CalibrationModelType.BrownConrady, calibration.DepthCameraCalibration.Intrinsics.Type);
for (int i = 0; i < calibration.depth_camera_calibration.intrinsics.parameters.Length; i++)
for (int i = 0; i < calibration.DepthCameraCalibration.Intrinsics.Parameters.Length; i++)
{
Assert.AreEqual(i * 1.4f, calibration.depth_camera_calibration.intrinsics.parameters[i]);
Assert.AreEqual(i * 1.4f, calibration.DepthCameraCalibration.Intrinsics.Parameters[i]);
}
Assert.AreEqual(91, calibration.depth_camera_calibration.resolution_width);
Assert.AreEqual(92, calibration.depth_camera_calibration.resolution_height);
Assert.AreEqual(1.23f, calibration.depth_camera_calibration.metric_radius);
Assert.AreEqual(91, calibration.DepthCameraCalibration.ResolutionWidth);
Assert.AreEqual(92, calibration.DepthCameraCalibration.ResolutionHeight);
Assert.AreEqual(1.23f, calibration.DepthCameraCalibration.MetricRadius);
Assert.AreEqual(101, calibration.color_camera_calibration.resolution_width);
Assert.AreEqual(102, calibration.color_camera_calibration.resolution_height);
Assert.AreEqual(4.56f, calibration.color_camera_calibration.metric_radius);
Assert.AreEqual(101, calibration.ColorCameraCalibration.ResolutionWidth);
Assert.AreEqual(102, calibration.ColorCameraCalibration.ResolutionHeight);
Assert.AreEqual(4.56f, calibration.ColorCameraCalibration.MetricRadius);
// GetCalibration with no arguments will throw if the device is not yet started