halcon中的一些不常见算子或者代码的学习(一)

(一) 字典

这个可以和C#中的Dictionary类比,它是由key来访问存储的元素。

和C#的字典区别只是,halcon中的这个字典只接收Htuple, 和Object两种类型。


下面的程序演示了写入与读取Htuple, Object类型的数据。

create_dict(DictHandle)

read_image(Image, 'printer_chip/printer_chip_01')
set_dict_object(Image, DictHandle, 'img1')
set_dict_tuple(DictHandle,'windows' , 1024)
set_dict_tuple(DictHandle,'linux' , 'false')
set_dict_tuple(DictHandle,'os2' , 'this is a test')
get_dict_tuple(DictHandle,'windows', t1)
get_dict_tuple(DictHandle,'linux', t2)
get_dict_tuple(DictHandle,'os2', t3)
get_dict_object(Object, DictHandle, 'img1')


(二)字符串数组赋值

下面的代码类似于:

msg:=''

msg[0]:='lxy1'

msg[1]:='lxy2'

dev_close_window()
dev_open_window(0, 0, 512, 512, 'black', WindowHandle)
txt:='this is '
txt[|txt|]:='windows,'
txt[|txt|]:='linux'
dev_set_color('red')
dev_disp_text(txt, 'window', 'top', 'left', 'black', [], [])

image.png


(三)多张图片平铺显示


PillBagPath1 := 'pill_bag/pill_bag_001'
PillBagPath2 := 'pill_bag/pill_bag_002'
read_image (Image, [PillBagPath1,PillBagPath2])
tile_images (Image, TiledImage, 2, 'horizontal')

image.png


(四)图像区域叠加与绘制


overpaint_gray ( ImageDestination, ImageSource : : : )

将灰度值不相同区域用不同颜色绘制到ImageDestination中, ImageSource包含希望的灰度值图像

overpaint_region ( Image, Region : : Grayval, Type : )

将Region以一个恒定的灰度值绘制到Image图像中

paint_gray ( ImageSource, ImageDestination : MixedImage : : )

将ImageSource的图像绘制到ImageDestination中,形成MixedImage。

paint_region ( Region, Image : ImageResult : Grayval, Type : )

将Region以一个恒定的灰度值绘制到Image图像中

paint_xld ( XLD, Image : ImageResult : Grayval : )

将XLD以一个恒定的灰度值绘制到Image图像中

set_grayval ( Image : : Row, Column, Grayval : )

设置Image图像中坐标为(Row,Column)的灰度值

read_image (Image, 'G:/Halcon/images/images/claudia.png')
gen_circle (Circle, 200, 200, 100.5)
reduce_domain (Image, Circle, ImageReduced)
gen_image_proto (Image, ImageCleared, 32)
overpaint_gray (ImageCleared, ImageReduced)
gen_image_const (Image1, 'byte', 512, 512)
overpaint_region (Image1, Circle, 255, 'fill')
* /* Copy a circular part of the image  into the image : */
read_image (Image2, 'G:/Halcon/images/images/brycecanyon1.png')
paint_gray (ImageReduced, Image2, MixedImage)
* /* Paint a rectangle into the image  */
read_image (Image3, 'G:/Halcon/images/images/pads.png')
gen_rectangle1 (Rectangle1, 30, 20, 100, 200)
paint_region (Rectangle1, Image3, ImageResult, 255, 'fill')
* /* Paint colored xld objects into a gray image */
* /* read and copy image to generate a three channel image */
copy_image (Image2, image0)
copy_image (Image2, image1)
compose3 (image0, Image2, image1, MultiChannelImage)
* /* extract subpixel border */
threshold_sub_pix (MultiChannelImage, Border, 128)
* /* select the circle and the arrows */
circle := Border[14]
arrow := Border[16]
ObjectsConcat := [circle,arrow]
* /* paint a green circle and white arrows (to paint all
* * objects e.g. blue, pass [0,0,255] tuple for GrayVal) */
paint_xld (ObjectsConcat, MultiChannelImage, ImageResult1, [0,1,0,1,1,255])



未完待续。。。。。


--------------------- 

作者:hackpig

来源:www.skcircle.com

版权声明:本文为博主原创文章,转载请附上博文链接!


本文出自勇哥的网站《少有人走的路》wwww.skcircle.com,转载请注明出处!讨论可扫码加群:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

会员中心
搜索
«    2024年3月    »
123
45678910
11121314151617
18192021222324
25262728293031
网站分类
标签列表
最新留言
    热门文章 | 热评文章 | 随机文章
文章归档
友情链接
  • 订阅本站的 RSS 2.0 新闻聚合
  • 扫描加本站机器视觉QQ群,验证答案为:halcon勇哥的机器视觉
  • 点击查阅微信群二维码
  • 扫描加勇哥的非标自动化群,验证答案:C#/C++/VB勇哥的非标自动化群
  • 扫描加站长微信:站长微信:abc496103864
  • 扫描加站长QQ:
  • 扫描赞赏本站:
  • 留言板:

Powered By Z-BlogPHP 1.7.2

Copyright Your skcircle.com Rights Reserved.

鄂ICP备18008319号


站长QQ:496103864 微信:abc496103864