public ShapeMatch(HObject Image, Algorithm al)
 {
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
     this.Image = Image; this.algorithm = al; vOrh = "h";
     pixeldist  = 1;
 }
Example #2
0
 public ScrewPitchTool(HObject Image, Algorithm al)
 {
     this.Image = Image; this.algorithm.Image = Image; this.algorithm = al;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
     pixeldist = 1;
 }
 public BigSmallDiameter(HObject Image, Algorithm al)
 {
     this.Image           = Image;
     this.algorithm.Image = Image;
     this.algorithm       = al;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
     pixeldist = 1;
 }
Example #4
0
        private void Initial()
        {
            centerRow    = null;
            centerColumn = null;
            radius       = null;
            centerRow    = new HTuple();
            centerColumn = new HTuple();
            radius       = new HTuple();

            HOperatorSet.GenEmptyObj(out RegionToDisp);
            RegionToDisp.Dispose();
        }
        private void Initial()
        {
            //Dthv = null;
            Length1      = null;
            Length2      = null;
            Phi          = null;
            centerRow    = null;
            centerColumn = null;
            //centerRow = new HTuple();
            //Dthv = new HTuple();
            Length1      = new HTuple();
            Length2      = new HTuple();
            Phi          = new HTuple();
            centerRow    = new HTuple();
            centerColumn = new HTuple();

            HOperatorSet.GenEmptyObj(out RegionToDisp);
            RegionToDisp.Dispose();
        }
