NI Vision ClampRake修改

        也可以直接在C盘模板中直接修改,模板路径: C:\Program Files (x86)\National Instruments\Vision Assistant\CG\Visual Studio Project\CS
修改后,以后可以不用修改

public static PointContour IVA_FindExtremeEdge(RakeReport report, bool findClosestEdge)
        {
            Double extremeDistance;
            Double tempDistance;
            PointContour edge = new PointContour(0,0);

            // Determine if the function should process the first edges or the last edges array
            if (findClosestEdge)
            {
                if (report.FirstEdges.Count > 0 )
                {
                    extremeDistance = report.FirstEdges[0].Distance;
                    edge = report.FirstEdges[0].Position;

                    // Then find the edge that is closest to the boundary of the search area
                    for (int i = 1 ; i < report.FirstEdges.Count ; i++)
                    {
                        tempDistance = report.FirstEdges[i].Distance;
                        if (tempDistance < extremeDistance)
                        {
                            extremeDistance = tempDistance;
                            edge = report.FirstEdges[i].Position;
                        }
                    }
                }
            }
            else
            {
                if( report.LastEdges.Count > 0 )
                {
                    // First, intialize the value with the first edge in the array
                    extremeDistance = report.LastEdges[0].Distance;
                    edge = report.LastEdges[0].Position;

                    // Then find the edge that are closest to the boundary of the search area
                    for (int i = 1 ; i < report.LastEdges.Count ; i++ )
                    {
                        tempDistance = report.LastEdges[i].Distance;
                        if (tempDistance > extremeDistance)
                        {
                            extremeDistance = tempDistance;
                            edge = report.LastEdges[i].Position;
                        }
                    }
                }
            }
            
            return edge;
        }

posted on 2017-06-08 11:13  qq1151219115  阅读(131)  评论(0编辑  收藏  举报