前面是我自己的代码,后面是别人的代码,大同小异,我自己的只有部分代码,测试通过的
我的代码
PointF[] srcQuad = new PointF[4];
PointF[] desQuad = new PointF[4];
desQuad[0] = intersectionTransformPointLT;
desQuad[1] = intersectionTransformPointRT;
desQuad[2] = intersectionTransformPointLB;
desQuad[3] = intersectionTransformPointRB;
srcQuad[0] = intersectionPointLT;
srcQuad[1] = intersectionPointRT;
srcQuad[2] = intersectionPointLB;
srcQuad[3] = intersectionPointRB;
perspective_after_ptr_show = IntPtr2IntPtr(original_ptr);
IntPtr map_matrix=new Matrix<double>(3,3);
//生成透视变换矩阵
//Emgu.CV.CameraCalibration.GetPerspectiveTransform();
map_matrix = CvInvoke.cvGetPerspectiveTransform(srcQuad, desQuad, map_matrix);
//进行透视变换(第三个参数决定了矩形框之外的部分进行处理的方式,现在所选为用黑色填充)
CvInvoke.cvWarpPerspective(original_ptr, perspective_after_ptr_show, map_matrix,(int)Emgu.CV.CvEnum.WARP.CV_WARP_FILL_OUTLIERS