当前位置:网站首页>Visual system design example (Halcon WinForm) -9. text display
Visual system design example (Halcon WinForm) -9. text display
2022-07-27 14:49:00 【11eleven】
After detecting the image, we need to mark the result with text output , Mark OK perhaps NG And other notes .C# Call in halcon Of HOperatorSet.DispText Has been an error .
The code is as follows :
public static void Disp_message(HTuple hv_WindowHandle, HTuple hv_String, HTuple hv_CoordSystem,
HTuple hv_Row, HTuple hv_Column, HTuple hv_Color, HTuple hv_Box)
{
// Local iconic variables
// Local control variables
HTuple hv_GenParamName = new HTuple(), hv_GenParamValue = new HTuple();
HTuple hv_Color_COPY_INP_TMP = new HTuple(hv_Color);
HTuple hv_Column_COPY_INP_TMP = new HTuple(hv_Column);
HTuple hv_CoordSystem_COPY_INP_TMP = new HTuple(hv_CoordSystem);
HTuple hv_Row_COPY_INP_TMP = new HTuple(hv_Row);
// Initialize local and output iconic variables
try
{
//This procedure displays text in a graphics window.
//
//Input parameters:
//WindowHandle: The WindowHandle of the graphics window, where
// the message should be displayed.
//String: A tuple of strings containing the text messages to be displayed.
//CoordSystem: If set to 'window', the text position is given
// with respect to the window coordinate system.
// If set to 'image', image coordinates are used.
// (This may be useful in zoomed images.)
//Row: The row coordinate of the desired text position.
// You can pass a single value or a tuple of values.
// See the explanation below.
// Default: 12.
//Column: The column coordinate of the desired text position.
// You can pass a single value or a tuple of values.
// See the explanation below.
// Default: 12.
//Color: defines the color of the text as string.
// If set to [] or '' the currently set color is used.
// If a tuple of strings is passed, the colors are used cyclically
// for every text position defined by Row and Column,
// or every new text line in case of |Row| == |Column| == 1.
//Box: A tuple controlling a possible box surrounding the text.
// Its entries:
// - Box[0]: Controls the box and its color. Possible values:
// -- 'true' (Default): An orange box is displayed.
// -- 'false': No box is displayed.
// -- color string: A box is displayed in the given color, e.g., 'white', '#FF00CC'.
// - Box[1] (Optional): Controls the shadow of the box. Possible values:
// -- 'true' (Default): A shadow is displayed in
// darker orange if Box[0] is not a color and in 'white' otherwise.
// -- 'false': No shadow is displayed.
// -- color string: A shadow is displayed in the given color, e.g., 'white', '#FF00CC'.
//
//It is possible to display multiple text strings in a single call.
//In this case, some restrictions apply on the
//parameters String, Row, and Column:
//They can only have either 1 entry or n entries.
//Behavior in the different cases:
// - Multiple text positions are specified, i.e.,
// - |Row| == n, |Column| == n
// - |Row| == n, |Column| == 1
// - |Row| == 1, |Column| == n
// In this case we distinguish:
// - |String| == n: Each element of String is displayed
// at the corresponding position.
// - |String| == 1: String is displayed n times
// at the corresponding positions.
// - Exactly one text position is specified,
// i.e., |Row| == |Column| == 1:
// Each element of String is display in a new textline.
//
//
//Convert the parameters for disp_text.
if ((int)((new HTuple(hv_Row_COPY_INP_TMP.TupleEqual(new HTuple()))).TupleOr(
new HTuple(hv_Column_COPY_INP_TMP.TupleEqual(new HTuple())))) != 0)
{
hv_Color_COPY_INP_TMP.Dispose();
hv_Column_COPY_INP_TMP.Dispose();
hv_CoordSystem_COPY_INP_TMP.Dispose();
hv_Row_COPY_INP_TMP.Dispose();
hv_GenParamName.Dispose();
hv_GenParamValue.Dispose();
return;
}
if ((int)(new HTuple(hv_Row_COPY_INP_TMP.TupleEqual(-1))) != 0)
{
hv_Row_COPY_INP_TMP.Dispose();
hv_Row_COPY_INP_TMP = 12;
}
if ((int)(new HTuple(hv_Column_COPY_INP_TMP.TupleEqual(-1))) != 0)
{
hv_Column_COPY_INP_TMP.Dispose();
hv_Column_COPY_INP_TMP = 12;
}
//
//Convert the parameter Box to generic parameters.
hv_GenParamName.Dispose();
hv_GenParamName = new HTuple();
hv_GenParamValue.Dispose();
hv_GenParamValue = new HTuple();
if ((int)(new HTuple((new HTuple(hv_Box.TupleLength())).TupleGreater(0))) != 0)
{
if ((int)(new HTuple(((hv_Box.TupleSelect(0))).TupleEqual("false"))) != 0)
{
//Display no box
using (HDevDisposeHelper dh = new HDevDisposeHelper())
{
{
HTuple
ExpTmpLocalVar_GenParamName = hv_GenParamName.TupleConcat(
"box");
hv_GenParamName.Dispose();
hv_GenParamName = ExpTmpLocalVar_GenParamName;
}
}
using (HDevDisposeHelper dh = new HDevDisposeHelper())
{
{
HTuple
ExpTmpLocalVar_GenParamValue = hv_GenParamValue.TupleConcat(
"false");
hv_GenParamValue.Dispose();
hv_GenParamValue = ExpTmpLocalVar_GenParamValue;
}
}
}
else if ((int)(new HTuple(((hv_Box.TupleSelect(0))).TupleNotEqual(
"true"))) != 0)
{
//Set a color other than the default.
using (HDevDisposeHelper dh = new HDevDisposeHelper())
{
{
HTuple
ExpTmpLocalVar_GenParamName = hv_GenParamName.TupleConcat(
"box_color");
hv_GenParamName.Dispose();
hv_GenParamName = ExpTmpLocalVar_GenParamName;
}
}
using (HDevDisposeHelper dh = new HDevDisposeHelper())
{
{
HTuple
ExpTmpLocalVar_GenParamValue = hv_GenParamValue.TupleConcat(
hv_Box.TupleSelect(0));
hv_GenParamValue.Dispose();
hv_GenParamValue = ExpTmpLocalVar_GenParamValue;
}
}
}
}
if ((int)(new HTuple((new HTuple(hv_Box.TupleLength())).TupleGreater(1))) != 0)
{
if ((int)(new HTuple(((hv_Box.TupleSelect(1))).TupleEqual("false"))) != 0)
{
//Display no shadow.
using (HDevDisposeHelper dh = new HDevDisposeHelper())
{
{
HTuple
ExpTmpLocalVar_GenParamName = hv_GenParamName.TupleConcat(
"shadow");
hv_GenParamName.Dispose();
hv_GenParamName = ExpTmpLocalVar_GenParamName;
}
}
using (HDevDisposeHelper dh = new HDevDisposeHelper())
{
{
HTuple
ExpTmpLocalVar_GenParamValue = hv_GenParamValue.TupleConcat(
"false");
hv_GenParamValue.Dispose();
hv_GenParamValue = ExpTmpLocalVar_GenParamValue;
}
}
}
else if ((int)(new HTuple(((hv_Box.TupleSelect(1))).TupleNotEqual(
"true"))) != 0)
{
//Set a shadow color other than the default.
using (HDevDisposeHelper dh = new HDevDisposeHelper())
{
{
HTuple
ExpTmpLocalVar_GenParamName = hv_GenParamName.TupleConcat(
"shadow_color");
hv_GenParamName.Dispose();
hv_GenParamName = ExpTmpLocalVar_GenParamName;
}
}
using (HDevDisposeHelper dh = new HDevDisposeHelper())
{
{
HTuple
ExpTmpLocalVar_GenParamValue = hv_GenParamValue.TupleConcat(
hv_Box.TupleSelect(1));
hv_GenParamValue.Dispose();
hv_GenParamValue = ExpTmpLocalVar_GenParamValue;
}
}
}
}
//Restore default CoordSystem behavior.
if ((int)(new HTuple(hv_CoordSystem_COPY_INP_TMP.TupleNotEqual("window"))) != 0)
{
hv_CoordSystem_COPY_INP_TMP.Dispose();
hv_CoordSystem_COPY_INP_TMP = "image";
}
//
if ((int)(new HTuple(hv_Color_COPY_INP_TMP.TupleEqual(""))) != 0)
{
//disp_text does not accept an empty string for Color.
hv_Color_COPY_INP_TMP.Dispose();
hv_Color_COPY_INP_TMP = new HTuple();
}
//
HOperatorSet.DispText(hv_WindowHandle, hv_String, hv_CoordSystem_COPY_INP_TMP,
hv_Row_COPY_INP_TMP, hv_Column_COPY_INP_TMP, hv_Color_COPY_INP_TMP, hv_GenParamName,
hv_GenParamValue);
//HOperatorSet.SetTposition(hv_WindowHandle, hv_Row_COPY_INP_TMP, hv_Column_COPY_INP_TMP);
//HOperatorSet.WriteString(hv_WindowHandle, hv_String);
hv_Color_COPY_INP_TMP.Dispose();
hv_Column_COPY_INP_TMP.Dispose();
hv_CoordSystem_COPY_INP_TMP.Dispose();
hv_Row_COPY_INP_TMP.Dispose();
hv_GenParamName.Dispose();
hv_GenParamValue.Dispose();
return;
}
catch (HalconException HDevExpDefaultException)
{
hv_Color_COPY_INP_TMP.Dispose();
hv_Column_COPY_INP_TMP.Dispose();
hv_CoordSystem_COPY_INP_TMP.Dispose();
hv_Row_COPY_INP_TMP.Dispose();
hv_GenParamName.Dispose();
hv_GenParamValue.Dispose();
throw HDevExpDefaultException;
}
}

