我正在为 OpenCV 使用 EmguCV 包装器,并且正在纠正这个形状:
借助此代码:
public Image<Bgr,byte> Rectify()
{
try
{
Image<Bgr, byte> warped_Image = new Image<Bgr, byte>(input_Image.Width, input_Image.Height);
MCvScalar s = new MCvScalar(0, 0, 0);
PointF[] dsts = new PointF[4];
dsts[0] = new PointF(0, 0);
dsts[2] = new PointF(0, input_Image.Height);
dsts[3] = new PointF(input_Image.Width, input_Image.Height);
dsts[1] = new PointF(input_Image.Width, 0);
HomographyMatrix mywarpmat = CameraCalibration.GetPerspectiveTransform(pnts, dsts);
Image<Bgr, byte> warped_Image2 = warped_Image.WarpPerspective(mywarpmat, Emgu.CV.CvEnum.INTER.CV_INTER_NN, Emgu.CV.CvEnum.WARP.CV_WARP_FILL_OUTLIERS, new Bgr(0, 0, 0));
CvInvoke.cvWarpPerspective(input_Image, warped_Image2, mywarpmat, (int)Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR, s);
Image<Bgr, byte> fixedImg = new Image<Bgr, byte>((int)warped_Image2.Width, (int)(warped_Image2.Width / aspectRatio));
CvInvoke.cvResize(warped_Image2.Ptr, fixedImg.Ptr, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
return fixedImg;
}
我得到这个结果(矫正形状):
我知道角落坐标两个图像(校正前后)。在校正之前,我知道形状内部的上部白线的坐标。知道如何在校正后获得这条白线的坐标吗?
先感谢您!