当前位置: 首页 > article >正文

Halcon tiff 点云读取以及平面矫正

一、读取tiff 图


dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)

xResolution:=0.0025
yResolution:=0.0025
zResolution:=0.001
read_image (IntputImage, 'C:/Users/alber/Desktop/2023-08-15_16-38-24-982_/Sta5_002.tif')
zoom_image_factor (IntputImage, IntputImage, 1,4, 'constant')
get_domain (IntputImage, Domain)
*获取该区域的最大最小值
min_max_gray (Domain, IntputImage, 0, Min, Max, Range)
*去除无效数据
threshold (IntputImage, Region,-1.2, Max)
reduce_domain (IntputImage, Region, ImageReduced)

get_image_size (ImageReduced, Width, Height)
convert_image_type (ImageReduced, ImageConvertedX, 'real')
*生成xy坐标的图像映射,乘以分辨率就是xy的相对值
gen_image_surface_first_order (ImageSurface, 'real', 1, 0, 0, 0, 0, Width, Height)
gen_image_surface_first_order (ImageSurface1, 'real', 0, 1, 0, 0, 0, Width, Height)
scale_image (ImageSurface, X, xResolution, 0)
scale_image (ImageSurface1, Y, yResolution, 0)

*创建3D模型
xyz_to_object_model_3d (Y,X,ImageReduced, ObjectModel3D)
write_object_model_3d (ObjectModel3D, 'ply', 'C:/Users/alber/Desktop/abc.ply', [], [])
disp_object_model_3d (WindowHandle, [ObjectModel3D], [], [], ['color_0','alpha'], ['green',0.7])

二、平面矫正

用Z轴来矫正


select_points_object_model_3d (ObjectModel3D, 'point_coord_x', 2.73, 3.2, ObjectModel3DThresholded)
select_points_object_model_3d (ObjectModel3DThresholded, 'point_coord_y', 1, 3.4, ObjectModel3DThresholded)
fit_primitives_object_model_3d (ObjectModel3DThresholded, ['primitive_type','fitting_algorithm'], ['plane','least_squares_tukey'], ObjectModel3DOut)

* 这一步很重要
get_object_model_3d_params (ObjectModel3DOut, 'primitive_parameter_pose', pose)


 *用Z轴来矫正
 * 将旋转的角度转转回去
 pose[3]:=-pose[3]
 pose[4]:=-pose[4]
 pose[5]:=-pose[5]
write_object_model_3d (ObjectModel3DThresholded, 'ply', 'C:/Users/alber/Desktop/abc3333.ply', [], [])
*
rigid_trans_object_model_3d (ObjectModel3DThresholded, pose, ObjectModel3DRigidTrans)
write_object_model_3d (ObjectModel3DRigidTrans, 'ply', 'C:/Users/alber/Desktop/abc3333afffff.ply', [], [])


rigid_trans_object_model_3d (ObjectModel3D, pose, ObjectModel3DRigidProdUCE)
write_object_model_3d (ObjectModel3DRigidProdUCE, 'ply', 'C:/Users/alber/Desktop/ABC_CR.ply', [], [])

三、 从一个姿态转到指定的姿态

1、将原始姿态pose ->matrix1

2、将指定的姿态pose 2->matrix2

3、svd  矩阵分解,计算出两个姿态的差接矩阵M

4、矩阵-》pose

5、rigid_trans_object_model_3d

矫正前:

矫正后:

 

 

全部代码:


dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)

xResolution:=0.0025
yResolution:=0.0025
zResolution:=0.001
read_image (IntputImage, 'C:/Users/alber/Desktop/2023-08-15_16-38-24-982_/Sta5_002.tif')
zoom_image_factor (IntputImage, IntputImage, 1,4, 'constant')
get_domain (IntputImage, Domain)
*获取该区域的最大最小值
min_max_gray (Domain, IntputImage, 0, Min, Max, Range)
*去除无效数据
threshold (IntputImage, Region,-1.2, Max)
reduce_domain (IntputImage, Region, ImageReduced)

