halcon-area_center返回区域的面积和中心位置
作者:互联网
在HDevelop中
2.png
dev_open_window(10,10,193,143,'black',WindowHandle) read_image (Image, 'D:/bb/tu/2.png') rgb1_to_gray(Image,Image1) threshold (Image1, Region, 120, 180) area_center (Region, Area, Row, Column) *返回区域的面积和中心位置 *参数1:输入对象,即被测区域 *参数2:输出变量,即被测区域的面积 *参数3:输出变量,即被测区域中心的行索引 *参数4:输出变量,即被测区域中心的列索引 dev_display (Region)
在QtCreator中
HObject ho_Image, ho_Image1, ho_Region; HTuple hv_WindowHandle, hv_Area, hv_Row, hv_Column;
SetWindowAttr("background_color","black"); OpenWindow(10,10,193,143,0,"visible","",&hv_WindowHandle); HDevWindowStack::Push(hv_WindowHandle); ReadImage(&ho_Image, "D:/bb/tu/2.png"); Rgb1ToGray(ho_Image, &ho_Image1); Threshold(ho_Image1, &ho_Region, 120, 180); AreaCenter(ho_Region, &hv_Area, &hv_Row, &hv_Column); //返回区域的面积和中心位置 //参数1:输入对象,即被测区域 //参数2:输出变量,即被测区域的面积 //参数3:输出变量,即被测区域中心的行索引 //参数4:输出变量,即被测区域中心的列索引 if (HDevWindowStack::IsOpen()) DispObj(ho_Region, HDevWindowStack::GetActive());
标签:center,area,Region,hv,halcon,区域,ho,Image1,Image 来源: https://www.cnblogs.com/liming19680104/p/15938000.html