道路自动识别

来源:互联网 发布:weka bp神经网络算法 编辑:程序博客网 时间:2024/05/01 15:24

今天学习了几个halcon的例程,其中一个比较有价值,故摘录再次,以便以后深入学习。这个例程主要利用不断获取到的图像进行道路的车道分析,有可能的话可以实现自动驾驶之类的。

图像打包上传,程序如下:

* autobahn.hdev: Fast detection of lane markers* dev_update_window ('off')dev_close_window ()dev_open_window (0, 0, 768, 575, 'black', WindowID)MinSize := 30*功能:根据HALCON 系统参数获取关于当前的信息get_system ('init_new_image', Information)*功能:HALCON 系统参数的设置set_system ('init_new_image', 'false')*功能:根据行或像素数创建一个区域gen_grid_region (Grid, 3, 3, 'lines', 512, 512)*功能:将一个区域修改为矩形clip_region (Grid, StreetGrid, 130, 10, 450, 502)*dev_set_line_width (3)*dev_set_color ('green')*read_image (ActualImage, 'autobahn/scene_00')*dev_display (ActualImage)stop ()dev_display (StreetGrid)stop ()for i := 0 to 28 by 1    *    read_image (ActualImage, 'autobahn/scene_'+(i$'02'))    *功能:缩小一个图像的区域    reduce_domain (ActualImage, StreetGrid, Mask)    *功能:使用Sobel 算子检测边缘(幅值)。    sobel_amp (Mask, Gradient, 'sum_abs', 3)    *功能:利用全局阀值分割图像    threshold (Gradient, Points, 20, 255)    *功能:扩大一个矩形结构基础的一个区域    dilation_rectangle1 (Points, RegionDilation, MinSize, MinSize)    *功能:缩小一个图像的区域    reduce_domain (ActualImage, RegionDilation, StripGray)        threshold (StripGray, Strip, 190, 255)    *功能:填充区域中的中断(裂缝等)。    fill_up (Strip, RegionFillUp)    dev_display (ActualImage)    dev_display (RegionFillUp)endfordev_set_line_width (1)dev_update_window ('on')set_system ('init_new_image', Information)


原创粉丝点击