Example #6
0
 public queliao()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
        private void action()
        {
            _length = 0;
            // Local iconic variables

            HObject ho_ImageReduced;
            HObject region, ho_regionOpening;
            // Local control variables
            HTuple hv_Number;
            HTuple hv_Row, hv_Column, hv_Angle, hv_Score, hv_Newtuple;

            HOperatorSet.GenEmptyObj(out region);

            HOperatorSet.GenEmptyObj(out ho_ImageReduced);

            try
            {
                if (hv_ModelID.Length != 1)
                {
                    HOperatorSet.ReadShapeModel(PathHelper.currentProductPath + @"\Pictures.shm", out hv_ModelID);
                }

                HOperatorSet.FindShapeModel(this.Image, hv_ModelID, 0, (new HTuple(360)).TupleRad()
                                            , 0.5, 0, 0.5, "least_squares", 0, 0.9, out hv_Row, out hv_Column, out hv_Angle,
                                            out hv_Score);
                if ((int)(new HTuple((new HTuple(hv_Score.TupleLength())).TupleGreaterEqual(1))) != 0)
                {
                    HOperatorSet.TupleGenConst(new HTuple(hv_Score.TupleLength()), 100, out hv_Newtuple);

                    HOperatorSet.GenCircle(out region, hv_Row, hv_Column, hv_Newtuple);
                }
                this.result = new HTuple();
                if (region.IsInitialized())
                {
                    HOperatorSet.CountObj(region, out hv_Number);
                    if ((int)(new HTuple(hv_Number.TupleGreaterEqual(1))) != 0)
                    {
                        this.Result = this.Result.TupleConcat("数量");
                        this.Result = this.Result.TupleConcat(hv_Number);
                    }


                    RegionToDisp.Dispose();
                    if (RegionToDisp.IsInitialized())
                    {
                        HOperatorSet.ConcatObj(region, RegionToDisp, out RegionToDisp);
                    }
                    else
                    {
                        //HOperatorSet.GenRegionContourXld(region, out RegionToDisp, "filled");
                        HOperatorSet.Union1(region, out RegionToDisp);
                    }
                }
            }
            catch (Exception e)
            {
                this.Result = new HTuple();
                this.Result = this.Result.TupleConcat("数量");
                this.Result = this.Result.TupleConcat(0);
            }
            finally
            {
                //algorithm.Region.Dispose();
                region.Dispose();
                ho_ImageReduced.Dispose();
            }
        }
 public kakou()
 {
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
 public ShapeMatch()
 {
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
 public BigSmallDiameter()
 {
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
 public chilunbiaomian2()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
 public dengzuoz()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
 public luowencc()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
Example #14
0
 public nbzcdmian5()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
Example #15
0
        // Main procedure
        private void action()
        {
            // Local iconic variables
            HObject ho_Rectangle;
            HObject ho_RegionFillUp, ho_RegionOut, Region;
            // Local control variables
            HTuple hv_length = new HTuple();

            // Initialize local and output iconic variables
            HOperatorSet.GenEmptyObj(out ho_Rectangle);
            HOperatorSet.GenEmptyObj(out ho_RegionFillUp);
            HOperatorSet.GenEmptyObj(out ho_RegionOut);
            HOperatorSet.GenEmptyObj(out Region);
            try
            {
                try
                {
                    ho_Rectangle.Dispose();
                    HOperatorSet.GenRectangle1(out ho_Rectangle, this.rr1, rc1, rr2,
                                               rc2);
                    Region.Dispose();
                    HOperatorSet.Intersection(ho_Rectangle, this.algorithm.Region, out Region);

                    ho_RegionFillUp.Dispose();
                    HOperatorSet.FillUp(Region, out ho_RegionFillUp);
                    ho_RegionOut.Dispose();
                    screwLength(ho_RegionFillUp, out ho_RegionOut, tr1, tc1, tr2,
                                tc2, hv_vOrh, out hv_length);
                    if (ho_RegionOut.IsInitialized())
                    {
                        RegionToDisp.Dispose();
                        HOperatorSet.Union1(ho_RegionOut, out RegionToDisp);
                        //HOperatorSet.ConcatObj(ho_RegionOut, RegionToDisp, out RegionToDisp);
                    }
                }
                catch (Exception e)
                {
                    hv_length = 0;
                }
                finally
                {
                    HTuple hv_result = new HTuple();
                    hv_result = hv_result.TupleConcat("螺牙长度");
                    hv_result = hv_result.TupleConcat(hv_length * pixeldist);
                    result    = hv_result.Clone();
                }
            }
            catch (HalconException HDevExpDefaultException)
            {
                ho_Rectangle.Dispose();
                ho_RegionFillUp.Dispose();
                ho_RegionOut.Dispose();
                throw HDevExpDefaultException;
            }
            finally
            {
                ho_Rectangle.Dispose();
                ho_RegionFillUp.Dispose();
                ho_RegionOut.Dispose();
            }
        }
 public xiaomaoding1()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
Example #17
0
        private void action()
        {
            _length = 0;
            // Local iconic variables

            HObject ho_Rectangle, ho_ImageReduced;
            HObject ho_Arrow, region;
            HObject ho_RegionTrans;
            HTuple  hv_Row, hv_Column, hv_Phi, hv_Length1, hv_Length2, hv_Distance_Measure_01_0;
            // Local control variables
            HTuple hv_Number;

            HOperatorSet.GenEmptyObj(out region);
            HOperatorSet.GenEmptyObj(out ho_Rectangle);
            HOperatorSet.GenEmptyObj(out ho_ImageReduced);
            HOperatorSet.GenEmptyObj(out ho_Arrow);
            HOperatorSet.GenEmptyObj(out ho_RegionTrans);
            try
            {
                ho_Rectangle.Dispose();
                HOperatorSet.GenRectangle1(out ho_Rectangle, this.DRow1, this.DColumn1, this.DRow2, this.DColumn2);
                HOperatorSet.Intersection(algorithm.Region, ho_Rectangle, out region);
                this.result = new HTuple();
                ho_Arrow.Dispose();
                ho_RegionTrans.Dispose();
                HOperatorSet.ShapeTrans(region, out ho_RegionTrans, "rectangle2");
                HOperatorSet.SmallestRectangle2(ho_RegionTrans, out hv_Row, out hv_Column, out hv_Phi,
                                                out hv_Length1, out hv_Length2);
                ho_Rectangle.Dispose();
                HOperatorSet.GenRectangle2(out ho_Rectangle, hv_Row, hv_Column, hv_Phi, hv_Length1,
                                           hv_Length2);

                xldLength(algorithm.Image, ho_Rectangle, out ho_Arrow, hv_Phi, out hv_Distance_Measure_01_0);
                this._length = hv_Distance_Measure_01_0;
                if (algorithm.Region.IsInitialized())
                {
                    HOperatorSet.CountObj(region, out hv_Number);
                    if ((int)(new HTuple(hv_Number.TupleEqual(1))) != 0)
                    {
                        this.Result = this.Result.TupleConcat("XLDlength");
                        this.Result = this.Result.TupleConcat(this._length * pixeldist);
                    }
                    else
                    {
                        this.Result = this.Result.TupleConcat("XLDlength");
                        this.Result = this.Result.TupleConcat(0);
                    }
                    //HOperatorSet.SetColor(this.LWindowHandle, "green");
                    //HOperatorSet.DispObj(ho_Arrow, this.LWindowHandle);
                    if (ho_Arrow.IsInitialized())
                    {
                        RegionToDisp.Dispose();
                        if (RegionToDisp.IsInitialized())
                        {
                            HOperatorSet.ConcatObj(ho_Arrow, RegionToDisp, out RegionToDisp);
                        }
                        else
                        {
                            HOperatorSet.CopyObj(ho_Arrow, out RegionToDisp, 1, 1);
                            HOperatorSet.Union1(RegionToDisp, out RegionToDisp);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                this.Result = new HTuple();
                this.Result = this.Result.TupleConcat("XLDlength");
                this.Result = this.Result.TupleConcat(0);
            }
            finally
            {
                algorithm.Region.Dispose();
                region.Dispose();
                ho_Rectangle.Dispose();
                ho_ImageReduced.Dispose();
                ho_Arrow.Dispose();
                ho_RegionTrans.Dispose();
            }
        }
Example #18
0
 public XldLength()
 {
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
Example #19
0
 public xuanxianggao()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
Example #20
0
 public heipiwaiquan()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
Example #21
0
 public OutCircletool()
 {
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
 public gaodu11()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
 public dipanhuokou()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
Example #24
0
        private void action()
        {
            // Stack for temporary objects
            HObject[] OTemp = new HObject[20];
            long      SP_O  = 0;
            // Local iconic variables
            HObject ho_Circle, region;
            HObject ho_SelectedRegions, ho_outCircle;
            // Local control variables

            //HTuple hv_blackOrwhite, hv_threshold_value;
            //HTuple hv_method, hv_andOror, hv_method_min_value, hv_method_max_value;
            HTuple hv_outer_Row, hv_outer_Column;
            HTuple hv_outer_Radius, hv_Circularity;
            HTuple hv_Number = new HTuple(), hv_result = new HTuple();

            // Initialize local and output iconic variables
            //HOperatorSet.GenEmptyObj(out ho_Image);
            HOperatorSet.GenEmptyObj(out ho_Circle);
            HOperatorSet.GenEmptyObj(out ho_SelectedRegions);
            HOperatorSet.GenEmptyObj(out ho_outCircle);
            HOperatorSet.GenEmptyObj(out region);
            try
            {
                //HOperatorSet.SetColor(this.LWindowHandle, "green");
                //    out hv_Radius);
                ho_Circle.Dispose();
                HOperatorSet.GenCircle(out ho_Circle, DCenterRow, DCenterColumn, DRadius);
                HOperatorSet.Intersection(ho_Circle, algorithm.Region, out region);
                region_outer_circle(region, out ho_outCircle, out hv_outer_Row,
                                    out hv_outer_Column, out hv_outer_Radius, out hv_Circularity);

                //HOperatorSet.DispObj(ho_outCircle, this.LWindowHandle);
                RegionToDisp.Dispose();
                if (!RegionToDisp.IsInitialized())
                {
                    HOperatorSet.CopyObj(ho_outCircle, out RegionToDisp, 1, 1);
                }
                else
                {
                    HOperatorSet.ConcatObj(ho_outCircle, RegionToDisp, out RegionToDisp);
                }
                //RegionToDisp
                HOperatorSet.CountObj(ho_outCircle, out hv_Number);
                if ((int)(new HTuple(hv_Number.TupleEqual(1))) != 0)
                {
                    hv_result = hv_result.TupleConcat("center_row");
                    hv_result = hv_result.TupleConcat(hv_outer_Row * pixeldist);
                    hv_result = hv_result.TupleConcat("center_column");
                    hv_result = hv_result.TupleConcat(hv_outer_Column * pixeldist);
                    hv_result = hv_result.TupleConcat("diameter");
                    hv_result = hv_result.TupleConcat(2 * hv_outer_Radius * pixeldist);
                    hv_result = hv_result.TupleConcat("circularity");
                    hv_result = hv_result.TupleConcat(hv_Circularity);
                    result    = hv_result.Clone();
                }
                else
                {
                    hv_result = hv_result.TupleConcat("center_row");
                    hv_result = hv_result.TupleConcat(0);
                    hv_result = hv_result.TupleConcat("center_column");
                    hv_result = hv_result.TupleConcat(0);
                    hv_result = hv_result.TupleConcat("diameter");
                    hv_result = hv_result.TupleConcat(0);
                    hv_result = hv_result.TupleConcat("circularity");
                    hv_result = hv_result.TupleConcat(0);
                    result    = hv_result.Clone();
                }
            }
            catch (HalconException HDevExpDefaultException)
            {
                this.Result = new HTuple();
                MyDebug.ShowMessage("CircleToolsError:=" + HDevExpDefaultException);
                hv_result = hv_result.TupleConcat("center_row");
                hv_result = hv_result.TupleConcat(0);
                hv_result = hv_result.TupleConcat("center_column");
                hv_result = hv_result.TupleConcat(0);
                hv_result = hv_result.TupleConcat("diameter");
                hv_result = hv_result.TupleConcat(0);
                hv_result = hv_result.TupleConcat("circularity");
                hv_result = hv_result.TupleConcat(0);
                result    = hv_result.Clone();
            }
            finally
            {
                ho_Circle.Dispose();
                region.Dispose();
                ho_SelectedRegions.Dispose();
                ho_outCircle.Dispose();
                algorithm.Region.Dispose();
            }
        }
 public shangcengbm()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
 public PartHeight()
 {
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
Example #27
0
 public waiguan2()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
 public kongxinju()
 {
     //RegionToDisp = Image;
     HOperatorSet.GenEmptyObj(out RegionToDisp);
     RegionToDisp.Dispose();
 }
Example #29
0
        private void action()
        {
            _length = 0;
            // Local iconic variables

            HObject ho_Rectangle, ho_ImageReduced;
            HObject ho_Arrow, region, ho_regionOpening;
            // Local control variables
            HTuple hv_Number;

            HOperatorSet.GenEmptyObj(out region);
            HOperatorSet.GenEmptyObj(out ho_Rectangle);
            HOperatorSet.GenEmptyObj(out ho_ImageReduced);
            HOperatorSet.GenEmptyObj(out ho_Arrow);
            try
            {
                ho_Rectangle.Dispose();
                HOperatorSet.GenRectangle1(out ho_Rectangle, this.DRow1, this.DColumn1, this.DRow2, this.DColumn2);

                //HOperatorSet.Intersection(algorithm.Region, ho_Rectangle, out region);
                if (taijie == "true")
                {
                    RegionOpen(algorithm.Region, ho_Rectangle, out region);
                }
                else
                {
                    HOperatorSet.Intersection(algorithm.Region, ho_Rectangle, out region);
                }
                this.result = new HTuple();
                ho_Arrow.Dispose();
                if (algorithm.Region.IsInitialized())
                {
                    my_clamp(region, out ho_Arrow, vOrh, out this._length);

                    HOperatorSet.CountObj(region, out hv_Number);
                    if ((int)(new HTuple(hv_Number.TupleEqual(1))) != 0)
                    {
                        this.Result = this.Result.TupleConcat("length");
                        this.Result = this.Result.TupleConcat(this._length * pixeldist);
                    }
                    else
                    {
                        this.Result = this.Result.TupleConcat("length");
                        this.Result = this.Result.TupleConcat(0);
                    }
                    //HOperatorSet.SetColor(this.LWindowHandle, "green");
                    //HOperatorSet.DispObj(ho_Arrow, this.LWindowHandle);
                    if (ho_Arrow.IsInitialized())
                    {
                        RegionToDisp.Dispose();
                        if (RegionToDisp.IsInitialized())
                        {
                            HOperatorSet.ConcatObj(ho_Arrow, RegionToDisp, out RegionToDisp);
                        }
                        else
                        {
                            HOperatorSet.GenRegionContourXld(ho_Arrow, out RegionToDisp, "filled");
                            HOperatorSet.Union1(RegionToDisp, out RegionToDisp);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                this.Result = new HTuple();
                this.Result = this.Result.TupleConcat("length");
                this.Result = this.Result.TupleConcat(0);
            }
            finally
            {
                algorithm.Region.Dispose();
                region.Dispose();
                ho_Rectangle.Dispose();
                ho_ImageReduced.Dispose();
                ho_Arrow.Dispose();
            }
        }