设为首页收藏本站
授权版本:2024_07
开启左侧

disp_message 参数数量错误

[复制链接]
changgongqi 发表于 2021-6-21 17:07:46 | 显示全部楼层 |阅读模式
* 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 (Row == [] or Column == [])
    return ()
endif
if (Row == -1)
    Row := 12
endif
if (Column == -1)
    Column := 12
endif
*
* Convert the parameter Box to generic parameters.
GenParamName := []
GenParamValue := []
if (|Box| > 0)
    if (Box[0] == 'false')
        * Display no box
        GenParamName := [GenParamName,'box']
        GenParamValue := [GenParamValue,'false']
    elseif (Box[0] != 'true')
        * Set a color other than the default.
        GenParamName := [GenParamName,'box_color']
        GenParamValue := [GenParamValue,Box[0]]
    endif
endif
if (|Box| > 1)
    if (Box[1] == 'false')
        * Display no shadow.
        GenParamName := [GenParamName,'shadow']
        GenParamValue := [GenParamValue,'false']
    elseif (Box[1] != 'true')
        * Set a shadow color other than the default.
        GenParamName := [GenParamName,'shadow_color']
        GenParamValue := [GenParamValue,Box[1]]
    endif
endif
* Restore default CoordSystem behavior.
if (CoordSystem != 'window')
    CoordSystem := 'image'
endif
*
if (Color == '')
    * disp_text does not accept an empty string for Color.
    Color := []
endif
*
disp_message (WindowHandle, String, CoordSystem, Row, Column, Color, GenParamName, GenParamValue)
return ()

在函数disp_message的101行有无效代码行


disp_message (
: : WindowHandle, String, CoordSystem, Row, Column, Color, Box : )

外部函数:
This procedure writes one or multiple text messages.


D:/software/Halcon/programs/HALCON-21.05-Progress/procedures/general/disp_message.hdvp

错误: '参数数量错误' [21207] 位置; 13 到 96
错误的标记

