HALCON setsystem 算子中参数的含义之 flush_graphic

12 篇文章 1 订阅

首先是halcon上的文档解释:

 

'flush_graphic':

After each HALCON operation which creates a graphic output, a flush operation will be executed in order to display the data immediately on screen. This is not necessary for all programs, e.g., if everything is done with the help of the mouse. In this case'flush_graphic' can be set to 'false' to improve the runtime. Note that this parameter has no effect on Unix-like systems because there, the window managers flush the display buffer automatically.

Value'true' or 'false'

Default'true'

理解的大概意思是 halcon算子创建一个图形输出后,会执行一个flush操作来更新屏幕上显示的数据。可以将值设为false来停止这个操作来提升runtime.

实际遇到的一个相关例子是,在图像窗口上绘制region,当flush_graphic的值是true时,不断的flush导致的结果就是屏幕上的

region在不停的闪烁,看起来很不友好;而当flush_graphic的值是false时,由于停止不断的flush,所以region不停闪烁的问题也就没有了。只在region更新的时候设置flush_graphic为true,是比较好的选择。


附一段halcon-c++开发使用到flush_graphic的功能函数:

/*********************采用圆形笔刷画出模板区*********************************
输入参数:
WindowHandle:窗口图像句柄
       Image:模板图像
      radius:笔刷半

输出参数:
ModelRegion:模板区域

返回值:
成功返回0,失败返回-1
/***************************************************************************/
int CreateModeRegion(const HTuple &WindowHandle,const HObject &Image,const Hlong &radius,HObject *ModleRegion)
{
    try
    {

        HTuple hvRow,hvColumn,hvButton,hvRowPos,hvColPos;
        HObject hoCircle;

        hvRowPos = 10;
        hvColPos = 10;
        SetColor(WindowHandle,"red");
        SetDraw(WindowHandle,"margin");

        SetTposition(WindowHandle,hvRowPos-10,hvRowPos);
        WriteString(WindowHandle,"用下面大小的小圆去涂抹模板区,按下左键移动涂抹,右键结束");
        DispCircle(WindowHandle,hvRowPos+radius+60,hvColPos+radius,radius);

        GenEmptyObj(ModleRegion);
        GetMbutton(WindowHandle,&hvRow, &hvColumn, &hvButton);

        //未画模板点右键退出则不创建模板
        int value = hvButton.I();
        if(4 == value)
        {
            SetSystem("flush_graphic","true");
            return -1;
        }
        //按下鼠标右键结束
        while(4 != value)
        {
            GetMposition(WindowHandle,&hvRow,&hvColumn,&hvButton);        
            value = hvButton.I();
            SetSystem("flush_graphic","false");
            DispObj(Image,WindowHandle);        
            if(hvRow>0 && hvColumn>0)
            {                
                if(0 == value)
                {                
                    GenCircle(&hoCircle, hvRow, hvColumn, radius);
                    DispObj(hoCircle,WindowHandle);
                    DispObj(*ModleRegion,WindowHandle);
                    SetSystem("flush_graphic","true");
                }
                //按下鼠标左键
                else if (1 == value)
                {
                    GenCircle(&hoCircle, hvRow, hvColumn, radius);                
                    SetSystem("flush_graphic","false");
                    Union2(*ModleRegion,hoCircle,ModleRegion);
                    DispObj(*ModleRegion,WindowHandle);
                }
            }
            else
            {
                break;
            }
        }    
        SetSystem("flush_graphic","true");
    }
    catch (HOperatorException &e)
    {
        CString csError(e.ErrorMessage());
        AfxMessageBox(csError);

    }
    catch(HTupleAccessException &ex)
    {
        CString csError(ex.ErrorMessage());
        AfxMessageBox(csError);
    }
    return 0;
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值