⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 opencvref_highgui.htm

📁 opencv 中文文档 关于opencv 的所有函数
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head>
<link rel="STYLESHEET" href="opencvref.css" charset="ISO-8859-1" type="text/css">
<title>OpenCV: HighGUI Reference Manual</title>
</head><body>

<h1>HighGUI Reference Manual</h1>

<hr><ul>
<li><a href="#highgui_gui">Simple GUI</a>
<li><a href="#highgui_loadsave">Loading and Saving Images</a>
<li><a href="#highgui_video">Video I/O</a>
<li><a href="#highgui_utils">Utility and System Functions</a>
<li><a href="#highgui_func_index">Alphabetical List of Functions</a>
</ul>


<hr><h2><a name="highgui_overview">HighGUI overview</a></h2>

<p>TODO</p>

<hr><h2><a name="highgui_gui">Simple GUI</a></h2>

<hr><h3><a name="decl_cvNamedWindow">cvNamedWindow</a></h3>
<p class="Blurb">Creates window</p>
<pre>
int cvNamedWindow( const char* name, int flags );
</pre><dl>
<dt>name<dd>Name of the window which is used as window identifier and appears in
the window caption.
<dt>flags<dd>Flags of the window. Currently the only
supported flag is <code>CV_WINDOW_AUTOSIZE</code>. If it is set,
window size is automatically adjusted to fit the displayed image
(see <a href="#decl_cvShowImage">cvShowImage</a>), while user can not change
the window size manually.
</dl><p>
The function <code>cvNamedWindow</code>
creates a window which can be used as a placeholder for images and trackbars.
Created windows are reffered by their names.
</p><p>
If the window with such a name already exists, the function does nothing.</p>


<hr><h3><a name="decl_cvDestroyWindow">cvDestroyWindow</a></h3>
<p class="Blurb">Destroys a window</p>
<pre>
void cvDestroyWindow( const char* name );
</pre><dl>
<dt>name<dd>Name of the window to be destroyed.
</dl>
<p>
The function <code>cvDestroyWindow</code>
destroys the window with a given name.
</p>


<hr><h3><a name="decl_cvDestroyAllWindows">cvDestroyAllWindows</a></h3>
<p class="Blurb">Destroys all the HighGUI windows</p>
<pre>
void cvDestroyAllWindows(void);
</pre>
<p>
The function <code>cvDestroyAllWindows</code>
destroys all the opened HighGUI windows.
</p>


<hr><h3><a name="decl_cvResizeWindow">cvResizeWindow</a></h3>
<p class="Blurb">Sets window size</p>
<pre>
void cvResizeWindow( const char* name, int width, int height );
</pre><dl>
<dt>name<dd>Name of the window to be resized.
<dt>width<dd>New width
<dt>height<dd>New height
</dl><p>
The function <code>cvResizeWindow</code> changes size of the window.
</p>


<hr><h3><a name="decl_cvMoveWindow">cvMoveWindow</a></h3>
<p class="Blurb">Sets window position</p>
<pre>
void cvMoveWindow( const char* name, int x, int y );
</pre><dl>
<dt>name<dd>Name of the window to be resized.
<dt>x<dd>New x coordinate of top-left corner
<dt>y<dd>New y coordinate of top-left corner
</dl><p>
The function <code>cvMoveWindow</code> changes position of the window.
</p>


<hr><h3><a name="decl_cvGetWindowHandle">cvGetWindowHandle</a></h3>
<p class="Blurb">Gets window handle by name</p>
<pre>
void* cvGetWindowHandle( const char* name );
</pre><dl>
<dt>name<dd>Name of the window.
</dl><p>
The function <code>cvGetWindowHandle</code>
returns native window handle (HWND in case of Win32 and GtkWidget in case of GTK+).
</p>


<hr><h3><a name="decl_cvGetWindowName">cvGetWindowName</a></h3>
<p class="Blurb">Gets window name by handle</p>
<pre>
const char* cvGetWindowName( void* window_handle );
</pre><dl>
<dt>window_handle<dd>Handle of the window.
</dl><p>
The function <code>cvGetWindowName</code>
returns the name of window given its native handle
(HWND in case of Win32 and GtkWidget in case of GTK+).
</p>


