当前位置:网站首页>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

边栏推荐
- Airport cloud business sign analysis
- Dynamic programming - stock trading 5
- 2022牛客多校二_ E I
- SkyWalking分布式系统应用程序性能监控工具-中
- MySQL advanced II. Logical architecture analysis
- [popular science] the difference and connection between accuracy and resolution
- 架构——MVC的升华
- Hard deduction SQL statement exercises, wrong question records
- Shell programming specifications and variables
- Construction and empirical research of post talent demand analysis framework based on recruitment advertisement
猜你喜欢

Nokia's patent business was hit for the first time, and Chinese enterprises are not so easy to knead

股票买卖4

Summary of basic knowledge of C language

PROFINET simulator tutorial

JS epidemic at home, learning can't stop, 7000 word long text to help you thoroughly understand the prototype and prototype chain

2022年中国网络视频市场年度综合分析

架构——MVC的升华
![Detailed explanation of Telnet remote login AAA mode [Huawei ENSP]](/img/48/dd0fa3c494c45f604b7a93c707b808.png)
Detailed explanation of Telnet remote login AAA mode [Huawei ENSP]

Navicate reports an error access violation at address 00000000

Thread knowledge summary
随机推荐
Understand JS execution context in an article
codeforces 1708E - DFS Trees
Secondary spanning tree [template]
这年头谁还不会抓包,WireShark 抓包及常用协议分析送给你!
Nokia's patent business was hit for the first time, and Chinese enterprises are not so easy to knead
巨形象的图解 SQL
User question understanding and answer content organization for epidemic disease Science Popularization
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]
Why is there no unified quotation for third-party testing fees of software products?
Hdu4496 d-city [concurrent search]
codeforces 1708E - DFS Trees
Is the security of online brokerage app account opening guaranteed?
PROFINET 模拟器使用教程
Database storage series (1) column storage
Forward proxy and reverse proxy
SLAM综述阅读笔记七:Visual and Visual-Inertial SLAM: State of the Art, Classification,and Experimental 2021
Why does script file 'd:\anaconda3\envs\pad appear_ env\Scripts\pip-script. py‘ is not present.
Is there a regular and safe account opening platform for gold speculation
Basic exercises of C language
@Bean 与 @Component 用在同一个类上,会发生什么?