Halcon测量:人机交互

Halcon测量

摘要

  功能

手动拖拽测量矩形进行测量

  基本步骤如下

1.加载图像
2.创建测量矩形
3.人机交互

Halcon代码:

*1 图像加载
dev_close_window ()
read_image (Image, '工件2.bmp')
get_image_size (Image, Width, Height)
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
dev_set_color ('green')
dev_display (Image)

set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()

*2 创建测量矩形
create_drawing_object_rectangle2 (300, 530, rad(90), 90, 20, DrawID)
set_drawing_object_params (DrawID, 'color', 'red')
* Attach the drawing object and the image to the window
attach_drawing_object_to_window (WindowHandle, DrawID)
attach_background_to_window (Image, WindowHandle)
get_font (WindowHandle, Font)

*3 交互
Button := 0
while (Button != 4)
    try
        perform_measurement (Image, DrawID, Width, Height, RowEdge, ColumnEdge)
        display_results (RowEdge, ColumnEdge, WindowHandle)
        * Check the mouse position and button
        get_mposition (WindowHandle, Row, Column, Button)
    catch (Exception)
        * Keep waiting until mouse button is
        * positioned in the window
    endtry
endwhile
* 
* Detach the drawing objects
dev_clear_window ()
detach_drawing_object_from_window (WindowHandle, DrawID)
detach_background_from_window (WindowHandle)
* Clear the drawing objects
clear_drawing_object (DrawID)
* dev_set_preferences ('suppress_handled_exceptions_dlg', SuppressExceptDlg)

dev_clear_window ()
dev_display (Image)
disp_message (WindowHandle, 'The drawing object has been cleared', 'window', 10, 10, 'red', 'false')

在这里插入图片描述

更多详情了解:https://blog.csdn.net/qq_32015315/article/details/141663063

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值