halcon-gen_polygons_xld返回XLD轮廓近似的Polygon
作者:互联网
在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 *要转化的xld轮廓 *参数2:输出多边形 *参数3:近似类型 * 'ramer' *参数4:近似阈值 get_lines_xld (Polygons, BeginRow, BeginCol, EndRow, EndCol, Length, Phi) *返回XLD轮廓近似Polygon的数据 *参数1:XLD轮廓近似的Polygon *参数2:线条起点的行坐标 *参数3:线条起点的列坐标 *参数4:线条终点的行坐标 *参数5:线条终点的列坐标 *参数6:线条的长度 *参数7:线条的角度 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_BeginRow, hv_BeginCol, hv_EndRow, hv_EndCol; HTuple hv_Length, hv_Phi, hv_Width, 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 //要转化的xld轮廓 //参数2:输出多边形 //参数3:近似类型 // 'ramer' //参数4:近似阈值 GetLinesXld(ho_Polygons, &hv_BeginRow, &hv_BeginCol, &hv_EndRow, &hv_EndCol, &hv_Length, &hv_Phi); //返回XLD轮廓近似Polygon的数据 //参数1:XLD轮廓近似的Polygon //参数2:线条起点的行坐标 //参数3:线条起点的列坐标 //参数4:线条终点的行坐标 //参数5:线条终点的列坐标 //参数6:线条的长度 //参数7:线条的角度 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());
标签:XLD,Polygon,xld,hv,近似,参数,ho,线条 来源: https://www.cnblogs.com/liming19680104/p/16023669.html