优化VisionPro中添加标签,区域,字符显示速度

Optimizing Graphics Performance Cognex VisionPro

This topic contains the following sections:

Disable Graphics Updates Whenever Possible
Minimize Use of Expensive Shapes
Fastest: Rectilinear Shapes
Medium Speed: Curved Shapes
Slowest: Graphics Containing Text
Remove Graphics When Changing Image or Fitting Display
Use Interactive Graphics
Consider Alternatives to CreateResultGraphics()
Optimize the Order of Operations

VisionPro provides a rich set of graphic shapes and functions for displaying these shapes on a CogDisplay. The number and complexity of shapes that your application creates can affect the time and computing resources required to display these graphics. The guidelines described in this topic can help you obtain the best performance possible.

Disable Graphics Updates Whenever Possible

In general, whenever you make a change to a CogDisplay, the display will immediately update its appearance to reflect the change. If you are making multiple changes, such as adding or removing graphics or supplying a new image to display, you can greatly reduce the amount of time required to make these changes by setting DrawingEnabled to false, making all of the changes, then setting DrawingEnabled to true.

Minimize Use of Expensive Shapes

Different types of VisionPro shapes require different amounts of time to display. You can improve display performance by minimizing the use of shapes that are costly to display. When considering the time required for display, VisionPro shapes can be divided into the three categories listed below:

Fastest: Rectilinear Shapes

Shapes made up exclusively of straight lines such as CogLineSegment, CogRectangle, and CogRectangleAffine require the least amount of time to display.

Medium Speed: Curved Shapes

Shapes that contain circular or elliptical shapes such as CogCircle, CogEllipticalArc, and CogEllipticalAnnulusSection take more time to display than rectilinear shapes. For shapes of comparable size and complexity, shapes with circular or elliptical features take about twice as long to display as rectilinear shapes.

Slowest: Graphics Containing Text

Any graphics that include text, such as CogCoordinateAxes, are substantially slower to render than shapes without text. For example, a CogCoordinateAxes graphic might take up to as much as 100 times longer to render than a CogRectangle.

Remove Graphics When Changing Image or Fitting Display

Changing a display’s image or Fit an image to the display region can take two or three times as long to perform if any graphics are present in the CogDisplay’s InteractiveGraphics or StaticGraphics collection.

You can improve the speed of these operations by clearing graphics first, performing the operation, then restoring the graphics.

In addition to changing the displayed image and fitting the image to the display area, the process of zooming or scaling the image takes much longer if graphics are present.

Use Interactive Graphics

The time required to render a VisionPro graphic shape is the same regardless of whether the shape is added to a [T:Cognex.VisionPro.Display/CogDisplay]'s InteractiveGraphics or StaticGraphics collection. The time required to add or remove a graphic, however, is greater for static graphics than for interactive graphics. Therefore, for best performance, add all your graphics to the interactive graphics collection. (You can prevent a user from manipulating a graphic in the interactive collection by setting the graphic’s Interactive property to false.)

Consider Alternatives to CreateResultGraphics()

The CreateResultGraphics method implemented by many tools’ results objects produces a graphics collection that contains result graphics that correspond to each result produced by the tool. You can use the appropriate bits defined in the tool’s ResultGraphicConstants enumeration to limit the graphics that are created, but in many cases the overhead of creating the composite graphics that link all of the graphics associated with a single result and the time required to generate data such as strings for graphic tool tips, can result in slow display performance.

As an alternative, you can consider generating your own custom result graphics based on the data in a tool’s results object. Doing this gives you a finer degree of control over the graphics that are produced for a tool’s results.

Optimize the Order of Operations

As you apply the guidelines in this topic to your application, you should keep in mind that the order in which you perform graphics and display operations determines how much time these operations require. For example, if your application acquires an image, runs a vision tool using that image as input, then wishes to display that image overlaid with result graphics from the tool, it should perform these actions in this order:

Disable display updates (set DrawingEnabled to false).
Remove all graphics from the display.
Update the display with the new image.
Fit the image to the display (if required).
Add the results graphics produced by the last run of the tool.
Enable display updates.
By performing these steps in this order, you minimize the total amount of time required to display the image and graphics.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
在VB显示VisionPro图像并显示框线,您可以使用Cognex.VisionPro.Display.CogDisplay控件和Cognex.VisionPro.ToolGroup.CogToolGroup类来实现。 以下是一个示例代码,演示如何在VB显示VisionPro图像并显示框线: ```vb Imports Cognex.VisionPro Imports Cognex.VisionPro.ToolGroup Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' 创建CogDisplay控件并设置其大小和位置 Dim cogDisplay As New Cognex.VisionPro.Display.CogDisplay() cogDisplay.Size = New Size(800, 600) cogDisplay.Location = New Point(10, 10) ' 创建CogToolGroup对象并加载VisionPro工具配置文件 Dim cogToolGroup As New CogToolGroup() cogToolGroup.LoadTool("path_to_your_tool_file.vpp") ' 创建CogImage对象并加载图像文件 Dim cogImage As New CogImageFile() cogImage.Open("path_to_your_image.bmp") ' 在CogImage上运行CogToolGroup以进行图像处理 cogToolGroup.Inputs("InputImage").Value = cogImage cogToolGroup.Run() ' 在CogDisplay上显示处理后的图像和框线 cogDisplay.Image = cogToolGroup.Outputs("OutputImage").Value cogDisplay.StaticGraphics.Add(cogToolGroup.CreateLastRunRecord().SubRecords.Item("YourRegionName").CreateGraphics()) ' 将CogDisplay控件添加到窗体 Me.Controls.Add(cogDisplay) End Sub End Class ``` 请注意,您需要将代码的"path_to_your_tool_file.vpp"替换为您实际的VisionPro工具配置文件路径,将"path_to_your_image.bmp"替换为您实际的图像文件路径,并将"YourRegionName"替换为实际的区域名称。此示例代码将在窗体加载时显示VisionPro图像,并在CogDisplay上显示经过处理的图像和框线。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值