机器视觉 dev_set_check算子
Posted 沧海一笑-dj
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了机器视觉 dev_set_check算子相关的知识,希望对你有一定的参考价值。
00. 目录
01. 概述
dev_set_check - 指定HDevelop中的错误处理方式。
02. 签名
dev_set_check( : : Mode : )
03. 描述
dev_set_check指定在发生错误时HDevelop如何应对,即如果算子的返回状态不是H_MSG_TRUE(2)。
如果Mode的值是’give_error’—这是系统默认值—则一个错误的算子调用会抛出一个异常,这个异常在HDevelop程序中可以被catch语句捕获到。 但是,如果在HDevelop程序中没有周围的try-catch块,而且程序在HDevelop中运行,则程序在错误的算子处停止运行,并且打开错误消息框以显示错误文本。 另外,相应的调用的算子被输入到“算子窗口”中,使得用户可以容易地编辑并且可能修正错误的算子调用的参数。 如果该程序是从HDevEngine调用的,并且该异常未在HDevelop程序中捕获,则会抛出一个HDevEngineException对象,并退出该程序。
如果Mode设置为’〜give_error’,则错误将被忽略,程序继续运行下一个算子。 dev_set_check(’〜give_error’)旨在与dev_error_var一起使用,dev_error_var可以检查算子调用返回的结果状态。
原文描述:
dev_set_check specifies how HDevelop has to react in case of an error, i.e., if the return state of an operator is not H_MSG_TRUE (2).
If Mode has the value ‘give_error’—which is the system default—an erroneous operator call will throw an exception, that can be caught within the HDevelop program by the catch statement. However, if there is no surrounding try-catch block in the HDevelop program and the program is executed within HDevelop, the program execution stops at the erroneous operator and an error message box is opened to display the error text. In addition, the appropriate operator call is entered into the ‘Operator Window’, so that the user can easily edit and possibly correct the parameters of the erroneous operator call. If the procedure was called from HDevEngine and the exception is not caught within the HDevelop program, an HDevEngineException object is thrown and the procedure is left.
If Mode is set to ‘~give_error’, the error will be ignored and the program continues with the next operator. dev_set_check(’~give_error’) is intended to be used in connection with dev_error_var, which allows to check the result state that is returned by the operator calls.
04. 注意
使用HDevelop的代码导出功能,为该算子生成的代码可能与相关的HALCON算子具有不同的行为。 有关将HDevelop图形算子(graphics operators)导出为不同编程语言的代码的详细说明,请参阅’HDevelop User’s Guide’中的’Code Export -> General Aspects of Code Generation -> Graphics Windows’一章。
05. 参数
Mode (input_control) string → (string)
错误处理的模式。
Default value: ‘give_error’
06. 结果
如果指定参数的值正确,则dev_set_check返回2(H_MSG_TRUE)。 否则会引发异常并返回错误代码。
HDevelop例程
sock_recv.hdev Receive image and tuple data via socket connection
projective_trans_image.hdev Apply projective transformations to an image
get_rectangle_pose_barcode.hdev Estimate 3D pose of bar codes
get_mposition.hdev Query mouse position and button status
error_handling_timeout.hdev Handle grab errors
dev_set_check.hdev Enable/Disable error handling in HDevelop
dev_error_var.hdev Catch errors in HDevelop
cbm_sbm.hdev Compare component-based matching to shape-based matching
cbm_param_visual.hdev Analyze the parameters of component-based matching
cbm_bin_switch.hdev Locate a switch and test its state using component-based matching
bottlet.hdev Train numbers on a beer bottle
3d_position_of_rectangle.hdev Estimate 3D pose of rectangular objects
程序示例
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
dev_error_var (Error, 1)
dev_set_check ('~give_error')
FileName := 'wrong_name'
read_image (Image, FileName)
ReadError := Error
if (ReadError != H_MSG_TRUE)
write_string (WindowHandle, 'wrong file name: '+FileName)
endif
* Now the program will stop with an exception
dev_set_check ('give_error')
read_image (Image, FileName)
07. 附录
7.1 机器视觉博客汇总
网址:https://dengjin.blog.csdn.net/article/details/116837497
以上是关于机器视觉 dev_set_check算子的主要内容,如果未能解决你的问题,请参考以下文章