Beispiel #1
0
        // find calibrates camera with collected data found by UFindCharucoBoardCorners method
        unsafe public static UCameraCalibrationData UCalibrateCameraCharuco(int width, int height, CharucoBoardParameters boardParameters, DoubleVectorIntMarshaller allCharucoIds, DoubleVectorPoint2FMarshaller allCharucoCorners)
        {
            MatDoubleMarshaller distCoeffs   = new MatDoubleMarshaller();
            MatDoubleMarshaller cameraMatrix = new MatDoubleMarshaller();

            double reProjectionError = CalibrateCameraCharuco(
                height,
                width,
                boardParameters.squaresW,
                boardParameters.squaresH,
                boardParameters.squareLength,
                boardParameters.markerLength,
                allCharucoIds.NativeDataPointer,
                allCharucoCorners.NativeDataPointer,
                cameraMatrix.NativeDataPointer,
                distCoeffs.NativeDataPointer
                );


            UCameraCalibrationData calibrationData = new UCameraCalibrationData(
                distCoeffs,
                cameraMatrix,
                reProjectionError
                );

            return(calibrationData);
        }
Beispiel #2
0
        // public static UCameraCalibrationData UStaticCalibrateCameraData()
        // {

        //     MatDoubleMarshaller distCoeffs = new MatDoubleMarshaller();
        //     MatDoubleMarshaller cameraMatrix = new MatDoubleMarshaller();

        //     StaticCameraCalibData(
        //         cameraMatrix.NativeDataPointer,
        //         distCoeffs.NativeDataPointer,
        //         true
        //     );

        //     UCameraCalibrationData calibrationData = new UCameraCalibrationData(
        //         distCoeffs,
        //         cameraMatrix
        //     );

        //     return calibrationData;
        // }

        // unsafe public static UCameraCalibrationData UCalibrateCamera(Color32[] texture, int width, int height, DoubleVectorIntMarshaller allCharucoIds, DoubleVectorPoint2FMarshaller allCharucoCorners)
        // {

        //     var watch = System.Diagnostics.Stopwatch.StartNew();

        //     // IntPtr distCoeffs = OpenCVMarshal.CreateMatPointer();
        //     MatDoubleMarshaller distCoeffs = new MatDoubleMarshaller();
        //     // IntPtr cameraMatrix = OpenCVMarshal.CreateMatPointer();
        //     MatDoubleMarshaller cameraMatrix = new MatDoubleMarshaller();

        //     fixed (Color32* texP = texture)
        //     {
        //         CalibrateCamera(
        //             texP,
        //             width,
        //             height,
        //             allCharucoIds.NativeDataPointer,
        //             allCharucoCorners.NativeDataPointer,
        //             cameraMatrix.NativeDataPointer,
        //             distCoeffs.NativeDataPointer
        //         );
        //     }


        //     UCameraCalibrationData calibrationData = new UCameraCalibrationData(
        //         distCoeffs,
        //         cameraMatrix
        //     );

        //     watch.Stop();
        //     var elapsedMs = watch.ElapsedMilliseconds;

        //     return calibrationData;
        // }
        unsafe public static UCameraCalibrationData UCalibrateCameraCharuco(int width, int height, CharucoBoardParameters boardParameters, DoubleVectorIntMarshaller allCharucoIds, DoubleVectorPoint2FMarshaller allCharucoCorners)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();
            // IntPtr distCoeffs = OpenCVMarshal.CreateMatPointer();
            MatDoubleMarshaller distCoeffs = new MatDoubleMarshaller();
            // IntPtr cameraMatrix = OpenCVMarshal.CreateMatPointer();
            MatDoubleMarshaller cameraMatrix = new MatDoubleMarshaller();

            double reProjectionError = CalibrateCameraCharuco(
                height,
                width,
                boardParameters.squaresW,
                boardParameters.squaresH,
                boardParameters.squareLength,
                boardParameters.markerLength,
                allCharucoIds.NativeDataPointer,
                allCharucoCorners.NativeDataPointer,
                cameraMatrix.NativeDataPointer,
                distCoeffs.NativeDataPointer
                );


            UCameraCalibrationData calibrationData = new UCameraCalibrationData(
                distCoeffs,
                cameraMatrix,
                reProjectionError
                );

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            return(calibrationData);
        }