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

首先是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;
}

扫描二维码关注公众号,回复: 4295845 查看本文章

猜你喜欢

转载自blog.csdn.net/u010096608/article/details/80885354