コード例 #1
0
 public HRegion Process(HRegion region)
 {
     return(region.Boundary(BoundaryType.ToHalconString()));
 }
コード例 #2
0
        private void DefineMat2Ds()
        {
            if (mat2Ds == null)
            {
                mat2Ds = new List <HHomMat2D>();
            }
            else
            {
                mat2Ds.Clear();
            }
            for (int i = 0; i < row_temp.Length; i++)
            {
                HHomMat2D homMat2D = new HHomMat2D();
                homMat2D.VectorAngleToRigid(
                    createShapeModel.refCoordinates[0].D, createShapeModel.refCoordinates[1].D, createShapeModel.refCoordinates[2].D,
                    row_temp[i].D, column_temp[i].D, angle_temp[i].D);
                HRegion boundary_region;
                if (SearchRegion == null | !SearchRegion.IsInitialized())
                {
                    boundary_region = refImage.GetDomain().Boundary("inner");
                }
                else
                {
                    boundary_region = SearchRegion.Boundary("inner");
                }

                HTuple row_rect2, col_rect2, phi_rect2, lenght1_rect2, lenght2_rect2;
                if (this.createShapeModel.modelRegion == null || !this.createShapeModel.modelRegion.IsInitialized())
                {
                    return;
                }
                this.createShapeModel.modelRegion.SmallestRectangle2(out row_rect2, out col_rect2, out phi_rect2, out lenght1_rect2, out lenght2_rect2);

                HRegion small_rect2_region = new HRegion();
                small_rect2_region.GenRectangle2(row_rect2, col_rect2, phi_rect2, lenght1_rect2, lenght2_rect2);

                HRegion small_rect2_region_affine = homMat2D.AffineTransRegion(small_rect2_region, "nearest_neighbor");

                HObject Area_temp;
                HOperatorSet.Intersection(boundary_region, small_rect2_region_affine, out Area_temp);
                HTuple area, row_tt, col_tt;
                HOperatorSet.AreaCenter(Area_temp, out area, out row_tt, out col_tt);
                if (area.D == 0)
                {
                    mat2Ds.Add(homMat2D);
                    row    = row.TupleConcat(row_temp[i]);
                    column = column.TupleConcat(column_temp[i]);
                    angle  = angle.TupleConcat(angle_temp[i]);
                    scale  = scale.TupleConcat(scale_temp[i]);
                    score  = score.TupleConcat(score_temp[i]);
                }
                if (boundary_region != null && boundary_region.IsInitialized())
                {
                    boundary_region.Dispose();
                }
                if (small_rect2_region_affine != null && small_rect2_region_affine.IsInitialized())
                {
                    small_rect2_region_affine.Dispose();
                }
                if (small_rect2_region != null && small_rect2_region.IsInitialized())
                {
                    small_rect2_region.Dispose();
                }
                if (Area_temp != null && Area_temp.IsInitialized())
                {
                    Area_temp.Dispose();
                }
            }
        }