Exemple #1
0
        public bool Grab_Intervene_Act(HImage image, List <HHomMat2D> Mat2Ds)
        {
            try
            {
                if (!bIsInitial)
                {
                    Initial_Grab_Intervene();
                }
                if (Grab_Intervene_Region == null || !Grab_Intervene_Region.IsInitialized())
                {
                    return(false);
                }
                if (Mat2Ds == null || Mat2Ds.Count() < 1)
                {
                    return(false);
                }
                if (ResultRegion == null)
                {
                    ResultRegion = new HRegion();
                }
                if (ResultRegion != null && ResultRegion.IsInitialized())
                {
                    ResultRegion.Dispose();
                }
                ResultRegion.GenEmptyObj();

                grabInterveneOkNg = new HTuple();

                if (Grab_Intervene_Region_Affines == null)
                {
                    Grab_Intervene_Region_Affines = new HRegion();
                }
                if (Grab_Intervene_Region_Affines != null && Grab_Intervene_Region_Affines.IsInitialized())
                {
                    Grab_Intervene_Region_Affines.Dispose();
                }
                Grab_Intervene_Region_Affines.GenEmptyObj();

                for (int i = 0; i < Mat2Ds.Count(); i++)
                {
                    if (Grab_Intervene_Region_Affine == null)
                    {
                        Grab_Intervene_Region_Affine = new HRegion();
                    }
                    if (Grab_Intervene_Region_Affine != null && Grab_Intervene_Region_Affine.IsInitialized())
                    {
                        Grab_Intervene_Region_Affine.Dispose();
                    }
                    Grab_Intervene_Region_Affine.GenEmptyObj();
                    Grab_Intervene_Region_Affine  = Mat2Ds[i].AffineTransRegion(Grab_Intervene_Region, "nearest_neighbor");
                    Grab_Intervene_Region_Affines = Grab_Intervene_Region_Affines.ConcatObj(Grab_Intervene_Region_Affine);
                    Act_Engine(image);
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
        public void GenDetectionRegionResult(HRegion modelRegion)
        {
            if (resultRegion == null)
            {
                resultRegion = new HRegion();
            }
            if (resultRegion != null && resultRegion.IsInitialized())
            {
                resultRegion.Dispose();
            }
            resultRegion.GenEmptyObj();

            HRegion temp = new HRegion();

            for (int i = 0; i < row.Length; i++)
            {
                HHomMat2D mat1 = new HHomMat2D();
                mat1.VectorAngleToRigid(
                    createShapeModel.refCoordinates[0].D,
                    createShapeModel.refCoordinates[1].D,
                    createShapeModel.refCoordinates[2].D,
                    row[i].D, column[i].D, angle[i].D);
                mat1 = mat1.HomMat2dScale(scale[i].D, scale[i].D, row[i].D, column[i].D);
                //图像偏移
                temp = mat1.AffineTransRegion(modelRegion, "nearest_neighbor");
                //获取模板集合
                resultRegion = resultRegion.ConcatObj(temp);
                temp.Dispose();
            }
        }
        /// <summary>
        /// Creates an iconic object depicting the
        /// measuring field.
        /// </summary>
        public void UpdateMeasureRegion()
        {
            mMeasureRegion.Dispose();
            mMeasureRegion.GenEmptyObj();
            switch (mROIType)
            {
            case ROI.ROI_TYPE_CIRCLEARC:
                double   sPhi, extent, innerRad, outerRad;
                HTuple   innerR, outerR, innerC, outerC;
                HXLDCont outCont, innerCont, contour;

                outCont   = new HXLDCont();
                innerCont = new HXLDCont();

                sPhi     = mMeasROI[2].D;
                extent   = mMeasROI[3].D;
                outerRad = mMeasROI[4].D;
                innerRad = mMeasROI[5].D;


                innerCont.GenCircleContourXld(mMeasROI[0].D, mMeasROI[1].D, innerRad, sPhi, (sPhi + extent), (extent > 0) ? "positive" : "negative", 1.0);
                outCont.GenCircleContourXld(mMeasROI[0].D, mMeasROI[1].D, outerRad, (sPhi + extent), sPhi, (extent > 0) ? "negative" : "positive", 1.0);

                innerCont.GetContourXld(out innerR, out innerC);
                outCont.GetContourXld(out outerR, out outerC);
                innerR = innerR.TupleConcat(outerR);
                innerC = innerC.TupleConcat(outerC);

                contour = new HXLDCont(innerR, innerC);
                contour = contour.CloseContoursXld();

                mMeasureRegion = contour.GenRegionContourXld("margin");

                contour.Dispose();
                innerCont.Dispose();
                outCont.Dispose();
                break;

            case ROI.ROI_TYPE_CIRCLE:
                //
                break;

            default:
                mMeasureRegion.GenRectangle2(mMeasROI[0].D, mMeasROI[1].D,
                                             mMeasROI[2].D, mMeasROI[3].D,
                                             mMeasROI[4].D);
                break;
            }
        }
        public bool LanQuan_Act(HImage R, HImage B, List <HHomMat2D> Mat2Ds)
        {
            try
            {
                if (!bIsInitial)
                {
                    Initial_LanQuan();
                }
                if (LanQuan_Region == null || !LanQuan_Region.IsInitialized())
                {
                    return(false);
                }
                if (Mat2Ds == null || Mat2Ds.Count() < 1)
                {
                    return(false);
                }
                if (ResultRegion == null)
                {
                    ResultRegion = new HRegion();
                }
                if (ResultRegion != null && ResultRegion.IsInitialized())
                {
                    ResultRegion.Dispose();
                }
                ResultRegion.GenEmptyObj();

                LanQuan_OkNg = new HTuple();
                Area         = new HTuple();

                if (LanQuan_Region_Affines == null)
                {
                    LanQuan_Region_Affines = new HRegion();
                }
                if (LanQuan_Region_Affines != null && LanQuan_Region_Affines.IsInitialized())
                {
                    LanQuan_Region_Affines.Dispose();
                }
                LanQuan_Region_Affines.GenEmptyObj();

                for (int i = 0; i < Mat2Ds.Count(); i++)
                {
                    if (LanQuan_Region_Affine == null)
                    {
                        LanQuan_Region_Affine = new HRegion();
                    }
                    if (LanQuan_Region_Affine != null && LanQuan_Region_Affine.IsInitialized())
                    {
                        LanQuan_Region_Affine.Dispose();
                    }
                    LanQuan_Region_Affine.GenEmptyObj();
                    LanQuan_Region_Affine  = Mat2Ds[i].AffineTransRegion(LanQuan_Region, "nearest_neighbor");
                    LanQuan_Region_Affines = LanQuan_Region_Affines.ConcatObj(LanQuan_Region_Affine);
                    Act_Engine(R, B);
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Exemple #5
0
        public bool FangDai_Act(HImage image, List <HHomMat2D> Mat2Ds)
        {
            try
            {
                //if (!bIsInitial)
                //{
                //    Initial_FangDai();
                //}
                if (FangDai_Region == null || !FangDai_Region.IsInitialized())
                {
                    return(false);
                }
                if (Mat2Ds == null || Mat2Ds.Count() < 1)
                {
                    return(false);
                }
                if (ResultRegion == null)
                {
                    ResultRegion = new HRegion();
                }
                if (ResultRegion != null && ResultRegion.IsInitialized())
                {
                    ResultRegion.Dispose();
                }
                ResultRegion.GenEmptyObj();

                FangDai_OkNg = new HTuple();
                Area         = new HTuple();

                if (FangDai_Region_Affines == null)
                {
                    FangDai_Region_Affines = new HRegion();
                }
                if (FangDai_Region_Affines != null && FangDai_Region_Affines.IsInitialized())
                {
                    FangDai_Region_Affines.Dispose();
                }
                FangDai_Region_Affines.GenEmptyObj();

                for (int i = 0; i < Mat2Ds.Count(); i++)
                {
                    if (FangDai_Region_Affine == null)
                    {
                        FangDai_Region_Affine = new HRegion();
                    }
                    if (FangDai_Region_Affine != null && FangDai_Region_Affine.IsInitialized())
                    {
                        FangDai_Region_Affine.Dispose();
                    }
                    FangDai_Region_Affine.GenEmptyObj();
                    FangDai_Region_Affine  = Mat2Ds[i].AffineTransRegion(FangDai_Region, "nearest_neighbor");
                    FangDai_Region_Affines = FangDai_Region_Affines.ConcatObj(FangDai_Region_Affine);
                    //Act_Engine(image);
                    HImage  roi_image    = image.ReduceDomain(FangDai_Region_Affines);
                    HRegion judge_region = roi_image.Threshold(new HTuple(minThreshold), new HTuple(255));
                    int     area         = judge_region.Area;
                    if (judge_region != null && judge_region.IsInitialized())
                    {
                        ResultRegion = ResultRegion.ConcatObj(judge_region);
                        judge_region.Dispose();
                    }
                    roi_image.Dispose();
                    if (area >= minArea && area <= maxArea)
                    {
                        if (FangDai_OkNg.Length == 0)
                        {
                            FangDai_OkNg = new HTuple(1);
                            Area         = new HTuple(area);
                        }
                        else
                        {
                            FangDai_OkNg = FangDai_OkNg.TupleConcat(new HTuple(1));
                            Area         = Area.TupleConcat(new HTuple(area));
                        }
                    }
                    else
                    {
                        if (FangDai_OkNg.Length == 0)
                        {
                            FangDai_OkNg = new HTuple(0);
                            Area         = new HTuple(area);
                        }
                        else
                        {
                            FangDai_OkNg = FangDai_OkNg.TupleConcat(new HTuple(1));
                            Area         = Area.TupleConcat(new HTuple(area));
                        }
                    }
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Exemple #6
0
        public bool FangDai_Act(HImage image, List <HHomMat2D> Mat2Ds)
        {
            try
            {
                if (!bIsInitial)
                {
                    Initial_FangDai();
                }
                if (FangDai_Region == null || !FangDai_Region.IsInitialized())
                {
                    return(false);
                }
                if (Mat2Ds == null || Mat2Ds.Count() < 1)
                {
                    return(false);
                }
                if (ResultRegion == null)
                {
                    ResultRegion = new HRegion();
                }
                if (ResultRegion != null && ResultRegion.IsInitialized())
                {
                    ResultRegion.Dispose();
                }
                ResultRegion.GenEmptyObj();

                FangDai_OkNg = new HTuple();
                Area         = new HTuple();

                if (FangDai_Region_Affines == null)
                {
                    FangDai_Region_Affines = new HRegion();
                }
                if (FangDai_Region_Affines != null && FangDai_Region_Affines.IsInitialized())
                {
                    FangDai_Region_Affines.Dispose();
                }
                FangDai_Region_Affines.GenEmptyObj();

                for (int i = 0; i < Mat2Ds.Count(); i++)
                {
                    if (FangDai_Region_Affine == null)
                    {
                        FangDai_Region_Affine = new HRegion();
                    }
                    if (FangDai_Region_Affine != null && FangDai_Region_Affine.IsInitialized())
                    {
                        FangDai_Region_Affine.Dispose();
                    }
                    FangDai_Region_Affine.GenEmptyObj();
                    FangDai_Region_Affine  = Mat2Ds[i].AffineTransRegion(FangDai_Region, "nearest_neighbor");
                    FangDai_Region_Affines = FangDai_Region_Affines.ConcatObj(FangDai_Region_Affine);
                    Act_Engine(image);
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }