1. 程式人生 > 其它 >halcon-write_shape_model儲存形狀模板

halcon-write_shape_model儲存形狀模板

 

在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輪廓模板 write_shape_model (ModelID, 'D:/bb/tu/ss.shm') *儲存形狀模板 *引數1:模板控制代碼 *引數2:檔名 * 副檔名是:shm

 

 


在QtCreator中

  HObject  ho_Image, ho_GrayImage, ho_Edges, ho_SelectedXLD;
  HTuple  hv_ModelID;
  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輪廓模板 WriteShapeModel(hv_ModelID, "D:/bb/tu/ss.shm"); //儲存形狀模板
//引數1:模板控制代碼 //引數2:檔名 // 副檔名是:shm