【学习OpenCV】——highgui

官方文档说明:点击打开链接

C++的接口,基于opencv 2.4.9


进度条

创建进度条:  
int  createTrackbar ( const string&  trackbarname , const string&  winname , int*  value , int  count , TrackbarCallback  onChange =0, void*  userdata =0 )

namedWindow("source", CV_WINDOW_NORMAL); //创建窗口
int sliderval = 10; //进度条的初始位置为10
createTrackbar("wrap","source",&sliderval,100); //最大位置100

获得进度值:

int  getTrackbarPos ( const string&  trackbarname , const string&  winname )

设置进度值:

void setTrackbarPos( const string&  trackbarname , const string&  winname , int  pos)

示例:点击打开链接

图像显示

void imshow( const string&  winname , InputArray  mat)

函数支持3种输入数据,所以要适当处理

  • If the image is 8-bit unsigned, it is displayed as is.
  • If the image is 16-bit unsigned or 32-bit integer, the pixels are divided by 256. That is, the value range [0,255*256] is mapped to [0,255].
  • If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255].
If window was created with OpenGL support, imshow also support ogl::Buffer , ogl::Texture2D and gpu::GpuMat as input.

窗口

创建窗口:

void  namedWindow ( const string&  winname , int  flags =WINDOW_AUTOSIZE  )
Parameters:
  • name – Name of the window in the window caption that may be used as a window identifier.
  • flags –

    Flags of the window. The supported flags are:

    • WINDOW_NORMAL If this is set, the user can resize the window (no constraint).
    • WINDOW_AUTOSIZE If this is set, the window size is automatically adjusted to fit the displayed image (see imshow() ), and you cannot change the window size manually.
    • WINDOW_OPENGL If this is set, the window will be created with OpenGL support.

销毁窗口:

void  destroyWindow ( const string&  winname )


销毁所有窗口:

void  destroyAllWindows ( )


调整窗口大小:

void  resizeWindow ( const string&  winname , int  width , int  height )


刷新窗口:

void  updateWindow ( const string&  winname )

动作

鼠标

void  setMouseCallback ( const string&  winname , MouseCallback  onMouse , void*  userdata =0  )

空格键:

int  waitKey ( int  delay =0 )
Parameters: delay – Delay in milliseconds. 0 is the special value that means “forever”

你可能感兴趣的:(opencv)