在HDevelop中
dev_close_window ()
read_image (Image, 'D:/bb/tu/1.jpg')
rgb1_to_gray (Image, GrayImage)
edges_sub_pix (GrayImage, Edges, 'canny', 1, 5, 10)
*亚像素边缘
select_shape_xld (Edges, SelectedXLD, ['contlength','area'], 'and', [108,700],[109,800])
get_contour_xld (SelectedXLD, Row, Col)
*返回XLD轮廓的坐标
*参数1:轮廓
*参数2:行坐标--数组
*参数3:列坐标--数组
get_image_size (GrayImage, Width, Height)
dev_open_window(10,10,Width, Height,'black',WindowHandle3)
dev_display(SelectedXLD)
在QtCreator中
HObject ho_Image, ho_GrayImage, ho_Edges, ho_SelectedXLD;
HTuple hv_Row, hv_Col, hv_Width, hv_Height, hv_WindowHandle3;
ReadImage(&ho_Image, "D:/bb/tu/1.jpg");
Rgb1ToGray(ho_Image, &ho_GrayImage);
EdgesSubPix(ho_GrayImage, &ho_Edges, "canny", 1, 5, 10);
//亚像素边缘
SelectShapeXld(ho_Edges, &ho_SelectedXLD, (HTuple("contlength").Append("area")),
"and", (HTuple(108).Append(700)), (HTuple(109).Append(800)));
GetContourXld(ho_SelectedXLD, &hv_Row, &hv_Col);
//返回XLD轮廓的坐标
//参数1:轮廓
//参数2:行坐标--数组
//参数3:列坐标--数组
GetImageSize(ho_GrayImage, &hv_Width, &hv_Height);
SetWindowAttr("background_color","black");
OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle3);
HDevWindowStack::Push(hv_WindowHandle3);
if (HDevWindowStack::IsOpen())
DispObj(ho_SelectedXLD, HDevWindowStack::GetActive());