HalconDotNet.HOperatorException:“HALCON error #5123: Wrong window type in operator disp_text”, No suitable solution was found , Say it's official BUG, Try to use WriteString Discovery can be used , The concise code is as follows :
imgSource.HControl.hWindowCtrl.HalconWindow.SetTposition(result.LoactionY.ToInt(), result.LoactionX.ToInt());// Set the output position
imgSource.HControl.hWindowCtrl.HalconWindow.SetColor(result.Color);// Set the color
imgSource.HControl.hWindowCtrl.HalconWindow.SetFont("-Mono-Bold-40-");// Set the font
imgSource.HControl.hWindowCtrl.HalconWindow.WriteString(result.Message);// Output content
Set the font completely without deformation :.SetFont($"-Arial-50-*-1-*-*-1-") 50 Is font size

边栏推荐
- 基于GEC6818开发板的相册
- Advanced MySQL III. storage engine
- 【科普】精度和分辨率的区别与联系
- Chinese character style transfer --- antagonistic discriminative domain adaptation (L1)
- @What happens when bean and @component are used on the same class?
- 自动化配置SSH免密登录和取消SSH免密配置脚本
- lc marathon 7.26
- DXGI 方式采集流程
- STM32 - capacitive touch button experiment
- Kubernetes 节点磁盘故障排查
猜你喜欢

