public List <Vector2> GetCornerPoints()
    {
        Image <Gray, float> cornerimg    = new Image <Gray, float>(this.img.Size);
        Image <Gray, Byte>  cornerthrimg = new Image <Gray, Byte>(this.img.Size);
        Image <Gray, Byte>  cannyimg     = this.img.Canny(60, 100);

        CvInvoke.CornerHarris(cannyimg, cornerimg, 3, 3, 0.04);

        //CvInvoke.cvNormalize(cornerimg, cornerimg, 0, 255, Emgu.CV.CvEnum.NORM_TYPE.CV_MINMAX, IntPtr.Zero);  //标准化处理

        double min = 0, max = 0;

        System.Drawing.Point minp = new System.Drawing.Point(0, 0);
        System.Drawing.Point maxp = new System.Drawing.Point(0, 0);
        CvInvoke.MinMaxLoc(cornerimg, ref min, ref max, ref minp, ref maxp);
        double scale = 255 / (max - min);
        double shift = min * scale;

        CvInvoke.ConvertScaleAbs(cornerimg, cornerthrimg, scale, shift);//进行缩放,转化为byte类型
        byte[]         data      = cornerthrimg.Bytes;
        List <Vector2> corners   = new List <Vector2>();
        List <Vector3> corners_3 = new List <Vector3>();

        for (int i = 0; i < cornerimg.Height; i++)
        {
            for (int j = 0; j < cornerimg.Width; j++)
            {
                int k = i * cornerthrimg.Width + j;
                if (data[k] > 80)    //通过阈值判断
                {
                    corners.Add(new Vector2(j, i));
                    corners_3.Add(m_projector.ImageToWorld(corners.Last()));
                }
            }
        }
        m_renderEngine.DrawPoints(corners_3);
        return(corners);
    }
Esempio n. 2
0
    public void DrawPoint(Vector2 p)
    {
        Vector3 p2 = m_projector.ImageToWorld(p);

        Vertex_Point.Add(p2);
        Color_Point.Add(Color_default);

        Vertex_Point.Add(p2 + new Vector3(1, 0, 0) * Length_Point2);
        Color_Point.Add(Color_default);
    }