您是否希望继续程序或编辑错误代码行?
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
绝地武士 发表于 2021-6-21 19:36:10 | 显示全部楼层
检查下参数表参数数量:
disp_message( : : WindowHandle, String, CoordSystem, Row, Column, Color, Box : )
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| changgongqi 发表于 2021-6-21 20:38:23 | 显示全部楼层
绝地武士 发表于 2021-6-21 19:36
检查下参数表参数数量:
disp_message( : : WindowHandle, String, CoordSystem, Row, Column, Color, Box  ...

disp_message (WindowID, '面积'+Area+'坐标:'+Row+' '+Column,'window',0,0, 'white', 'false')
上面的是一个列子的,
所有程序跑起来都错误
是不是和版本有关系?我用的是21.05版本
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
绝地武士 发表于 2021-6-21 21:32:34 | 显示全部楼层
changgongqi 发表于 2021-6-21 20:38
disp_message (WindowID, '面积'+Area+'坐标:'+Row+' '+Column,'window',0,0, 'white', 'false')
上面的 ...

微信截图_20210621213148.png
没有任何问题呢?这代码随便怎么都可以过去!
  1. dev_get_window (WindowID)
  2. read_image (Image, 'printer_chip/printer_chip_01')
  3. Area:=520
  4. Row:=200
  5. Column:=200
  6. disp_message (WindowID, '面积'+Area+'坐标:'+Row+' '+Column,'window',0,0, 'white', 'false')
复制代码

奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| changgongqi 发表于 2021-6-21 22:13:35 | 显示全部楼层
绝地武士 发表于 2021-6-21 21:32
没有任何问题呢?这代码随便怎么都可以过去!

在函数disp_message的101行有无效代码行
disp_message ( : : WindowHandle, String, CoordSystem, Row, Column, Color, Box : )
外部函数:
This procedure writes one or multiple text messages.
D:/software/Halcon/programs/HALCON-21.05-Progress/procedures/general/disp_message.hdvp
错误: '参数数量错误' [21207] 位置; 13 到 96
您是否希望继续程序或编辑错误代码行?

我用你的程序跑,上面的这条错误还在。我跑含有disp_messaged()例程时,也会出错。
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| changgongqi 发表于 2021-6-21 22:16:48 | 显示全部楼层
changgongqi 发表于 2021-6-21 22:13
在函数disp_message的101行有无效代码行
disp_message ( : : WindowHandle, String, CoordSystem, Row, C ...
  1. ////这是主程序
  2. * Image Acquisition 02: Code generated by Image Acquisition 02
  3. open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', '[0] USB2.0 VGA UVC WebCam', 0, -1, AcqHandle)
  4. grab_image_start (AcqHandle, -1)
  5. dev_close_window()
  6. dev_open_window(0,0,728,512,'black',WindowID)
  7. while (true)
  8.     grab_image_async (Image, AcqHandle, -1)
  9.     * Image Acquisition 02: Do something
  10.     rgb1_to_gray (Image, GrayImage)
  11.     dev_display (GrayImage)
  12.     threshold (GrayImage, Regions, 82, 255)
  13.     connection (Regions, ConnectedRegions)
  14.    
  15.     select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 21951.2, 200000)
  16.     dev_display (GrayImage)
  17.     dev_display (SelectedRegions)
  18.     area_center (SelectedRegions, Area, Row, Column)
  19.     disp_message (WindowID, '面积'+Area+'坐标:'+Row+' '+Column,'window',0,0, 'white', 'false')
  20.   
  21. endwhile
  22. close_framegrabber (AcqHandle)

  23. ////这是disp_message()
  24. * This procedure displays text in a graphics window.
  25. *
  26. * Input parameters:
  27. * WindowHandle: The WindowHandle of the graphics window, where
  28. *    the message should be displayed.
  29. * String: A tuple of strings containing the text messages to be displayed.
  30. * CoordSystem: If set to 'window', the text position is given
  31. *    with respect to the window coordinate system.
  32. *    If set to 'image', image coordinates are used.
  33. *    (This may be useful in zoomed images.)
  34. * Row: The row coordinate of the desired text position.
  35. *    You can pass a single value or a tuple of values.
  36. *    See the explanation below.
  37. *    Default: 12.
  38. * Column: The column coordinate of the desired text position.
  39. *    You can pass a single value or a tuple of values.
  40. *    See the explanation below.
  41. *    Default: 12.
  42. * Color: defines the color of the text as string.
  43. *    If set to [] or '' the currently set color is used.
  44. *    If a tuple of strings is passed, the colors are used cyclically
  45. *    for every text position defined by Row and Column,
  46. *    or every new text line in case of |Row| == |Column| == 1.
  47. * Box: A tuple controlling a possible box surrounding the text.
  48. *    Its entries:
  49. *    - Box[0]: Controls the box and its color. Possible values:
  50. *      -- 'true' (Default): An orange box is displayed.
  51. *      -- 'false': No box is displayed.
  52. *      -- color string: A box is displayed in the given color, e.g., 'white', '#FF00CC'.
  53. *    - Box[1] (Optional): Controls the shadow of the box. Possible values:
  54. *      -- 'true' (Default): A shadow is displayed in
  55. *                darker orange if Box[0] is not a color and in 'white' otherwise.
  56. *      -- 'false': No shadow is displayed.
  57. *      -- color string: A shadow is displayed in the given color, e.g., 'white', '#FF00CC'.
  58. *
  59. * It is possible to display multiple text strings in a single call.
  60. * In this case, some restrictions apply on the
  61. * parameters String, Row, and Column:
  62. * They can only have either 1 entry or n entries.
  63. * Behavior in the different cases:
  64. *    - Multiple text positions are specified, i.e.,
  65. *        - |Row| == n, |Column| == n
  66. *        - |Row| == n, |Column| == 1
  67. *        - |Row| == 1, |Column| == n
  68. *      In this case we distinguish:
  69. *        - |String| == n: Each element of String is displayed
  70. *                         at the corresponding position.
  71. *        - |String| == 1: String is displayed n times
  72. *                         at the corresponding positions.
  73. *    - Exactly one text position is specified,
  74. *       i.e., |Row| == |Column| == 1:
  75. *       Each element of String is display in a new textline.
  76. *
  77. *
  78. * Convert the parameters for disp_text.
  79. if (Row == [] or Column == [])
  80.     return ()
  81. endif
  82. if (Row == -1)
  83.     Row := 12
  84. endif
  85. if (Column == -1)
  86.     Column := 12
  87. endif
  88. *
  89. * Convert the parameter Box to generic parameters.
  90. GenParamName := []
  91. GenParamValue := []
  92. if (|Box| > 0)
  93.     if (Box[0] == 'false')
  94.         * Display no box
  95.         GenParamName := [GenParamName,'box']
  96.         GenParamValue := [GenParamValue,'false']
  97.     elseif (Box[0] != 'true')
  98.         * Set a color other than the default.
  99.         GenParamName := [GenParamName,'box_color']
  100.         GenParamValue := [GenParamValue,Box[0]]
  101.     endif
  102. endif
  103. if (|Box| > 1)
  104.     if (Box[1] == 'false')
  105.         * Display no shadow.
  106.         GenParamName := [GenParamName,'shadow']
  107.         GenParamValue := [GenParamValue,'false']
  108.     elseif (Box[1] != 'true')
  109.         * Set a shadow color other than the default.
  110.         GenParamName := [GenParamName,'shadow_color']
  111.         GenParamValue := [GenParamValue,Box[1]]
  112.     endif
  113. endif
  114. * Restore default CoordSystem behavior.
  115. if (CoordSystem != 'window')
  116.     CoordSystem := 'image'
  117. endif
  118. *
  119. if (Color == '')
  120.     * disp_text does not accept an empty string for Color.
  121.     Color := []
  122. endif
  123. *
  124. disp_message (WindowHandle, String, CoordSystem, Row, Column, Color, GenParamName, GenParamValue)
  125. return ()
复制代码
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
绝地武士 发表于 2021-6-22 09:55:13 | 显示全部楼层
101行是disp_text函数,你是不是手误替换了函数导致异常了?附件给你,自行替换吧
disp_message.rar (3.07 KB, 下载次数: 24)
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| changgongqi 发表于 2021-6-22 10:58:46 | 显示全部楼层
绝地武士 发表于 2021-6-22 09:55
101行是disp_text函数,你是不是手误替换了函数导致异常了?附件给你,自行替换吧

...

感谢大佬,问题解决了
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表