halcon-create_shape_model_xld創建XLD輪廓模板


  

原理:XLD是亞像素輪廓,XLD輪廓模板匹配,是直接利用灰度變化明顯的地方,進行XLD輪廓提取,生成XLD輪廓模板,然后使用該模板,在目標圖像中進行搜索匹配。

在HDevelop中

dev_close_window ()
read_image (Image, 'D:/bb/tu/1.jpg')
rgb1_to_gray (Image, GrayImage)
edges_sub_pix (GrayImage, Edges, 'canny', 1, 20, 40)
select_shape_xld (Edges, SelectedXLD, 'contlength', 'and', 130, 137.8)


create_shape_model_xld (SelectedXLD, 'auto', -0.2, 0.2, 0.05, 'auto', 'ignore_local_polarity', 5, ModelID)
*創建XLD輪廓模板
*參數1:輸入將用於創建模型的xld輪廓
*參數2:金字塔層級    List of values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'auto'
*參數3:模板起始旋轉角度
*參數4:模板終止旋轉角度
*參數5:角度的步長      限制:角度步長>0和角度步長<=pi/16
*參數6:生成模型的優化和可選方法
*      'auto', 'no_pregeneration', 'none', 'point_reduction_high', 'point_reduction_low'
*      'point_reduction_medium', 'pregeneration'
*參數7:匹配方法設置
*      'ignore_color_polarity', 'ignore_global_polarity', 'ignore_local_polarity', 'use_polarity'
*參數8:設置對比度      建議值:1,2,3,5,7,10,20,30,40
*參數9:模板句柄

find_shape_model (GrayImage, ModelID, -0.2, 0.2, 0.8, 3, 0.5, 'least_squares', 0, 0.9, Row, Column, Angle, Score)

 

 

在QtCreator中

  HObject  ho_Image, ho_GrayImage, ho_Edges, ho_SelectedXLD;
  HTuple  hv_ModelID, hv_Row, hv_Column, hv_Angle;
  HTuple  hv_Score;
  ReadImage(&ho_Image, "D:/bb/tu/1.jpg");
  Rgb1ToGray(ho_Image, &ho_GrayImage);
  EdgesSubPix(ho_GrayImage, &ho_Edges, "canny", 1, 20, 40);
  SelectShapeXld(ho_Edges, &ho_SelectedXLD, "contlength", "and", 130, 137.8);


  CreateShapeModelXld(ho_SelectedXLD, "auto", -0.2, 0.2, 0.05, "auto", "ignore_local_polarity", 
      5, &hv_ModelID);
  //創建XLD輪廓模板
  //參數1:輸入將用於創建模型的xld輪廓
  //參數2:金字塔層級    List of values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'auto'
  //參數3:模板起始旋轉角度
  //參數4:模板終止旋轉角度
  //參數5:角度的步長      限制:角度步長>0和角度步長<=pi/16
  //參數6:生成模型的優化和可選方法
  //     'auto', 'no_pregeneration', 'none', 'point_reduction_high', 'point_reduction_low'
  //     'point_reduction_medium', 'pregeneration'
  //參數7:匹配方法設置
  //     'ignore_color_polarity', 'ignore_global_polarity', 'ignore_local_polarity', 'use_polarity'
  //參數8:設置對比度      建議值:1,2,3,5,7,10,20,30,40
  //參數9:模板句柄

  FindShapeModel(ho_GrayImage, hv_ModelID, -0.2, 0.2, 0.8, 3, 0.5, "least_squares", 
      0, 0.9, &hv_Row, &hv_Column, &hv_Angle, &hv_Score);

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM