1 學習halcon的準備工作
1.1 圖片及文件讀取
1.1.1 知識點
主要講述了絕對路徑、相對路徑(兩種方法)、文件夾讀取。
1.1.2 實現代碼:
read_image (Image, 'C:/Users/Administrator/Desktop/2345截圖20190830212142.png')
read_image (Image1, '1.jpg')
list_files ('E:/halcon', 'files', Files)
for Index := 0 to 5 by 1
read_image (Image2, Files[Index])
endfor
1.2 圖片動態選擇及視頻讀取
#1.2.1 程序代碼
dev_open_file_dialog ('read_image', 'default', 'default', Selection)
read_image (Image, Selection)
open_framegrabber ('File', 1, 1, 0, 0, 0, 0, 'default', 0, 'rgb', 'default', 'default', 'default', 3, -1, -1, AcqHandle)
1.3 算子介紹
1.3.1 知識點
備註(dev都是和界面有關的算子)
1.3.2 程序代碼
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
draw_circle (WindowHandle, Row, Column, Radius)
gen_circle (Circle, Row, Column, Radius)
*面積
region_features (Circle, 'area', Value)
1.4 數組的創建及基本運算
1.4.1 知識點
1.4.2 程序代碼
*矩陣賦值運算
A:=[]
A:=[1]
A:=[A,1]
A:=[A,[1,2,3]]
C:=A+1
D:=C+A
L:=|A|
VAL:=A[6]
tuple_length (A, Length)
dev_open_file_dialog ('read_image', 'default', 'default', Selection)
read_image (Image, Selection)
rgb1_to_gray (Image, GrayImage)
get_domain (GrayImage, Domain)
get_region_points (Domain, Rows, Columns)
get_image_size (GrayImage, Width, Height)
gen_image_const (Image1, 'byte', Width, Height)
*獲取圖像的灰度
get_grayval (Image1, Rows, Columns, Grayval)
*設置圖像的灰度
set_grayval (Image1, Rows, Columns, 255)
1.5 矩陣的運算與創建
1.5.1知識點
備註(性能激活測評起:測量算子運行時間,矩陣運算時間長)
1.5.2程序代碼
*矩陣創建A:=[1,2,3,4,5,6,7,8,,9]
create_matrix (3, 3, [1,2,3,4,5,6,7,8,9], MatrixID)
*矩陣獲0行0列取值
get_value_matrix (MatrixID, 0, 0, Value)
*獲取矩陣所有值
get_full_matrix (MatrixID, Values)
*求矩陣逆
invert_matrix (MatrixID, 'general', 0, MatrixInvID)
get_full_matrix (MatrixInvID, Values1)
*矩陣範數
norm_matrix (MatrixInvID, '2-norm', Value1)