halcon-union2_closed_contours_xld封闭轮廓_sed

halcon-union2_closed_contours_xld封闭轮廓_连线_02



在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])
select_shape_xld (Edges, SelectedXLD1, ['contlength','area'], 'and', [83,376],[84,377])



union2_closed_contours_xld (SelectedXLD, SelectedXLD, ContoursUnion)
*封闭轮廓
*参数1和参数2就一个轮廓时,轮廓端点直接连线封闭
*参数3:输出轮廓

union2_closed_contours_xld (SelectedXLD, SelectedXLD1, ContoursUnion1)
*参数1和参数2是两个轮廓时,就近封闭


*get_contour_xld

get_image_size (GrayImage, Width, Height)
dev_open_window(10,10,Width, Height,'black',WindowHandle)
dev_display(ContoursUnion)

dev_open_window(10,10,Width, Height,'black',WindowHandle1)
dev_display(SelectedXLD)

dev_open_window(10,10,Width, Height,'black',WindowHandle2)
dev_display(SelectedXLD)
dev_display(SelectedXLD1)

dev_open_window(10,10,Width, Height,'black',WindowHandle3)
dev_display(ContoursUnion1)


halcon-union2_closed_contours_xld封闭轮廓_连线_03






在QtCreator中

HObject  ho_Image, ho_GrayImage, ho_Edges, ho_SelectedXLD;
HObject ho_SelectedXLD1, ho_ContoursUnion, ho_ContoursUnion1;
HTuple hv_Width, hv_Height, hv_WindowHandle;
HTuple hv_WindowHandle1, hv_WindowHandle2, 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)));
SelectShapeXld(ho_Edges, &ho_SelectedXLD1, (HTuple("contlength").Append("area")),
"and", (HTuple(83).Append(376)), (HTuple(84).Append(377)));



Union2ClosedContoursXld(ho_SelectedXLD, ho_SelectedXLD, &ho_ContoursUnion);
//封闭轮廓
//参数1和参数2就一个轮廓时,轮廓端点直接连线封闭
//参数3:输出轮廓

Union2ClosedContoursXld(ho_SelectedXLD, ho_SelectedXLD1, &ho_ContoursUnion1);
//参数1和参数2是两个轮廓时,就近封闭


//get_contour_xld

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_ContoursUnion, 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());

SetWindowAttr("background_color","black");
OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle2);
HDevWindowStack::Push(hv_WindowHandle2);
if (HDevWindowStack::IsOpen())
DispObj(ho_SelectedXLD, HDevWindowStack::GetActive());
if (HDevWindowStack::IsOpen())
DispObj(ho_SelectedXLD1, HDevWindowStack::GetActive());

SetWindowAttr("background_color","black");
OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle3);
HDevWindowStack::Push(hv_WindowHandle3);
if (HDevWindowStack::IsOpen())
DispObj(ho_ContoursUnion1, HDevWindowStack::GetActive());