Halcon一日一练:获取程序运行时间
很多时候,我们需要知道每个函数的运算周期,以提高程序的运行效率。知道运行时间对于图像算法处理很重要
Halcon提供相关的算子,我们先来看代码:
**获取图像处理时间 read_image(Image,'fuse')//读取图像 count_seconds(Seconds)//读取时间 threshold(Image, Region, 128, 255)//阈值分割 count_seconds(Seconds1)//读取时间 PTime:=(1000*(Seconds-Seconds1))//计算阈值分割时间 count_seconds(Seconds2)//读取时间 auto_threshold(Image, Regions, 2)//自动阈值分割 count_seconds(Seconds3)//读取时间 PTime2:=(1000*(Seconds3-Seconds2))//计算自动阈值分割时间
count_seconds()是当前的系统时间,这个时间的值以秒为单位,PTime计算的时间是以毫秒单位。实际上这两个算子都是在毫秒内完成的。
下面看一下控制延时的算子:wai_seconds()的用法。我们设置延时1秒。
**延时一秒 Image_Name:=['adhesive_bead_01','adhesive_bead_02','adhesive_bead_03','adhesive_bead_04','adhesive_bead_05',\ 'adhesive_bead_06','adhesive_bead_07','adhesive_bead_ref']//设置图像 read_image(Image,'bead/'+Image_Name)//读取图像 channels_to_image(Image,Image)//把单通道图像转换为一个多通道图像 count_channels(Image, Channels)//计算图像通道 for index:=1 to Channels by 1 access_channel(Image,Channel,index)//获取多通道图像的一个通道 dev_display(Channel) wait_seconds(1)//等待一秒 endfor phot_stereo(Image,Height,[30,30,30,45,60,60,60,45],[0,90,180,0,0,90,180,270]) for Index:=0 to 360 by 8 shade_height_field(Height, ImageShade, 45, Index, 1, 0, 'false') dev_display(ImageShade) endfor
专注机器视觉
分类:
Halcon一日一练
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现