Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Emgu发现变压器_C#_Opencv_Emgucv - Fatal编程技术网

C#Emgu发现变压器

C#Emgu发现变压器,c#,opencv,emgucv,C#,Opencv,Emgucv,我正在尝试在emgu C#中测试FindTransformECC函数。它基于这篇文章: 我的代码是: public static Mat AlignImage(Mat sourceimage, Mat template, int iterations, double eps, MotionType _motionType = MotionType.Euclidean) { float[,,] warp_matrix_temp = new float[2, 3, 1

我正在尝试在emgu C#中测试FindTransformECC函数。它基于这篇文章:

我的代码是:

    public static Mat AlignImage(Mat sourceimage, Mat template, int iterations, double eps, MotionType _motionType = MotionType.Euclidean)
    {
        float[,,] warp_matrix_temp = new float[2, 3, 1];
        float[,] warp_matrix = new float[2, 3];

        CvInvoke.CvtColor(sourceimage, sourceimage, ColorConversion.Bgr2Gray);
        CvInvoke.CvtColor(template, template, ColorConversion.Bgr2Gray);

        Image<Gray, float> wm = new Image<Gray, float>(new Size(2, 3));
        wm.Data = warp_matrix_temp;

        CvInvoke.FindTransformECC(template, sourceimage, wm, _motionType, new MCvTermCriteria(iterations, eps));

        warp_matrix_temp = wm.Data;

        return new Mat();
    }
publicstaticmatalignimage(matsourceimage,mattemplate,int迭代,double-eps,MotionType\u MotionType=MotionType.Euclidean)
{
浮动[,]扭曲矩阵温度=新浮动[2,3,1];
浮动[,]扭曲矩阵=新浮动[2,3];
CvInvoke.CvtColor(sourceimage,sourceimage,ColorConversion.Bgr2Gray);
CvInvoke.CvtColor(模板,模板,ColorConversion.Bgr2Gray);
图像wm=新图像(新尺寸(2,3));
wm.Data=扭曲矩阵温度;
CvInvoke.findtTransformeC(模板、源图像、wm、_motionType、新的MCvTermCriteria(迭代、eps));
扭曲矩阵温度=wm.数据;
返回新垫();
}
函数未完成,因为FindTransformeC返回错误:“Emgu.CV.Util.CvException:‘OpenCV:NaN遇到’。” 我没有找到合适的解决办法。输入图像正常。我把它写进了文件以确保它是正确的。 我使用的是从nuget软件包安装的Emgu.CV 3.4.1.2976。 有人能帮我吗?我不知道应该是什么问题。 多谢各位


Lucie

EMGU开发人员找到了答案(我们在回购协议中讨论过)。 需要初始化扭曲数组中的值:

float[,,] warp_matrix_temp = new float[2, 3, 1] { { { 1 }, { 0 }, { 0 } }, { { 0 }, { 1 }, { 0 } } };
这将有助于功能正常运行。 我希望这将有助于其他人在未来

露西