2021-04-08 Halcon进阶【02】 几何计量【多目标测量】
生活随笔
收集整理的這篇文章主要介紹了
2021-04-08 Halcon进阶【02】 几何计量【多目标测量】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?在Halcon進階【01】 幾何計量【矩形測量】一文中,講述最基本的幾何物體測量,本文講述對上個問題的擴充;遇到多個物體如何測量,這里先給出目標圖片和代碼:
下面代碼測量了矩形和園,請學習的同學將橢圓的代碼也加進去。
read_image (Image, 'rect3') rgb1_to_gray(Image,Image) create_metrology_model (MetrologyHandle) get_image_size (Image, Width, Height) set_metrology_model_image_size (MetrologyHandle, Width, Height) add_metrology_object_rectangle2_measure (MetrologyHandle, 172.3, 239.2, rad(11.609), 146.7, 50.9, 10, 2, 1, 30, [], [], Index)add_metrology_object_circle_measure(MetrologyHandle, 73.2, 105.746, 40.497, 10, 4, 1, 30, [], [], Index1)apply_metrology_model (Image, MetrologyHandle)get_metrology_object_result (MetrologyHandle, Index, 'all', 'result_type', 'all_param', Rectangle) get_metrology_object_result_contour (Contour, MetrologyHandle, Index, 'all', 1.5)get_metrology_object_result (MetrologyHandle, Index1, 'all', 'result_type', 'all_param', Circle) get_metrology_object_result_contour (Contour, MetrologyHandle, Index1, 'all', 1.5) clear_metrology_model (MetrologyHandle)本文給出兩個被測量物體,然后用相同方式進行測量,讀者可以對照兩文,將圖中的橢圓測量也加進去。這樣,基本的套路您已經掌握了。
將上述代碼改成下面樣子(僅僅追加了兩句語句):
read_image (Image, 'rect3') rgb1_to_gray(Image,Image) create_metrology_model (MetrologyHandle) get_image_size (Image, Width, Height) set_metrology_model_image_size (MetrologyHandle, Width, Height) add_metrology_object_rectangle2_measure (MetrologyHandle, 172.3, 239.2, rad(11.609), 146.7, 50.9, 10, 2, 1, 30, [], [], Index)add_metrology_object_circle_measure(MetrologyHandle, 73.2, 105.746, 40.497, 10, 4, 1, 30, [], [], Index1) apply_metrology_model (Image, MetrologyHandle)get_metrology_object_result (MetrologyHandle, Index, 'all', 'result_type', 'all_param', Rectangle) get_metrology_object_result_contour (Contour, MetrologyHandle, Index, 'all', 1.5)get_metrology_object_result (MetrologyHandle, Index1, 'all', 'result_type', 'all_param', Circle) get_metrology_object_result_contour (Contour, MetrologyHandle, Index1, 'all', 1.5)get_metrology_object_measures (Contour, MetrologyHandle, 'all', 'all', Row1, Column1) gen_cross_contour_xld (Cross, Row1, Column1, 6, 0.785398)clear_metrology_model (MetrologyHandle)結果如下:
這個結果表明,無論測量矩形幾何參量,或是園的幾何參量,都是通過微小的測量矩形進行邊界采樣完成的。
總結
以上是生活随笔為你收集整理的2021-04-08 Halcon进阶【02】 几何计量【多目标测量】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Halcon知识: 矩形测量
- 下一篇: 2021-04-15 深入理解SLAM技