<hr>
<h3><a name="decl_cvShowImage">cvShowImage</a></h3>
<p class="Blurb">Shows the image in the specified window</p>
<pre>
void cvShowImage( const char* name, const CvArr* image );
</pre><dl>
<dt>name<dd>Name of the window.
<dt>image<dd>Image to be shown.
</dl><p>
The function <code>cvShowImage</code>
shows the image in the specified window. If the window was created with <code>CV_WINDOW_AUTOSIZE</code>
flag then the image is shown with its original size, otherwise
the image is scaled to fit the window.
</p>


<hr><h3><a name="decl_cvCreateTrackbar">cvCreateTrackbar</a></h3>
<p class="Blurb">Creates the trackbar and attaches it to the specified window</p>
<pre>
CV_EXTERN_C_FUNCPTR( void (*CvTrackbarCallback)(int pos) );

int cvCreateTrackbar( const char* trackbar_name, const char* window_name,
                      int* value, int count, CvTrackbarCallback on_change );
</pre><dl>
<dt>trackbar_name<dd>Name of created trackbar.
<dt>window_name<dd>Name of the window which will e used as a parent for created trackbar.
<dt>value<dd>Pointer to the integer variable, which value will reflect the position of the slider.
  Upon the creation the slider position is defined by this variable.
<dt>count<dd>Maximal position of the slider. Minimal position is always 0.
<dt>on_change<dd>Pointer to the function to be called every time the slider changes the position. This
  function should be prototyped as <code>void Foo(int);</code>Can be NULL if
  callback is not required.
</dl><p>
The function <code>cvCreateTrackbar</code>
creates the trackbar (a.k.a. slider or range control) with the specified name and range,
assigns the variable to be syncronized with trackbar position and specifies callback function
to be called on trackbar position change. The created trackbar is displayed on top
of given window.</p>


<hr><h3><a name="decl_cvGetTrackbarPos">cvGetTrackbarPos</a></h3>
<p class="Blurb">Retrieves trackbar position</p>
<pre>
int cvGetTrackbarPos( const char* trackbar_name, const char* window_name );
</pre><dl>
<dt>trackbar_name<dd>Name of trackbar.
<dt>window_name<dd>Name of the window which is the parent of trackbar.
</dl><p>
The function <code>cvGetTrackbarPos</code>
returns the ciurrent position of the specified trackbar.</p>


<hr><h3><a name="decl_cvSetTrackbarPos">cvSetTrackbarPos</a></h3>
<p class="Blurb">Sets trackbar position</p>
<pre>
void cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos );
</pre><dl>
<dt>trackbar_name<dd>Name of trackbar.
<dt>window_name<dd>Name of the window which is the parent of trackbar.
<dt>pos<dd>New position.
</dl><p>
The function <code>cvSetTrackbarPos</code>
  sets the position of the specified trackbar.</p>


<hr><h3><a name="decl_cvSetMouseCallback">cvSetMouseCallback</a></h3>
<p class="Blurb">Assigns callback for mouse events</p>
<pre>
#define CV_EVENT_MOUSEMOVE      0
#define CV_EVENT_LBUTTONDOWN    1
#define CV_EVENT_RBUTTONDOWN    2
#define CV_EVENT_MBUTTONDOWN    3
#define CV_EVENT_LBUTTONUP      4
#define CV_EVENT_RBUTTONUP      5
#define CV_EVENT_MBUTTONUP      6
#define CV_EVENT_LBUTTONDBLCLK  7
#define CV_EVENT_RBUTTONDBLCLK  8
#define CV_EVENT_MBUTTONDBLCLK  9

#define CV_EVENT_FLAG_LBUTTON   1
#define CV_EVENT_FLAG_RBUTTON   2
#define CV_EVENT_FLAG_MBUTTON   4
#define CV_EVENT_FLAG_CTRLKEY   8
#define CV_EVENT_FLAG_SHIFTKEY  16
#define CV_EVENT_FLAG_ALTKEY    32

CV_EXTERN_C_FUNCPTR( void (*CvMouseCallback )(int event, int x, int y, int flags, void* param) );

void cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, void* param=NULL );
</pre><dl>
<dt>window_name<dd>Name of the window.
<dt>on_mouse<dd>Pointer to the function to be called every time mouse event occurs
                in the specified window. This function should be prototyped as
  <pre>void Foo(int event, int x, int y, int flags, void* param);</pre>
  where <code>event</code> is one of <code>CV_EVENT_*</code>,
  <code>x</code> and <code>y</code> are coordinates of mouse pointer in image coordinates
  (not window coordinates), <code>flags</code> is a combination of <code>CV_EVENT_FLAG</code>,
  and <code>param</code> is a user-defined parameter passed to the
  <code>cvSetMouseCallback</code> function call.
