28 internal readonly Handle _handle;
50 var handle =
new Handle(filePath);
93 var calibrationParameters =
new Backend.Types.peak_icv_calibration_parameters();
95 DllHelper.ExecuteAndMapReturnCodes(() => CInterface.peak_icv_Calibration_Result_ToParameters(
96 _handle, out calibrationParameters,
97 (nuint) Marshal.SizeOf<Backend.Types.peak_icv_calibration_parameters>()));
116 var meanReprojectionError = 0.0;
117 DllHelper.ExecuteAndMapReturnCodes(() =>
118 CInterface.peak_icv_Calibration_Result_GetMeanReprojectionError(
119 _handle, out meanReprojectionError));
120 return meanReprojectionError;
137 DllHelper.ExecuteAndMapReturnCodes(() =>
138 CInterface.peak_icv_Calibration_Result_GetCalibrationViews_GetCount(
139 _handle, out numViews));
146 var viewHandles =
new IntPtr[numViews];
147 DllHelper.ExecuteAndMapReturnCodes(() =>
148 CInterface.peak_icv_Calibration_View_Array_Create(viewHandles, numViews));
152 DllHelper.ExecuteAndMapReturnCodes(() =>
153 CInterface.peak_icv_Calibration_Result_GetCalibrationViews(_handle, viewHandles, numViews));
161 CInterface.peak_icv_Calibration_View_Array_Destroy(viewHandles, numViews);
174 GC.SuppressFinalize(
this);
177 SafeHandle IHasSafeHandle.Handle => _handle;
195 internal sealed class Handle : SafeHandleZeroOrMinusOneIsInvalid
197 internal Handle() : base(true)
199 DllHelper.ExecuteAndMapReturnCodes(() =>
200 CInterface.peak_icv_Calibration_Result_Create(out handle));
203 internal Handle(
string filePath) : base(true)
205 DllHelper.ExecuteAndMapReturnCodes(() =>
206 CInterface.peak_icv_Calibration_Result_CreateFromFile(out handle,
207 Utils.ToUtf8(filePath)));
210 protected override bool ReleaseHandle()
212 return CInterface.peak_icv_Calibration_Result_Destroy(handle) ==
213 Backend.Types.peak_icv_status.PEAK_ICV_STATUS_SUCCESS;
217 private static class CInterface
219 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
220 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_Result_Create(
223 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
224 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_Result_CreateFromFile(
228 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
229 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_Result_Destroy(
232 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
233 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_Result_GetMeanReprojectionError(
234 Handle handle, out
double meanReprojectionError);
236 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
237 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_Result_ToParameters(
238 Handle handle, out Backend.Types.peak_icv_calibration_parameters calibration_parameters,
239 nuint size_of_calibration_parameters);
241 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
242 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_Result_GetCalibrationViews_GetCount(
243 Handle handle, out nuint calibration_view_count);
245 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
246 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_Result_GetCalibrationViews(
247 Handle handle, IntPtr[] calibration_view_handle, nuint calibration_view_count);
249 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
250 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_View_Array_Create(
251 IntPtr[] handle, nuint calibration_view_count);
253 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
254 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_View_Array_Destroy(
255 IntPtr[] handle, nuint calibration_view_count);