public static UBoardMarkerPoseEstimationData UEstimateBoardMarkerPose(IntPtr markerCorners, int width, int height, ArucoBoardParameters boardParameters, IntPtr markerIds, IntPtr cameraMatrix, IntPtr distCoeffs) { float markerLength = 0.04f; float markerSeparation = 0.01f; int markersX = 4; int markersY = 3; Vec3dMarshaller tvecMarshaller = new Vec3dMarshaller(); Vec3dMarshaller rvecMarshaller = new Vec3dMarshaller(); EstimateArucoBoardPose( boardParameters.markerLength, boardParameters.markerSeperation, boardParameters.squaresW, boardParameters.squaresH, markerCorners, markerIds, cameraMatrix, distCoeffs, rvecMarshaller.NativeDataPointer, tvecMarshaller.NativeDataPointer ); rvecMarshaller.MarshalNativeToManaged(); tvecMarshaller.MarshalNativeToManaged(); UBoardMarkerPoseEstimationData PoseEstimateData = new UBoardMarkerPoseEstimationData( (Vec3d)rvecMarshaller.GetMangedObject(), (Vec3d)tvecMarshaller.GetMangedObject(), rvecMarshaller.NativeDataPointer, tvecMarshaller.NativeDataPointer ); return(PoseEstimateData); }
unsafe public static bool UFindChessboardCorners(Color32[] texture, int width, int height, ArucoBoardParameters boardParameters, IntPtr imagePoints, IntPtr objectPoints) { var watch = System.Diagnostics.Stopwatch.StartNew(); int cornersH = 9; int cornersW = 6; float cornerLength = 0.024f; float cornerSeparation = 0.024f; bool foundBoard = false; IntPtr foundBoardMarkers = CreateBooleanPointer(); fixed(Color32 *texP = texture) { FindChessboardCorners( texP, width, height, boardParameters.squaresW, boardParameters.squaresH, boardParameters.markerLength, boardParameters.markerSeperation, foundBoardMarkers, imagePoints, objectPoints ); } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; if (Marshal.ReadByte(foundBoardMarkers, 0) > 0) { foundBoard = true; } DeleteBooleanPointer(foundBoardMarkers); return(foundBoard); }
public unsafe static UBoardMarkerPoseEstimationDataEuler UEstimateArucoBoardPose(Color32[] texture, int width, int height, ArucoBoardParameters boardParameters, IntPtr cameraMatrix, IntPtr distCoeffs) { float markerLength = 0.04f; float markerSeparation = 0.01f; int markersX = 4; int markersY = 3; Vec3dMarshaller tvecMarshaller = new Vec3dMarshaller(); Vec3dMarshaller rvecMarshaller = new Vec3dMarshaller(); MatDoubleMarshaller eulerAngles = new MatDoubleMarshaller(); fixed(Color32 *texP = texture) { EstimateArucoBoardPoseV2( texP, width, height, boardParameters.markerLength, boardParameters.markerSeperation, boardParameters.squaresW, boardParameters.squaresH, cameraMatrix, distCoeffs, rvecMarshaller.NativeDataPointer, tvecMarshaller.NativeDataPointer, eulerAngles.NativeDataPointer ); } UBoardMarkerPoseEstimationDataEuler PoseEstimateData = new UBoardMarkerPoseEstimationDataEuler( (Vec3d)rvecMarshaller.GetMangedObject(), (Vec3d)tvecMarshaller.GetMangedObject(), (double[][])eulerAngles.GetMangedObject() ); return(PoseEstimateData); }