Пример #1
0
        /// <summary>
        /// 计算提取区域(数组结果)
        /// </summary>
        /// <returns></returns>
        public bool CalculateNonUnionPositiveRegion()
        {
            if (_operationFlag == ROI_MODE_NONE)
            {
                return(true);
            }
            HalconDotNet.HObject tmp = new HalconDotNet.HObject();
            tmp.GenEmptyObj();

            for (int i = 0; i < ROIList.Count; i++)
            {
                switch (((ROI)ROIList[i]).GetOperationFlag())
                {
                case ROI.MODE_NEGATIVE:
                    break;

                case ROI.MODE_POSITIVE:
                    tmp = tmp.ConcatObj(((ROI)ROIList[i]).GetModelRegion());
                    break;
                }
            }

            _nonUnionPositiveRegion = tmp;

            if (ROIList.Count == 0)
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
 public ROILine()
 {
     NumHandles      = 3;   //两个个端点+一个定位中心点
     ActiveHandleIdx = 0;   //活动操作柄在中点,以便于移动位置
     ROIShape        = ProVision.InteractiveROI.ROIShape.ROI_SHAPE_LINE;
     _arrowHandle    = new HalconDotNet.HObject();
     _arrowHandle.GenEmptyObj();
 }
Пример #3
0
        public ROICircularArc()
        {
            NumHandles      = 4;   //一个定位中心点+一个缩放角点(在圆弧上)+一个起始点+一个终止点
            ActiveHandleIdx = 0;   //活动操作柄在中点,以便于移动位置
            ROIShape        = ProVision.InteractiveROI.ROIShape.ROI_SHAPE_CIRCULARARC;

            _circularArc = new HalconDotNet.HObject();
            _circularArc.GenEmptyObj();
            _circularArcDir = "";

            _arrowHandle = new HalconDotNet.HObject();
            _arrowHandle.GenEmptyObj();

            PI    = Math.PI;
            TwoPI = 2 * PI;
        }
Пример #4
0
        /// <summary>
        /// Calculates the ModelROI region for all objects contained
        /// in ROIList, by adding and subtracting the positive and
        /// negative ROI objects.
        /// 计算合成区域(联合结果)
        /// </summary>
        public bool CalculateSyntheticalRegion()
        {
            HalconDotNet.HObject tmpAdd, tmpDiff, tmp;
            HalconDotNet.HTuple  area = new HalconDotNet.HTuple(), row = new HalconDotNet.HTuple(), col = new HalconDotNet.HTuple();

            if (_operationFlag == ROI_MODE_NONE)
            {
                return(true);
            }

            tmpAdd = new HalconDotNet.HObject();
            tmpAdd.GenEmptyObj();
            tmpDiff = new HalconDotNet.HObject();
            tmpDiff.GenEmptyObj();
            tmp = new HalconDotNet.HObject();
            tmp.GenEmptyObj();

            for (int i = 0; i < ROIList.Count; i++)
            {
                switch (((ROI)ROIList[i]).GetOperationFlag())
                {
                case ROI.MODE_NEGATIVE:
                    HalconDotNet.HOperatorSet.Union2(tmpDiff, ((ROI)ROIList[i]).GetModelRegion(), out tmpDiff);
                    break;

                case ROI.MODE_POSITIVE:
                    HalconDotNet.HOperatorSet.Union2(tmpAdd, ((ROI)ROIList[i]).GetModelRegion(), out tmpAdd);
                    break;
                }
            }

            if (_syntheticalRegion != null &&
                _syntheticalRegion.IsInitialized())
            {
                _syntheticalRegion.Dispose();
            }
            HalconDotNet.HOperatorSet.AreaCenter(tmpAdd, out area, out row, out col);

            if (area.TupleNotEqual(new HalconDotNet.HTuple()) &&
                area[0].D > 0)
            {
                if (tmp != null && tmp.IsInitialized())
                {
                    tmp.Dispose();
                }
                HalconDotNet.HOperatorSet.Difference(tmpAdd, tmpDiff, out tmp);

                HalconDotNet.HOperatorSet.AreaCenter(tmp, out area, out row, out col);
                if (area.TupleNotEqual(new HalconDotNet.HTuple()) &&
                    area[0].D > 0)
                {
                    _syntheticalRegion = tmp;
                }
            }

            if (_syntheticalRegion == null || ROIList.Count == 0)
            {
                return(false);
            }

            return(true);
        }