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
原文地址:https://www.cnblogs.com/amosyang/p/8435168.html