几何尺寸与公差论坛

 找回密码
 注册
查看: 1115|回复: 4

visionpro画多个掩膜,滚轮缩放很卡怎么办

  [复制链接]
发表于 2023-1-24 13:21:44 | 显示全部楼层 |阅读模式
如果您在VisionPro画掩膜滚轮缩放时,发现卡顿,建议您:  1. 尽量减少要缩放的像素点数,因为缩放受限于你电脑的硬件性能;  2. 您也可以在设置中将平滑过滤模式设置为“线型”来提高速度;  3. 您可以更新您的电脑硬件,比如更高配置的CPU,更大的显存以及高速的显卡,以提升图像处理的效率;  4. 您可以尝试使用双核CPU,它可以提高缩放效率。
 楼主| 发表于 2023-2-9 20:44:18 | 显示全部楼层
I try to use CogMaskGraphic to draw one plane with green color, but run very slow when zoom the picture with lots of CogMaskGraphic, how to solve the problem?
 楼主| 发表于 2023-2-9 20:44:42 | 显示全部楼层
When working with large images, it's not uncommon to experience performance issues when drawing many graphics, especially when zooming in and out. Here are a few tips to optimize the performance:

    Reduce the number of graphics: Try to reduce the number of graphics you are using. Consider combining multiple graphics into a single graphic if possible.

    Use efficient graphic types: Different graphic types have different performance characteristics. Use the most efficient type for your needs. For example, using a CogRectangle or CogPolygon instead of a CogMaskGraphic can result in improved performance.

    Use caching: The CogMaskGraphic class supports caching, which can significantly improve performance. By enabling caching, the graphic is only recalculated when the image changes, rather than every time the image is drawn. To enable caching, set the CogMaskGraphic.EnableCaching property to true.

    Use a lower-resolution image: If you are zoomed in on a high-resolution image, the graphics may take longer to render. Consider using a lower-resolution image when you are zoomed in, and switching back to a higher-resolution image when zoomed out.

    Use hardware acceleration: The Cognex VisionPro library supports hardware acceleration on supported graphics hardware. This can significantly improve performance, especially when dealing with large images. To enable hardware acceleration, set the CogDisplay.UseAcceleration property to true.

    Optimize your graphics algorithms: The performance of your graphics also depends on the algorithms you use to generate them. Consider optimizing your algorithms to improve performance.

Try these tips one by one, and see if they can help you improve the performance of your CogMaskGraphic-based application.
 楼主| 发表于 2023-2-23 08:43:19 | 显示全部楼层
    private static void AddMask(UCMapDieSelect ImgControl, Die item, CogImage8Grey maskImg, CogRectangle rect)
        {
            JZDieMaskGraphic zMaskGraphic = new JZDieMaskGraphic { SourceImage = maskImg, Interactive = false };
            //zMaskGraphic.SelectedSpaceName = "$";
            zMaskGraphic.Region = rect;
            //zMaskGraphic.IsMask = item.IsGoodDie;
            if (item.IsGoodDie)
            {
                zMaskGraphic.Color = CogColorConstants.White;
                zMaskGraphic.SetColorMap(0, CogColorConstants.Green);
            }
            else
            {
                zMaskGraphic.Color = CogColorConstants.DarkGrey;
                zMaskGraphic.SetColorMap(0, CogColorConstants.Black);
            }
            zMaskGraphic.ContentDie = item;

            // Add the mask graphic object to the list of mask graphics
            lock (ImgControl.cogComposite)
            {
                ImgControl.cogComposite.Shapes.Add(zMaskGraphic);
            }
        }
 楼主| 发表于 2023-2-23 08:44:31 | 显示全部楼层
     // Create a new thread for each add mask task
            var tasks = new List<Task>();
            foreach (Die item in Parame.DieMes)
            {
                CogRectangle rect = new CogRectangle { Width = dieWidth, Height = dieHeight };
                rect.X = left + (item.BinXIndex - 1) * dieWidth;
                rect.Y = top + (item.BinYIndex - 1) * dieHeight;
                var task = Task.Run(() => AddMask(ImgControl, item, maskImg, rect));
                tasks.Add(task);
            }
            // Wait for all tasks to complete
            Task.WaitAll(tasks.ToArray());
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-2-23 05:46 , Processed in 0.039081 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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