【机器视觉】 dev_set_check算子
00. 目錄
文章目錄
- 00. 目錄
- 01. 概述
- 02. 簽名
- 03. 描述
- 04. 注意
- 05. 參數
- 06. 結果
- 07. 附錄
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算子的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【机器视觉】 dev_get_syste
- 下一篇: 【机器视觉】 dev_close_ins