<dt>param<dd>User-defined parameter to be passed to the callback function.
</dl><p>
The function <code>cvSetMouseCallback</code>
sets the callback function for mouse events occuting within the specified
window. To see how it works, look at <a href="../../samples/c/ffilldemo.c">
opencv/samples/c/ffilldemo.c</a> demo</p>


<hr><h3><a name="decl_cvWaitKey">cvWaitKey</a></h3>
<p class="Blurb">Waits for a pressed key</p>
<pre>
int cvWaitKey( int delay=0 );
</pre><dl>
<dt>delay<dd>Delay in milliseconds.
</dl><p>
The function <code>cvWaitKey</code> waits for key event infinitely (delay&lt;=0) or for "delay" milliseconds.
Returns the code of the pressed key or -1 if no key were pressed until the specified timeout has elapsed.
</p><p>
<b>Note</b>: This function is the only method in HighGUI to fetch and handle events so
it needs to be called periodically for normal event processing, unless HighGUI is used
within some environment that takes care of event processing.
</p>


<hr><h2><a name="highgui_loadsave">Loading and Saving Images</a></h2>

<hr><h3><a name="decl_cvLoadImage">cvLoadImage</a></h3>
<p class="Blurb">Loads an image from file</p>
<pre>
IplImage* cvLoadImage( const char* filename, int iscolor=1 );
</pre><dl>
<dt>filename<dd>Name of file to be loaded.
<dt>iscolor<dd>Specifies colorness of the loaded image:<br>
       if &gt;0, the loaded image is forced to be color 3-channel image;<br>
       if 0, the loaded image is forced to be grayscale;<br>
       if &lt;0, the loaded image will be loaded as is
       (with number of channels depends on the file).
</dl><p>
The function <code>cvLoadImage</code> loads an image
from the specified file and returns the pointer to the loaded image.
Currently the following file formats are supported:
<ul>
<li>Windows bitmaps - BMP, DIB;
<li>JPEG files - JPEG, JPG, JPE;
<li>Portable Network Graphics - PNG;
<li>Portable image format - PBM, PGM, PPM;
<li>Sun rasters - SR, RAS;
<li>TIFF files - TIFF, TIF.
</ul>
</p>

<hr><h3><a name="decl_cvSaveImage">cvSaveImage</a></h3>
<p class="Blurb">Saves an image to the file</p>
<pre>
int cvSaveImage( const char* filename, const CvArr* image );
</pre><dl>
<dt>filename<dd>Name of the file.
<dt>image<dd>Image to be saved.
</dl><p>
The function <code>cvSaveImage</code>
saves the image to the specified file.
The image format is chosen depending on the <code>filename</code> extension, see
<a href="#decl_cvLoadImage">cvLoadImage</a>.
Only 8-bit single-channel or 3-channel
(with &#39;BGR&#39; channel order) images can be saved using this function.
If the format, depth or channel order is different, use <code>cvCvtScale</code>
and <code>cvCvtColor</code> to convert it before saving, or use
universal <code>cvSave</code> to save the image to XML or YAML format.
</p>


<hr><h2><a name="highgui_video">Video I/O functions</a></h2>

<hr><h3><a name="decl_CvCapture">CvCapture</a></h3>
<p class="Blurb">Video capturing structure</p>
<pre>
typedef struct CvCapture CvCapture;
</pre>
<p>
The structure <a href="#decl_CvCapture">CvCapture</a>
does not have public interface and is used only as a parameter for video
capturing functions.
</p>


<hr>
<h3><a name="decl_cvCaptureFromFile">cvCaptureFromFile</a></h3>
<p class="Blurb">Initializes capturing video from file</p>
<pre>
CvCapture* cvCaptureFromFile( const char* filename );
</pre><dl>
<dt>filename<dd>Name of the video file.
</dl><p>
The function <code>cvCaptureFromFile</code>
allocates and initialized the CvCapture structure for reading the video stream
from the specified file.
</p>
<p>After the allocated structure is not used any more it should be released by
<a href="#decl_cvReleaseCapture">cvReleaseCapture</a> function.
</p>


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -