Matlab立体相机校准器到C#.NET

时间:2016-05-13 21:45:22

标签: c# matlab camera-calibration

Matlab侧校准功能还可以,效果很好。 我通过deploytool制作DLL包括这个功能。 此功能返回摄像机校准信息。

function [ result ] = Calibrate()
imageFileNames1 = {'D:\left\l1.png',...
    'D:\left\l10.png',...
    'D:\left\l2.png',...
    'D:\left\l3.png',...
    'D:\left\l4.png',...
    'D:\left\l5.png',...
    'D:\left\l6.png',...
    'D:\left\l7.png',...
    'D:\left\l8.png',...
    'D:\left\l9.png',...
    };
imageFileNames2 = {'D:\right\r1.png',...
    'D:\right\r10.png',...
    'D:\right\r2.png',...
    'D:\right\r3.png',...
    'D:\right\r4.png',...
    'D:\right\r5.png',...
    'D:\right\r6.png',...
    'D:\right\r7.png',...
    'D:\right\r8.png',...
    'D:\right\r9.png',...
    };
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames1, imageFileNames2);
squareSize = 25;
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
[stereoParams, pairsUsed, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, ...
    'EstimateSkew', false, 'EstimateTangentialDistortion', false, ...
    'NumRadialDistortionCoefficients', 2, 'WorldUnits', 'mm');
result=stereoParams;
end

C#Side:

using StereoCameraCalibrator2;
using MathWorks.MATLAB.NET.Arrays;
using MathWorks.MATLAB.NET.Utility;

private void button2_Click(object sender, EventArgs e)
        {
            try
            {

                CalibrateAPI2 calibrate2 = new CalibrateAPI2(); 
                MWArray result =    calibrate2.Calibrate(); // this returns null all ways

            }
            catch (Exception err)
            {

                Debug.WriteLine(err.Message);
            }
        }

为什么返回null? 另一个样本正常工作,例如rgb到图像转换。但校准不起作用。我该怎么解决这个问题呢。

0 个答案:

没有答案