get_image_size (ImageReduced, Width, Height)
convert_image_type (ImageReduced, ImageConvertedX, 'real')
*生成xy坐标的图像映射,乘以分辨率就是xy的相对值
gen_image_surface_first_order (ImageSurface, 'real', 1, 0, 0, 0, 0, Width, Height)
gen_image_surface_first_order (ImageSurface1, 'real', 0, 1, 0, 0, 0, Width, Height)
scale_image (ImageSurface, X, xResolution, 0)
scale_image (ImageSurface1, Y, yResolution, 0)

*创建3D模型
xyz_to_object_model_3d (Y,X,ImageReduced, ObjectModel3D)
write_object_model_3d (ObjectModel3D, 'ply', 'C:/Users/alber/Desktop/abc.ply', [], [])
disp_object_model_3d (WindowHandle, [ObjectModel3D], [], [], ['color_0','alpha'], ['green',0.7])



select_points_object_model_3d (ObjectModel3D, 'point_coord_x', 2.73, 3.2, ObjectModel3DThresholded)
select_points_object_model_3d (ObjectModel3DThresholded, 'point_coord_y', 1, 3.4, ObjectModel3DThresholded)
fit_primitives_object_model_3d (ObjectModel3DThresholded, ['primitive_type','fitting_algorithm'], ['plane','least_squares_tukey'], ObjectModel3DOut)

* 这一步很重要
get_object_model_3d_params (ObjectModel3DOut, 'primitive_parameter_pose', pose)


 *用Z轴来矫正
 * 将旋转的角度转转回去
 pose[3]:=-pose[3]
 pose[4]:=-pose[4]
 pose[5]:=-pose[5]
write_object_model_3d (ObjectModel3DThresholded, 'ply', 'C:/Users/alber/Desktop/abc3333.ply', [], [])
*
rigid_trans_object_model_3d (ObjectModel3DThresholded, pose, ObjectModel3DRigidTrans)
write_object_model_3d (ObjectModel3DRigidTrans, 'ply', 'C:/Users/alber/Desktop/abc3333afffff.ply', [], [])


rigid_trans_object_model_3d (ObjectModel3D, pose, ObjectModel3DRigidProdUCE)
write_object_model_3d (ObjectModel3DRigidProdUCE, 'ply', 'C:/Users/alber/Desktop/ABC_CR.ply', [], [])

pose_compose (pose, pose, PoseCompose)

svd_matrix (, 'full', 'both', MatrixUID, MatrixSID, MatrixVID)


http://www.kler.cn/a/154596.html

相关文章:

  • rust高级特征
  • SAFETY LAYERS IN ALIGNED LARGE LANGUAGEMODELS: THE KEY TO LLM SECURITY
  • JMeter与大模型融合应用之JMeter日志分析服务化实战应用
  • hive alter table add columns 是否使用 cascade 的方案
  • 【miniMax开放平台-注册安全分析报告-无验证方式导致安全隐患】
  • 嵌入式硬件电子电路设计(五)MOS管详解(NMOS、PMOS、三极管跟mos管的区别)
  • 算法工程师面试八股(搜广推方向)
  • jenkins使用nexus插件
  • 如何创建一个vue工程
  • CSS浅谈动画性能
  • 密码学学习笔记(二十二):RSA签名方案
  • CC2530basic_Rf串口无线收发
  • [蓝桥杯 2020 省 AB1] 解码
  • 已解决AttributeError: module ‘gradio‘ has no attribute ‘outputs‘
  • Java集合类的重要性
  • 误用STM32串口发送标志位 “USART_FLAG_TXE” “USART_FLAG_TC”造成的BUG
  • GPT实战系列-大模型训练和预测,如何加速、降低显存
  • 【涨薪技术】深入接口测试之Mock技术
  • 关于STM32G0 FLASH 写入时出现PGSERR的一种处理办法
  • n个整数存放在一个一维数组A中,任选一种程序设计语言,编写一个函数,利用递归的方法,求数组中各整数的平均值
  • 状态模式-C++实现
  • 使用java批量生成Xshell session(*.xsh)文件
  • Unity对接后台和加载图片
  • 4.4-Docker bridge0详解
  • oracle FUNCTION(任意两个时间 之间的工作小时)
  • 游戏被流量攻击会有什么样的影响,该用什么样的防护方式去处理