Halcon快速读取自定义点云TXT文件

1、ReadPointCloudFromTextfile(::Filename:X,Y,Z)

open_file(Filename,'input',file)

NumColumns := 3
VecOutLine.clear()

repeat
fread_line(file, oneline, IsEOF)
if(IsEOF == 1)
    break        
endif
if(oneline == ' ')
    continue
endif
tuple_str_first_n (oneline, 0, Substring)
if(Substring == '#')
    continue
endif
VecOutLine.at(VecOutLine.length()) := oneline
until (IsEOF)

convert_vector_to_tuple(VecOutLine, P)

P := split(P,' ')

Number := number(regexp_replace(P,'^\\s*0*(.+?)\\s*\n*$','$1'))
P := HNULL

X := Number[[0:NumColumns:|Number|-1]]
Y := Number[[1:NumColumns:|Number|-1]]
Z := Number[[2:NumColumns:|Number|-1]]

close_file(file)
return ()

2、demo

dev_update_off ()

Filename := 'C:/Users/shining3d/Documents/Halcon_demo/Point_0.txt'

X := []
Y := []
Z := []

count_seconds (Then)
ReadPointCloudFromTextfile (Filename, X, Y, Z)
count_seconds (Now)
DurationSeconds := Now - Then
Msg := 'opening file ' + Filename + ' in ' + DurationSeconds + 's'
dev_inspect_ctrl (Msg)

gen_object_model_3d_from_points (X, Y, Z, ObjectModel3D)

X := HNULL
Y := HNULL
Z := HNULL

dev_get_window (WindowHandle)
visualize_object_model_3d (WindowHandle, ObjectModel3D, [], [], [], [], [], [], [], PoseOut)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值