瓶子个数计数halcon
文章目录
- 处理要求
- 处理方法一
- 源码
- 效果
- 方法二
- 源码
- 效果
|
处理要求
查找纸箱内瓶子个数
处理方法一
源码
dev_clear_window ()
dev_open_window (0, 0, 640*1.5, 512*1.5, 'black', WindowHandle)
* Image Acquisition 01: Code generated by Image Acquisition 01
list_files ('F:/HALCON/瓶盖识别/1', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
for Index := 0 to |ImageFiles| - 1 by 1read_image (Image, ImageFiles[Index])* Image Acquisition 01: Do somethingmean_image (Image, ImageMean, 19, 19)sub_image (ImageMean, Image, ImageSub, 1, 1)mean_image (ImageSub, ImageMean1, 19, 19)dyn_threshold (ImageSub, ImageMean1, RegionDynThresh, 4, 'light')connection (RegionDynThresh, ConnectedRegions)select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 711.57, 20000) select_shape (SelectedRegions, SelectedRegions1, ['width','height'], 'and', [0,0], [200,200])union1 (SelectedRegions1, RegionUnion)closing_circle (RegionUnion, RegionClosing, 20)fill_up (RegionClosing, RegionFillUp)difference (RegionFillUp, RegionClosing, RegionDifference)connection (RegionDifference, ConnectedRegions1) count_obj (ConnectedRegions1, Number)dev_display (Image)dev_display (ConnectedRegions1)set_display_font (WindowHandle, 50, 'mono', 'true', 'false')disp_message (WindowHandle, ['箱内有瓶:']+[Number], 'image', 30, 30, ['blue'], 'false') stop()endfor
效果
方法二
源码
list_files ('F:/HALCON/瓶盖识别/2', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
for Index := 0 to |ImageFiles| - 1 by 1read_image (Image, ImageFiles[Index])smooth_image(Image, ImageSmooth, 'deriche2', 0.5)edges_color_sub_pix(ImageSmooth, Edges, 'canny', 2, 10, 20)segment_contours_xld(Edges, ContoursSplit, 'lines_circles', 5, 5, 3)union_cocircular_contours_xld(ContoursSplit, UnionContours, 0.5, 0.1, 0.2, 30, 10, 10, 'true', 1)select_shape_xld (UnionContours, SelectedXLD1, ['ra','rect2_len1','circularity'], 'and', [15,30,0.3], [50,65,1])fit_circle_contour_xld(SelectedXLD1, 'algebraic', -1, 0, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder)gen_circle_contour_xld(ContCircle, Row, Column, Radius, 0, 6.28318, 'positive', 1)select_shape_xld (ContCircle, SelectedXLD, ['ra','area'], 'or', [36,3200], [50,5000])dev_display(Image)dev_display(SelectedXLD)stop()
endfor
效果
------------------------------------------------------------------------------------------分割线
------------------------------------------------------------------------------------------
|
|
瓶子个数计数halcon相关推荐
- 用户输入的数是否为合数php,php怎么判断一个数是不是素数?
质数又称素数.一个大于1的自然数,除了1和它自身外,不能被其他自然数整除的数叫做质数:否则称为合数.(注:1不是素数.)那么php怎么判断一个数是不是素数?下面本篇文章就来给大家介绍一下. 下面我们就 ...
- 教你用OpenCV和Python实现手掌检测和手掌计数
点击上方"码农的后花园",选择"星标" 公众号 精选文章,第一时间送达 最近号主由于某些原因,并没有定期更新,但是一直记着你们呢,你们只要记住号主与你们同在 ...
- Scipy Lecture Notes学习笔记(一)Getting started with Python for science 1.2. The Python language
Scipy Lecture Notes学习笔记(一)Getting started with Python for science 1.2. The Python language 1.2.2. 基本 ...
- linux上使用FTP下载文件
项目需求要去一个文件服务器下载对账文件,保存至我们系统的前置服务器.然后其他厂商连入我们的前置服务器,将文件取走进行解析. 脚本完成后,又细想了一下,我的脚本如果获取不到文件,就会在后台一直运行.这样 ...
- Linux cgroup机制分析之cpuset subsystem
------------------------------------------ 本文系本站原创,欢迎转载! 转载请注明出处:http://ericxiao.cublog.cn/ -------- ...
- C语言13567星号如何输出,c语言程序编程心得
c语言程序设计 本课介绍c语言程序设计的基本方法和基本的程序语句. 从程序流程的角度来看,程序可以分为三种基本结构,即顺序结构.分支结构.循环结构.这三种基本结构可以组成所有的各种复杂程序.c语言提供 ...
- Hark的数据结构与算法练习之基数排序
算法说明 基数排序是基于计数排序的,所以看这个之前要先看一下计数排序对于理解基数排序是很有帮助的(发现计数和基数的音节几乎一致啊).这个我有写,请点击. OK,现在你肯定已经熟悉了计数排序,那么我就来 ...
- python小结价格_036 Python进阶小结
目录 一.数据类型内置方法 1.1 数字类型内置方法 1.1.1 整形 1.1.2 浮点型 1.2 字符串类型内置方法 1.3 列表类型内置方法 1.4 元组类型内置方法 1.5 字典类型内置方法 1 ...
- 基于直方图的图像增强算法(HE、CLAHE、Retinex)
直方图是图像色彩统计特征的抽象表述.基于直方图可以实现很多有趣的算法.例如,图像增强中利用直方图来调整图像的对比度.有人利用直方图来进行大规模无损数据隐藏.还有人利用梯度直方图HOG来构建图像特征进而 ...
最新文章
- 使用ssh工具链接mysql_mycli辅助工具-更方便得通过ssh tunnel连接线上MySQL
- Maven项目加载JAR包
- Axure tabstrip and different control
- 2019年6月SAP发布的未来ABAP平台的发展方向
- Bash数组变量的赋值
- md5 算法java实现_java实现MD5算法
- java hdfs 指定用户目录_HDFS目录(文件 )权限管理
- ROS笔记(5) ROS架构
- 一瓶可乐的自动售货机指令“旅程”
- VB讲课笔记14:二级VB知识点总结
- c++窗口管理系统是什么_维维华东食品饮料公司电能管理系统的设计与应用——安科瑞 戴玥...
- 深度学习15-Google涂鸦识别挑战项目(下)
- Codeforces #123D: 后缀数组+单调栈
- 被Redis击穿的一次面试经历
- AndroidStudio插件GsonFormat快速实现JavaBean
- tomcat访问html文件
- 双硬盘双win10互不干扰_双硬盘装WIN7 WIN10双系统
- 2022保研经验帖——吉大、华师、浙大、中大、南航/理、东南、南开等
- 【Akka】Akka 学习 akka 两本书的读后感
- 潭州学院html学习(day03)