HSystem.SetSystem("temporary_mem_cache","false");会导致软件闪退
尝试读取或写入受保护的内存解决方案
list_image_files ('F:/A.H_halcon/检测', 'default', [], ImageFiles)
for i:=0 to |ImageFiles| - 1 by 1
read_image (Image,ImageFiles)
rgb1_to_gray (Image, GrayImage)
gray_opening_rect (GrayImage, ImageOpening, 1, 7)
sub_image (GrayImage, ImageOpening, ImageSub, 1, 128)
gray_closing_rect (ImageSub, ImageClosing, 11, 1)
threshold (ImageClosing, Region, 128+9, 255)
connection (Region, ConnectedRegions)
dev_display (GrayImage)
select_shape (ConnectedRegions, SelectedRegions, 'height', 'and', 30, 99999)
smallest_rectangle2 (SelectedRegions, Row, Column, Phi, Length1, Length2)
dev_display (GrayImage)
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
dev_set_draw ('margin')
endfor