在HDevelop中
dev_close_window ()
read_image (Image, 'D:/bb/tu/6.jpg')
rgb1_to_gray (Image, GrayImage)
edges_sub_pix (GrayImage, Edges, 'canny', 1, 5, 10)
*亚像素边缘
select_shape_xld (Edges, SelectedXLD, 'area', 'and', 5500, 5600)
*根据形状特征选择轮廓
*参数1:轮廓集
*参数2:选中的轮廓
*参数3:形状特征
* 'area': 轮廓的面积---默认
* 'area_points': 轮廓点的面积
* 'row': 中心的行索引
* 'column': 中心的列索引
* 'width': 轮廓的宽度
* 'height': 轮廓的高度
* 'ratio': 轮廓的高度与宽度之比
* 'row1': 左上角的行坐标
* 'column1': 左上角的列坐标
* 'row2': 右下角的行坐标
* 'column2': 右下角的列坐标
* 'circularity': 圆度
* 'compactness': 紧凑度
* 'contlength': 轮廓总长度
* 'convexity': 凸性
* 'ra': 等效椭圆的大半径
* 'rb': 等效椭圆的小半径
* 'phi': 等效椭圆的方向
* 'outer_radius': 最小外接圆半径
* 'max_diameter': 最大直径
* 'orientation': 轮廓的方向--弧度为单位
* 'rect2_phi': 最小外接矩形角度
* 'rect2_len1': 最小外接矩形长度的一半
* 'rect2_len2': 最小外接矩形宽度的一半
*参数4:特征之间的逻辑关系 (and or)
*参数5和参数6:Min,Max特征值的要求范围
get_image_size (GrayImage, Width, Height)
dev_open_window(10,10,Width, Height,'black',WindowHandle)
dev_display(Edges)
dev_open_window(10,10,Width, Height,'black',WindowHandle1)
dev_display(SelectedXLD)
在QtCreator中
HObject ho_Image, ho_GrayImage, ho_Edges, ho_SelectedXLD;
HTuple hv_Width, hv_Height, hv_WindowHandle;
HTuple hv_WindowHandle1;
ReadImage(&ho_Image, "D:/bb/tu/6.jpg");
Rgb1ToGray(ho_Image, &ho_GrayImage);
EdgesSubPix(ho_GrayImage, &ho_Edges, "canny", 1, 5, 10);
//亚像素边缘
SelectShapeXld(ho_Edges, &ho_SelectedXLD, "area", "and", 5500, 5600);
//根据形状特征选择轮廓
//参数1:轮廓集
//参数2:选中的轮廓
//参数3:形状特征
// 'area': 轮廓的面积---默认
// 'area_points': 轮廓点的面积
// 'row': 中心的行索引
// 'column': 中心的列索引
// 'width': 轮廓的宽度
// 'height': 轮廓的高度
// 'ratio': 轮廓的高度与宽度之比
// 'row1': 左上角的行坐标
// 'column1': 左上角的列坐标
// 'row2': 右下角的行坐标
// 'column2': 右下角的列坐标
// 'circularity': 圆度
// 'compactness': 紧凑度
// 'contlength': 轮廓总长度
// 'convexity': 凸性
// 'ra': 等效椭圆的大半径
// 'rb': 等效椭圆的小半径
// 'phi': 等效椭圆的方向
// 'outer_radius': 最小外接圆半径
// 'max_diameter': 最大直径
// 'orientation': 轮廓的方向--弧度为单位
// 'rect2_phi': 最小外接矩形角度
// 'rect2_len1': 最小外接矩形长度的一半
// 'rect2_len2': 最小外接矩形宽度的一半
//参数4:特征之间的逻辑关系 (and or)
//参数5和参数6:Min,Max特征值的要求范围
GetImageSize(ho_GrayImage, &hv_Width, &hv_Height);
SetWindowAttr("background_color","black");
OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle);
HDevWindowStack::Push(hv_WindowHandle);
if (HDevWindowStack::IsOpen())
DispObj(ho_Edges, HDevWindowStack::GetActive());
SetWindowAttr("background_color","black");
OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle1);
HDevWindowStack::Push(hv_WindowHandle1);
if (HDevWindowStack::IsOpen())
DispObj(ho_SelectedXLD, HDevWindowStack::GetActive());