技術雜談|HALCON算子封裝新函數(shù)
創(chuàng)建新函數(shù):將多個算子封裝成一個新的函數(shù)

mean_image (Image, ImageMean, mean_width, mean_height)
reduce_domain (ImageMean, Rectangle, ImageReduced)
threshold (ImageReduced, Region, 78, 255)
area_center (Region, Area, Row, Column)

也可以在菜單欄中創(chuàng)建

定義新函數(shù)名稱

點擊圖中“參數(shù)”,刪減參數(shù),把不用的參數(shù)刪掉即可

生成的新函數(shù)

選中函數(shù)右鍵鼠標 選擇顯示函數(shù)可以查看封裝的Halcon算子

比如不需要Area參數(shù)名 將其移除后點擊應用


參數(shù)介紹:
圖標參數(shù):一般Region、Image、XLD等都屬于圖標參數(shù)。
控制參數(shù):一般數(shù)據(jù)、字符串都屬于控制參數(shù)。

以上Halcon函數(shù)介紹完畢。
public void Centera (HObject ho_Image, HObject ho_Rectangle, out HObject ho_ImageMean,
????? out HObject ho_ImageReduced, out HObject ho_Region, HTuple hv_mean_width, HTuple hv_mean_height,
????? out HTuple hv_Row, out HTuple hv_Column)
? {
??? // Local control variables
??? HTuple hv_Area = new HTuple();
??? // Initialize local and output iconic variables
??? HOperatorSet.GenEmptyObj(out ho_ImageMean);
??? HOperatorSet.GenEmptyObj(out ho_ImageReduced);
??? HOperatorSet.GenEmptyObj(out ho_Region);
??? hv_Row = new HTuple();
??? hv_Column = new HTuple();
??? ho_ImageMean.Dispose();
??? HOperatorSet.MeanImage(ho_Image, out ho_ImageMean, hv_mean_width, hv_mean_height);
??? ho_ImageReduced.Dispose();
??? HOperatorSet.ReduceDomain(ho_ImageMean, ho_Rectangle, out ho_ImageReduced);
??? ho_Region.Dispose();
??? HOperatorSet.Threshold(ho_ImageReduced, out ho_Region, 78, 255);
??? hv_Area.Dispose();hv_Row.Dispose();hv_Column.Dispose();
??? HOperatorSet.AreaCenter(ho_Region, out hv_Area, out hv_Row, out hv_Column);
? }