IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
CalibrationView.cs
Go to the documentation of this file.
1using System.Runtime.InteropServices;
4using Microsoft.Win32.SafeHandles;
5
7
28public class CalibrationView : IDisposable, IHasSafeHandle
29{
30 private readonly Handle _handle;
31
32 internal CalibrationView(Handle handle)
33 {
34 _handle = handle;
35 }
36
37 internal CalibrationView()
38 {
39 _handle = new Handle();
40 }
41
56 {
57 get
58 {
59 nuint numReprojectionErrors = 0;
60 DllHelper.ExecuteAndMapReturnCodes(() =>
61 CInterface.peak_icv_Calibration_View_GetReprojectionErrors_GetCount(
62 _handle, out numReprojectionErrors));
63
64 if (numReprojectionErrors == 0)
65 {
66 return Array.Empty<ReprojectionError>();
67 }
68
69 var cReprojectionErrors = new Backend.Types.peak_icv_reprojection_error[numReprojectionErrors];
70
71 DllHelper.ExecuteAndMapReturnCodes(() =>
72 CInterface.peak_icv_Calibration_View_GetReprojectionErrors(_handle,
73 cReprojectionErrors,
74 numReprojectionErrors));
75 return cReprojectionErrors.Select(cReprojectionError => new ReprojectionError(cReprojectionError))
76 .ToArray();
77 }
78 }
79
90 {
91 get
92 {
93 double cMeanReprojectionError = 0;
94 DllHelper.ExecuteAndMapReturnCodes(() =>
95 CInterface.peak_icv_Calibration_View_GetMeanReprojectionError(
96 _handle, out cMeanReprojectionError));
97 return cMeanReprojectionError;
98 }
99 }
100
106 {
107 get
108 {
109 double cMaxReprojectionError = 0;
110 DllHelper.ExecuteAndMapReturnCodes(() =>
111 CInterface.peak_icv_Calibration_View_GetMaximumReprojectionError(
112 _handle, out cMaxReprojectionError));
113 return cMaxReprojectionError;
114 }
115 }
116
132 {
133 get
134 {
135 var cCoordinateSystem = new Backend.Types.peak_icv_coordinate_system();
136 DllHelper.ExecuteAndMapReturnCodes(() =>
137 CInterface.peak_icv_Calibration_View_GetCoordinateSystem(_handle, out cCoordinateSystem));
138 return new CoordinateSystem(cCoordinateSystem);
139 }
140 }
141
153 {
154 get
155 {
156 var cExtrinsicParameters = new Backend.Types.peak_icv_extrinsic_parameters();
157 DllHelper.ExecuteAndMapReturnCodes(() => CInterface.peak_icv_Calibration_View_GetExtrinsicParameters(
158 _handle, out cExtrinsicParameters,
159 (nuint) Marshal.SizeOf(cExtrinsicParameters)));
160 return new ExtrinsicParameters(cExtrinsicParameters);
161 }
162 }
163
174 {
175 get
176 {
177 var handle = new PolygonF.Handle();
178 DllHelper.ExecuteAndMapReturnCodes(() =>
179 CInterface.peak_icv_Calibration_View_GetConvexHull(_handle, out handle));
180 return new PolygonF(handle);
181 }
182 }
183
188 public void Dispose()
189 {
190 _handle.Dispose();
191 GC.SuppressFinalize(this);
192 }
193
194 SafeHandle IHasSafeHandle.Handle => _handle;
195
196 internal sealed class Handle : SafeHandleZeroOrMinusOneIsInvalid
197 {
198 internal Handle() : base(true)
199 {
200 DllHelper.ExecuteAndMapReturnCodes(() => CInterface.peak_icv_Calibration_View_Create(out handle));
201 }
202
206 internal Handle(IntPtr handle) : base(true)
207 {
208 SetHandle(handle);
209 }
210
211 protected override bool ReleaseHandle()
212 {
213 return CInterface.peak_icv_Calibration_View_Destroy(handle) ==
214 Backend.Types.peak_icv_status.PEAK_ICV_STATUS_SUCCESS;
215 }
216 }
217
218 private static class CInterface
219 {
220 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
221 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_View_Create(
222 out IntPtr calibration_view_handle);
223
224 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
225 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_View_Destroy(
226 IntPtr calibration_view_handle);
227
228 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
229 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_View_GetExtrinsicParameters(
230 Handle calibration_view_handle, out Backend.Types.peak_icv_extrinsic_parameters extrinsic_parameters,
231 nuint extrinsic_parameters_size);
232
233 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
234 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_View_GetCoordinateSystem(
235 Handle calibration_view_handle, out Backend.Types.peak_icv_coordinate_system coordinate_system);
236
237 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
238 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_View_GetReprojectionErrors_GetCount(
239 Handle calibration_view_handle, out nuint num_reprojection_errors);
240
241 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
242 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_View_GetReprojectionErrors(
243 Handle calibration_view_handle, [Out] Backend.Types.peak_icv_reprojection_error[] reprojection_errors,
244 nuint num_reprojection_errors);
245
246 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
247 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_View_GetMeanReprojectionError(
248 Handle calibration_view_handle, out double mean_reprojection_error);
249
250 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
251 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_View_GetMaximumReprojectionError(
252 Handle calibration_view_handle, out double max_reprojection_error);
253
254 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
255 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_View_GetConvexHull(
256 Handle calibration_view_handle, out PolygonF.Handle polygon_handle);
257 }
258}
Represents a single observation of a calibration plate in an image.
double MeanReprojectionError
Provides the mean reprojection error from a calibration view.
CoordinateSystem CoordinateSystem
Provides the coordinate system of the calibration view that was projected into the image plane.
ReprojectionError[] ReprojectionErrors
Provides the reprojection errors for every marker in the view.
void Dispose()
Releases the resources used by the CalibrationView class.
double MaxReprojectionError
Provides the maximum reprojection error from a calibration view.
ExtrinsicParameters ExtrinsicParameters
Provides the extrinsic parameters for the view.
PolygonF ConvexHull
Provides the convex hull of the found calibration plate in the view.
Represents the extrinsic parameters for camera calibration, including rotation, translation and the t...
Represents the reprojection error for a marker point in the image.
Represents the coordinate system of a calibration view projected into the image plane.
A polygon is a two-dimensional geometric shape that is made up of a finite number of straight line se...
Definition PolygonF.cs:18