[英]Transformations with Emgu (OpenCV) - Affine/perspective?
我目前正在尝试通过使用EMGU来实现转换,尽管我似乎无法完全理解它的工作方式(而且似乎没有在线示例)。
我已经有了自己的图像,我希望从(和)转换为4个点,尽管我不知道还需要其他哪些变量,但它要求输入“ mapMat”?
这是我到目前为止的内容:
float[,] tmp = {
{bottomLeft.x, bottomLeft.y},
{topLeft.x, topLeft.y},
{topRight.x, topRight.y},
{bottomRight.x, bottomRight.y}
};
Matrix<float> sourceMat = new Matrix<float>(tmp);
float[,] target = {
{0, height},
{0, 0},
{width, 0},
{width, height}
};
Matrix<float> targetMat = new Matrix<float>(target);
//mapMat = just a placeholder matrix?
Matrix<float> mapMat = new Matrix<float>(target);
CvInvoke.cvGetAffineTransform(sourceMat.Ptr, targetMat.Ptr, mapMat.Ptr);
但是,这不起作用。 我也不确定仿射变换是否是最理想的解决方案? 我也阅读了有关FindHomography的内容以及透视图转换,但是不确定它们是否适用于此。
我希望实现的目标转换是这样的:
http://img832.imageshack.us/img832/5157/targettransform.png
任何帮助将不胜感激,
谢谢
首先一点介绍:
因此,假设您有4个源角和目标角,并且您想要估计“透视变换”,那么此代码应执行您想要的操作:
PointF[] pts1 = new PointF[4];
PointF[] pts2 = new PointF[4];
HomographyMatrix homography;
for (int i = 0; i < 4; i++)
{
pts1[i] = new PointF (sourceCorner[i].X, sourceCorner[i].Y);
pts2[i] = new PointF (destCorner[i].X, destCorner[i].Y);
}
homography = CameraCalibration.GetPerspectiveTransform(pts1, pts2);
看看CameraCalibration其他有用的方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.