如何获得像素的坐标形状整流后? [英] How to get coordinates of pixel after shape was rectified?

查看:830
本文介绍了如何获得像素的坐标形状整流后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用EmguCV包装OpenCV的,我rectifing这种形状:

I'm using EmguCV wrapper for OpenCV and I'm rectifing this shape:

与此code的帮助:

 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;
        }

我得到这个结果(整流型):

我知道拐角两个图像(前后精馏)坐标。 整改之前,我就知道上白线内的形状坐标。 任何想法我如何能得到这个白线的坐标整改后?

I know the corners coordinates both of the images (before and after rectification). Before the rectification I knew coordinates of the upper white line that inside the shape. Any idea how can i get the coordinates of this white line after rectification?

感谢你在前进!

推荐答案

有同形矩阵它很容易。正如你所知道的同形矩阵映射直线成直线,这样你就可以直接投射的图像输入线的端点 下面是一些香草伪code:

Having homography matrix it's quite easy. As you know an homography matrix maps straight line into straight line, so you can simply project the endpoints of your input image line Here's some vanilla pseudocode :

 PointF[] pts = new PointF[] { 
                new PointF(startingLinePoint.x, startingLinePoint.y),
                new PointF(endingLinePoint.x, endingLinePoint.y)
        };

 mywarpmat.ProjectPoints(pts);

积分的意愿包含开始和你正在寻找在该行的结束点的预测,那么你必须简单地定义线路穿越他们。

Pts will contained the starting and ending point of the line you are searching in the projected then you have to simply define line passing through them.

这篇关于如何获得像素的坐标形状整流后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