예제 #1
0
            //显示静态图像的匹配结果
            public void MatchStaticImage()
            {
                //绘制矩形(可以做一个弹窗什么的)
                MessageBox.Show("请在右图中绘制匹配的区块,按鼠标右键结束绘制");
                HOperatorSet.DrawRectangle1(hv_ExpDefaultWinHandle, out hv_LeftTopY, out hv_LeftTopX, out hv_RightBottomY, out hv_RightBottomX);

                //获取这个鼠标绘制出来的矩形框
                ho_Rectangle.Dispose();
                HOperatorSet.GenRectangle1(out ho_Rectangle, hv_LeftTopY, hv_LeftTopX, hv_RightBottomY, hv_RightBottomX);

                hv_pi          = ((new HTuple(0.0)).TupleAcos()) * 2;
                hv_arrowLength = 50;

                ho_ImageReduced.Dispose();
                HOperatorSet.ReduceDomain(ho_Image_Static, ho_Rectangle, out ho_ImageReduced);

                //从ImageReduced中创建一个该特征的唯一TemplateID用于后续匹配作为代号
                HOperatorSet.CreateTemplateRot(ho_ImageReduced, 4, -hv_pi, 2 * hv_pi, hv_pi / 45, "sort", "original", out hv_TemplateID);

                //在图像中查找与TemplateID对应的区块的最佳匹配,并把最佳匹配的结果保存到Column,Angle,Error中
                HOperatorSet.BestMatchRotMg(ho_ImageReduced, hv_TemplateID, -hv_pi, 2 * hv_pi, 40, "true", 4, out hv_Row, out hv_Column, out hv_Angle, out hv_Error);

                //显示箭头
                HOperatorSet.DispArrow(hv_ExpDefaultWinHandle, hv_Row, hv_Column, hv_Row + ((hv_Angle.TupleSin()) * hv_arrowLength), hv_Column + ((hv_Angle.TupleCos()) * hv_arrowLength), 1);

                //打开开关并发送当前的匹配结果
                DoMatch = true;
                SendMatchResult();
            }
예제 #2
0
            //显示动态图像的匹配结果
            public void MatchDynamicImage()
            {
                //在图像中查找与TemplateID对应的区块的最佳匹配,并把最佳匹配的结果保存到Column,Angle,Error中
                HOperatorSet.BestMatchRotMg(ho_Image, hv_TemplateID, -hv_pi, 2 * hv_pi, 40, "true", 4, out hv_Row, out hv_Column, out hv_Angle, out hv_Error);

                //显示匹配结果的箭头
                HOperatorSet.DispArrow(hv_ExpDefaultWinHandle, hv_Row, hv_Column, hv_Row + ((hv_Angle.TupleSin()) * hv_arrowLength), hv_Column + ((hv_Angle.TupleCos()) * hv_arrowLength), 1);

                SendMatchResult();
            }