首页 > 解决方案 > EmguCV PCACompute InputData - 将 VectorOfPoint 转换为 Mat

问题描述

CvInvoke.PCACompute 方法需要一个 IInputArray 数据来进行分析。

我尝试使用源图像作为输入 Mat,但根据我的理解,计算的特征向量是异常的。而且我无法将我的 Contour VectorOfPoint 转换为 Mat,我可以喂它。

我也找不到关于在 EmguCV / C# 中实现 PCA 分析的好文献。

有人可以指出我正确的方向。

下面是我的代码 -

public static void getOrientation(Image<Gray,byte> inputImage)
        {
            Image<Gray, Byte> cannyGray = inputImage.Canny(85, 255);

            VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();
            Mat eigen_vectors = new Mat(inputImage.Size,DepthType.Cv8U,1);
            Mat mean_mat = new Mat(inputImage.Size, DepthType.Cv8U, 1);

            CvInvoke.FindContours(cannyGray, contours, null, RetrType.External, ChainApproxMethod.ChainApproxSimple);

            Point[][] cont_points = contours.ToArrayOfArray();
            Mat contour_mat = new Mat();
            contour_mat.SetTo(cont_points[0]);
            
            //CvInvoke.PCACompute(cannyGray.Mat, mean_mat, eigen_vectors,2);
            CvInvoke.PCACompute(contours, mean_mat, eigen_vectors);

        }

标签: c#opencvemgucv

解决方案


推荐阅读