Dynamic programming - stock trading 5

Slam overview Reading Note 7: visual and visual intangible slam: state of the art, classification, and empirical 2021

The interviewer asked: how to judge whether an element is in the visible area?

巨形象的图解 SQL
![[intensive reading of papers] grounded language image pre training (glip)](/img/3a/4ad136065acb8627df9e064ed8ef32.png)
[intensive reading of papers] grounded language image pre training (glip)

telnet远程登录aaa模式详解【华为eNSP】

Construction of knowledge map of financial securities and discovery of related stocks from the perspective of knowledge relevance

【STM32】EXTI

SLAM综述阅读笔记四:A Survey on Deep Learning for Localization and Mapping: Towards the Age of Spatial 2020

文献翻译__tvreg v2:用于去噪、反卷积、修复和分割的变分成像方法(部分)
随机推荐
【科普】精度和分辨率的区别与联系
Timestamp of AAC, h264, etc
大家最想要的,最全的C语言知识点总结,还不赶紧学习
aac 和 h264等的时间戳
进程间通信
The difference between [x for X in list_a if not np.isnan (x)] and [x if not np.isnan (x) else none for X in list_a]
MySQL advanced II. Logical architecture analysis
DVWA全级别通关教程
np. Usage and difference of range() and range()
通过VN1630/VN7640的I/O功能来确认电源设置电压的时间精确度
Architecture - the sublimation of MVC
Summary of basic knowledge of C language
DirectX 入门知识
Navicate reports an error access violation at address 00000000
Slam overview Reading Note 6: slam research based on image semantics: application-oriented solutions for autonomous navigation of mobile robots 2020
C language layered understanding (C language array)
PROFINET simulator tutorial
Is there a regular and safe account opening platform for gold speculation
Tencent two sides: @bean and @component are used in the same class, what will happen?
2022年中国网络视频市场年度综合分析