在HDevelop中
dev_close_window () read_image (Image, 'D:/bb/tu/4.jpg') rgb1_to_gray (Image, GrayImage) edges_sub_pix (GrayImage, Edges, 'canny', 1, 5, 10) *亚像素边缘 select_shape_xld (Edges, SelectedXLD, ['area'], 'and', [14040],[14240]) gen_polygons_xld (SelectedXLD, Polygons, 'ramer', 2) *返回XLD轮廓近似的Polygon get_polygon_xld (Polygons, Row, Col, Length, Phi) *返回XLD轮廓近似Polygon的数据 *参数1:XLD轮廓近似的Polygon *参数2:多边形点的行坐标 *参数3:多边形点的列坐标 *参数4:线段的长度 *参数5:线段的角度 get_image_size (GrayImage, Width, Height) dev_open_window(10,10,Width, Height,'black',WindowHandle3) dev_display(Polygons)
在QtCreator中
HObject ho_Image, ho_GrayImage, ho_Edges, ho_SelectedXLD;
HObject ho_Polygons;
HTuple hv_Row, hv_Col, hv_Length, hv_Phi, hv_Width;
HTuple hv_Height, hv_WindowHandle3;
ReadImage(&ho_Image, "D:/bb/tu/4.jpg"); Rgb1ToGray(ho_Image, &ho_GrayImage); EdgesSubPix(ho_GrayImage, &ho_Edges, "canny", 1, 5, 10); //亚像素边缘 SelectShapeXld(ho_Edges, &ho_SelectedXLD, "area", "and", 14040, 14240); GenPolygonsXld(ho_SelectedXLD, &ho_Polygons, "ramer", 2); //返回XLD轮廓近似的Polygon GetPolygonXld(ho_Polygons, &hv_Row, &hv_Col, &hv_Length, &hv_Phi); //返回XLD轮廓近似Polygon的数据 //参数1:XLD轮廓近似的Polygon //参数2:多边形点的行坐标 //参数3:多边形点的列坐标 //参数4:线段的长度 //参数5:线段的角度 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_Polygons, HDevWindowStack::GetActive());