• halconget_polygon_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
    
    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());

  • 相关阅读:
    分享
    慕课网-软件测试基础-学习笔记
    向量内积(点乘)和外积(叉乘)概念及几何意义
    使用opencv3+python实现视频运动目标检测
    解决opencv3运行opencv2代码时报错的修改备忘录
    分享
    OpenCV学习笔记
    LeetCode
    LeetCode
    npm安装包很慢
  • 原文地址:https://www.cnblogs.com/liming19680104/p/16029375.html
Copyright © 2020-2023  润新知