zoukankan      html  css  js  c++  java
  • halcon学习笔记——实例篇(2)长度和角度测量

    实例二:长度和角度测量

    素材图片:

    图

    halcon代码:

       1: *读取并截取图片
       2: dev_close_window()
       3: read_image (Image, 'D:/MyFile/halcon/长度和角度测量/图.png')
       4: crop_rectangle1 (Image, ImagePart, 75, 0, 400, 400)
       5: get_image_size (ImagePart, Width, Height)
       6: dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
       7: dev_display (ImagePart)
       8:  
       9: *获取图形的边界
      10: threshold (ImagePart, Regions, 0, 112)
      11:  
      12: *分离三角形和圆形
      13: connection(Regions,ConnectedRegions)
      14: sort_region(ConnectedRegions,SortedRegions,'upper_left','true','column')
      15: select_obj(SortedRegions,Circle,1)
      16: select_obj(SortedRegions,Triangle,2)
      17:  
      18: *获取三角形各边的信息
      19: skeleton(Triangle,TriangleSkeleton)
      20: gen_contours_skeleton_xld(TriangleSkeleton,TriangleContours,1,'filter')
      21: segment_contours_xld(TriangleContours,ContoursSplit,'lines_circles', 5, 4, 2)
      22: select_contours_xld(ContoursSplit,SelectedContours, 'contour_length',100, 999, -0.5, 0.5)
      23: fit_line_contour_xld (SelectedContours, 'tukey', -1, 10, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
      24:  
      25: *计算三角形角度
      26: angle_ll (RowBegin[0], ColBegin[0], RowEnd[0], ColEnd[0], RowBegin[1], ColBegin[1], RowEnd[1], ColEnd[1], Angle1)
      27: angle_ll (RowBegin[0], ColBegin[0], RowEnd[0], ColEnd[0], RowBegin[2], ColBegin[2], RowEnd[2], ColEnd[2], Angle2)
      28: angle_ll (RowBegin[1], ColBegin[1], RowEnd[1], ColEnd[1], RowBegin[2], ColBegin[2], RowEnd[2], ColEnd[2], Angle3)
      29: Angle1:=abs(deg(Angle1))
      30: Angle2:=abs(deg(Angle2))
      31: Angle3:=abs(deg(Angle3))
      32:  
      33: *获取圆的信息
      34: area_center(Circle,AreaCircle, RowCircle, ColumnCircle)
      35:  
      36: *计算圆心到三角形各边的距离
      37: Distance := []
      38: for Index := 0 to 2 by 1
      39:     distance_pl (RowCircle, ColumnCircle, RowBegin[Index], ColBegin[Index], RowEnd[Index], ColEnd[Index], ThisDistance)
      40:     Distance := [Distance,ThisDistance]
      41: endfor
  • 相关阅读:
    国内DP厂家的相关资料信息
    【转】挟天子以令诸侯博客关于TCP/IP模型与OSI模型的区别
    TMS320CC657基本外围电路调试
    TMS320C6657双核DSP的图像处理系统开发(1):硬件相关tips
    TI c6657开发资源
    PCIE接口的说明
    Flash Builder4注册机
    myeclipse 方法上加上@Override就报错的处理方法
    oracle安装完成后目录中不论有没有tnsnames.ora和listener.ora文件 PLSQL都能连上的问题解决方法
    POJO和javabean的区别
  • 原文地址:https://www.cnblogs.com/hanzhaoxin/p/2910338.html
Copyright © 2011-2022 走看看