コード例 #1
0
ファイル: HalconVision.cs プロジェクト: Jin-Shuai/ICDemo
        public void GetPins(HObject ho_Intensity, out HObject ho_Pins, out HObject ho_IC)
        {
            // Local iconic variables

            HObject ho_Dark, ho_DarkDilation, ho_ICLarge;
            HObject ho_ICLargeGray, ho_ICDark, ho_ICDilation, ho_SearchSpace;
            HObject ho_SearchSpaceDilation, ho_SearchSpaceUnion, ho_SearchGray;
            HObject ho_SearchMean, ho_PinsRaw, ho_PinsConnect, ho_PinsFilled;

            // Initialize local and output iconic variables
            HOperatorSet.GenEmptyObj(out ho_Pins);
            HOperatorSet.GenEmptyObj(out ho_IC);
            HOperatorSet.GenEmptyObj(out ho_Dark);
            HOperatorSet.GenEmptyObj(out ho_DarkDilation);
            HOperatorSet.GenEmptyObj(out ho_ICLarge);
            HOperatorSet.GenEmptyObj(out ho_ICLargeGray);
            HOperatorSet.GenEmptyObj(out ho_ICDark);
            HOperatorSet.GenEmptyObj(out ho_ICDilation);
            HOperatorSet.GenEmptyObj(out ho_SearchSpace);
            HOperatorSet.GenEmptyObj(out ho_SearchSpaceDilation);
            HOperatorSet.GenEmptyObj(out ho_SearchSpaceUnion);
            HOperatorSet.GenEmptyObj(out ho_SearchGray);
            HOperatorSet.GenEmptyObj(out ho_SearchMean);
            HOperatorSet.GenEmptyObj(out ho_PinsRaw);
            HOperatorSet.GenEmptyObj(out ho_PinsConnect);
            HOperatorSet.GenEmptyObj(out ho_PinsFilled);
            ho_Dark.Dispose();
            HOperatorSet.Threshold(ho_Intensity, out ho_Dark, 0, 50);
            ho_DarkDilation.Dispose();
            HOperatorSet.DilationRectangle1(ho_Dark, out ho_DarkDilation, 14, 14);
            ho_ICLarge.Dispose();
            HOperatorSet.Connection(ho_DarkDilation, out ho_ICLarge);
            ho_ICLargeGray.Dispose();
            HOperatorSet.AddChannels(ho_ICLarge, ho_Intensity, out ho_ICLargeGray);
            ho_ICDark.Dispose();
            HOperatorSet.Threshold(ho_ICLargeGray, out ho_ICDark, 0, 50);
            ho_IC.Dispose();
            HOperatorSet.ShapeTrans(ho_ICDark, out ho_IC, "rectangle2");
            ho_ICDilation.Dispose();
            HOperatorSet.DilationRectangle1(ho_IC, out ho_ICDilation, 5, 1);
            ho_SearchSpace.Dispose();
            HOperatorSet.Difference(ho_ICDilation, ho_IC, out ho_SearchSpace);
            ho_SearchSpaceDilation.Dispose();
            HOperatorSet.DilationRectangle1(ho_SearchSpace, out ho_SearchSpaceDilation, 14,
                                            1);
            ho_SearchSpaceUnion.Dispose();
            HOperatorSet.Union1(ho_SearchSpaceDilation, out ho_SearchSpaceUnion);
            ho_SearchGray.Dispose();
            HOperatorSet.ReduceDomain(ho_Intensity, ho_SearchSpaceUnion, out ho_SearchGray
                                      );
            ho_SearchMean.Dispose();
            HOperatorSet.MeanImage(ho_SearchGray, out ho_SearchMean, 15, 15);
            ho_PinsRaw.Dispose();
            HOperatorSet.DynThreshold(ho_SearchGray, ho_SearchMean, out ho_PinsRaw, 5, "light");
            ho_PinsConnect.Dispose();
            HOperatorSet.Connection(ho_PinsRaw, out ho_PinsConnect);
            ho_PinsFilled.Dispose();
            HOperatorSet.FillUp(ho_PinsConnect, out ho_PinsFilled);
            ho_Pins.Dispose();
            HOperatorSet.SelectShape(ho_PinsFilled, out ho_Pins, "area", "and", 10, 100);
            ho_Dark.Dispose();
            ho_DarkDilation.Dispose();
            ho_ICLarge.Dispose();
            ho_ICLargeGray.Dispose();
            ho_ICDark.Dispose();
            ho_ICDilation.Dispose();
            ho_SearchSpace.Dispose();
            ho_SearchSpaceDilation.Dispose();
            ho_SearchSpaceUnion.Dispose();
            ho_SearchGray.Dispose();
            ho_SearchMean.Dispose();
            ho_PinsRaw.Dispose();
            ho_PinsConnect.Dispose();
            ho_PinsFilled.Dispose();

            return;
        }