c# - 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);
}
解决方案
推荐阅读
- node.js - 猫鼬填充不同的字段不给出正确的结果
- ios - sqlite3 选择总是返回“1”
- javascript - 无法使用 orderByChild 和 equalTo 从 firebase 查询
- javascript - 从输入类型文件中获取文件夹目录 - PHP
- android - 如何在 Java 代码中使用 Kotlin 协程实现 NIO Socket(客户端)?
- mysql - MySQL:在一个按时间戳排序的大表上查询非常慢(尽管有索引)......
- string - 元组python 3中的字符串
- raku - 更新 CompUnit::PrecompilationStore 中的程序?
- javascript - IE 浏览器不支持如果在 javascript 中定义函数时分配默认值
- amazon-dynamodb - DynamoDb 中 Set 属性的部分匹配条件