]> rtime.felk.cvut.cz Git - opencv.git/blobdiff - opencv/doc/HighGui.tex
Move prototype for C in CreateTrackbar
[opencv.git] / opencv / doc / HighGui.tex
index 62dede61311b883a94228c2ddd4bb4ee3e19dcd7..2be594df527ca3f63bad8b6b92b2e7690179bb7b 100644 (file)
@@ -40,20 +40,34 @@ Creates a trackbar and attaches it to the specified window
 int cvCreateTrackbar( \par const char* trackbarName, \par const char* windowName,
                       \par int* value, \par int count, \par CvTrackbarCallback onChange );
 }
-\cvdefPy{CreateTrackbar(trackbarName, windowName, value, count, onChange)}
-\begin{lstlisting}
-CV_EXTERN_C_FUNCPTR( void (*CvTrackbarCallback)(int pos) );
-\end{lstlisting}
+\cvdefPy{CreateTrackbar(trackbarName, windowName, value, count, onChange) -> None}
 
 \begin{description}
-\cvarg{ trackbarName}{Name of the created trackbar.}
-\cvarg{ windowName}{Name of the window which will be used as a parent for created trackbar.}
-\cvarg{ value}{Pointer to an integer variable, whose value will reflect the position of the slider. Upon creation, the slider position is defined by this variable.}
-\cvarg{ count}{Maximal position of the slider. Minimal position is always 0.}
-\cvarg{ onChange}{Pointer to the function to be called every time the slider changes position. This function should be prototyped as \texttt{void Foo(int);}Can be NULL if callback is not required.}
+\cvarg{trackbarName}{Name of the created trackbar.}
+\cvarg{windowName}{Name of the window which will be used as a parent for created trackbar.}
+\ifPy
+\cvarg{value}{Initial value for the slider position, between 0 and \texttt{count}.}
+\else
+\cvarg{value}{Pointer to an integer variable, whose value will reflect the position of the slider. Upon creation, the slider position is defined by this variable.}
+\fi
+\cvarg{count}{Maximal position of the slider. Minimal position is always 0.}
+\ifPy
+\cvarg{onChange}{
+OpenCV calls \texttt{onChange} every time the slider changes position.
+OpenCV will call it as \texttt{func(x)} where \texttt{x} is the new position of the slider.}
+\else
+\cvarg{onChange}{
+Pointer to the function to be called every time the slider changes position.
+This function should be prototyped as \texttt{void Foo(int);}  Can be NULL if callback is not required.}
+\fi
 \end{description}
 
 The function \texttt{cvCreateTrackbar} creates a trackbar (a.k.a. slider or range control) with the specified name and range, assigns a variable to be syncronized with trackbar position and specifies a callback function to be called on trackbar position change. The created trackbar is displayed on the top of the given window.
+\ifC
+\begin{lstlisting}
+CV_EXTERN_C_FUNCPTR( void (*CvTrackbarCallback)(int pos) );
+\end{lstlisting}
+\fi
 
 \cvCPyFunc{DestroyAllWindows} 
 Destroys all of the HighGUI windows.
@@ -70,7 +84,7 @@ Destroys a window.
 \cvdefPy{DestroyWindow(name)-> None}
 
 \begin{description}
-\cvarg{ name}{Name of the window to be destroyed.}
+\cvarg{name}{Name of the window to be destroyed.}
 \end{description}
 
 The function \texttt{cvDestroyWindow} destroys the window with the given name.
@@ -82,8 +96,8 @@ Returns the trackbar position.
 \cvdefPy{GetTrackbarPos(trackbarName,windowName)-> None}
 
 \begin{description}
-\cvarg{ trackbarName}{Name of the trackbar.}
-\cvarg{ windowName}{Name of the window which is the parent of the trackbar.}
+\cvarg{trackbarName}{Name of the trackbar.}
+\cvarg{windowName}{Name of the window which is the parent of the trackbar.}
 \end{description}
 
 The function \texttt{cvGetTrackbarPos} returns the current position of the specified trackbar.
@@ -96,7 +110,7 @@ Gets the window's handle by its name.
 \cvdefC{void* cvGetWindowHandle( const char* name );}
 
 \begin{description}
-\cvarg{ name}{Name of the window}.
+\cvarg{name}{Name of the window}.
 \end{description}
 
 The function \texttt{cvGetWindowHandle} returns the native window handle (HWND in case of Win32 and GtkWidget in case of GTK+).
@@ -107,7 +121,7 @@ Gets the window's name by its handle.
 \cvdefC{const char* cvGetWindowName( void* windowHandle );}
 
 \begin{description}
-\cvarg{ windowHandle}{Handle of the window.}
+\cvarg{windowHandle}{Handle of the window.}
 \end{description}
 
 The function \texttt{cvGetWindowName} returns the name of the window given its native handle (HWND in case of Win32 and GtkWidget in case of GTK+).
@@ -137,9 +151,9 @@ Sets the position of the window.
 \cvdefPy{MoveWindow(name,x,y)-> None}
 
 \begin{description}
-\cvarg{ name}{Name of the window to be resized.}
-\cvarg{ x}{New x coordinate of the top-left corner}
-\cvarg{ y}{New y coordinate of the top-left corner}
+\cvarg{name}{Name of the window to be moved.}
+\cvarg{x}{New x coordinate of the top-left corner}
+\cvarg{y}{New y coordinate of the top-left corner}
 \end{description}
 
 The function \texttt{cvMoveWindow} changes the position of the window.
@@ -151,8 +165,8 @@ Creates a window.
 \cvdefPy{NamedWindow(name,flags=CV\_WINDOW\_AUTOSIZE)-> None}
 
 \begin{description}
-\cvarg{ name}{Name of the window in the window caption that may be used as a window identifier.}
-\cvarg{ flags}{Flags of the window. Currently the only supported flag is \texttt{CV\_WINDOW\_AUTOSIZE}. If this is set, window size is automatically adjusted to fit the displayed image (see \cross{ShowImage}), and the user can not change the window size manually.}
+\cvarg{name}{Name of the window in the window caption that may be used as a window identifier.}
+\cvarg{flags}{Flags of the window. Currently the only supported flag is \texttt{CV\_WINDOW\_AUTOSIZE}. If this is set, window size is automatically adjusted to fit the displayed image (see \cross{ShowImage}), and the user can not change the window size manually.}
 \end{description}
 
 The function \texttt{cvNamedWindow} creates a window which can be used as a placeholder for images and trackbars. Created windows are referred to by their names.
@@ -166,71 +180,74 @@ Sets the window size.
 \cvdefPy{ResizeWindow(name,width,height)-> None}
 
 \begin{description}
-\cvarg{ name}{Name of the window to be resized.}
-\cvarg{ width}{New width}
-\cvarg{ height}{New height}
+\cvarg{name}{Name of the window to be resized.}
+\cvarg{width}{New width}
+\cvarg{height}{New height}
 \end{description}
 
 The function \texttt{cvResizeWindow} changes the size of the window.
 
-\cvCPyFunc{SetMouseCallback} %XXX Weird URL Formatting
+\cvCPyFunc{SetMouseCallback}
 Assigns callback for mouse events.
 
 \cvdefC{void cvSetMouseCallback( const char* windowName, CvMouseCallback onMouse, void* param=NULL );}
 \cvdefPy{SetMouseCallback(windowName, onMouse, param) -> None}
 
-\begin{lstlisting}
-#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) );
-\end{lstlisting}
 
 \begin{description}
-\cvarg{ windowName}{Name of the window.}
-\cvarg{ onMouse}{Pointer to the function to be called every time a mouse event occurs in the specified window. This function should be prototyped as
+\cvarg{windowName}{Name of the window.}
 
-\cvdefC{
-void Foo(int event, int x, int y, int flags, void* param);
-}\cvdefPy{Foo(event,x,y,flags,param)-> None}
+\ifC  % {
+\cvarg{onMouse}{Pointer to the function to be called every time a mouse event occurs in the specified window. This function should be prototyped as
+\texttt{void Foo(int event, int x, int y, int flags, void* param);}
+where \texttt{event} is one of \texttt{CV\_EVENT\_*}, \texttt{x} and \texttt{y} are the coordinates of the mouse pointer in image coordinates (not window coordinates), \texttt{flags} is a combination of \texttt{CV\_EVENT\_FLAG\_*}, and \texttt{param} is a user-defined parameter passed to the \texttt{cvSetMouseCallback} function call.}
+\else % }{
+\cvarg{onMouse}{Callable to be called every time a mouse event occurs in the specified window. This callable should have signature
+\texttt{ Foo(event, x, y, flags, param)-> None }
+where \texttt{event} is one of \texttt{CV\_EVENT\_*}, \texttt{x} and \texttt{y} are the coordinates of the mouse pointer in image coordinates (not window coordinates), \texttt{flags} is a combination of \texttt{CV\_EVENT\_FLAG\_*}, and \texttt{param} is a user-defined parameter passed to the \texttt{cvSetMouseCallback} function call.}
+\fi   % }
 
-where \texttt{event} is one of \texttt{CV\_EVENT\_*}, \texttt{x} and \texttt{y} are the coordinates of the mouse pointer in image coordinates (not window coordinates), \texttt{flags} is a combination of \texttt{CV\_EVENT\_FLAG}, and \texttt{param} is a user-defined parameter passed to the \texttt{cvSetMouseCallback} function call.}
 \cvarg{param}{User-defined parameter to be passed to the callback function.}
 \end{description}
 
-The function \texttt{cvSetMouseCallback} sets the callback function for mouse events occuring within the specified window. To see how it works, look at 
+The function \texttt{cvSetMouseCallback} sets the callback function for mouse events occuring within the specified window. 
 
-\url{http://opencvlibrary.sourceforge.net/../../samples/c/ffilldemo.c|opencv/samples/c/ffilldemo.c} 
+The \texttt{event} parameter is one of:
+
+\begin{description}
+\cvarg{CV\_EVENT\_MOUSEMOVE}{Mouse movement}
+\cvarg{CV\_EVENT\_LBUTTONDOWN}{Left button down}
+\cvarg{CV\_EVENT\_RBUTTONDOWN}{Right button down}
+\cvarg{CV\_EVENT\_MBUTTONDOWN}{Middle button down}
+\cvarg{CV\_EVENT\_LBUTTONUP}{Left button up}
+\cvarg{CV\_EVENT\_RBUTTONUP}{Right button up}
+\cvarg{CV\_EVENT\_MBUTTONUP}{Middle button up}
+\cvarg{CV\_EVENT\_LBUTTONDBLCLK}{Left button double click}
+\cvarg{CV\_EVENT\_RBUTTONDBLCLK}{Right button double click}
+\cvarg{CV\_EVENT\_MBUTTONDBLCLK}{Middle button double click}
+\end{description}
+
+The \texttt{flags} parameter is a combination of :
+
+\begin{description}
+\cvarg{CV\_EVENT\_FLAG\_LBUTTON}{Left button pressed}
+\cvarg{CV\_EVENT\_FLAG\_RBUTTON}{Right button pressed}
+\cvarg{CV\_EVENT\_FLAG\_MBUTTON}{Middle button pressed}
+\cvarg{CV\_EVENT\_FLAG\_CTRLKEY}{Control key pressed}
+\cvarg{CV\_EVENT\_FLAG\_SHIFTKEY}{Shift key pressed}
+\cvarg{CV\_EVENT\_FLAG\_ALTKEY}{Alt key pressed}
+\end{description}
 
 \cvCPyFunc{SetTrackbarPos} 
 Sets the trackbar position.
 
 \cvdefC{void cvSetTrackbarPos( \par const char* trackbarName, \par const char* windowName, \par int pos );}
-\cvdefPy{SetTrackbarPos(trackbarName,windowName)-> None}
+\cvdefPy{SetTrackbarPos(trackbarName,windowName,pos)-> None}
 
 \begin{description}
-\cvarg{ trackbarName}{Name of the trackbar.}
-\cvarg{ windowName}{Name of the window which is the parent of trackbar.}
-\cvarg{ pos}{New position.}
+\cvarg{trackbarName}{Name of the trackbar.}
+\cvarg{windowName}{Name of the window which is the parent of trackbar.}
+\cvarg{pos}{New position.}
 \end{description}
 
 The function \texttt{cvSetTrackbarPos} sets the position of the specified trackbar.
@@ -260,7 +277,7 @@ Waits for a pressed key.
 \cvdefPy{WaitKey(delay=0)-> int}
 
 \begin{description}
-\cvarg{ delay}{Delay in milliseconds.}
+\cvarg{delay}{Delay in milliseconds.}
 \end{description}
 
 The function \texttt{cvWaitKey} waits for key event infinitely ($ \texttt{delay} <= 0$) or for \texttt{delay} milliseconds. Returns the code of the pressed key or -1 if no key was pressed before the specified time had elapsed.
@@ -275,7 +292,7 @@ Loads an image from a file.
 
 \cvdefC{
 IplImage* cvLoadImage( \par const char* filename, \par int iscolor=CV\_LOAD\_IMAGE\_COLOR );}
-\cvdefPy{LoadImage(filename, iscolor=CV\_LOAD\_IMAGE\_COLOR)}
+\cvdefPy{LoadImage(filename, iscolor=CV\_LOAD\_IMAGE\_COLOR)->None}
 
 \begin{lstlisting}
 #define CV_LOAD_IMAGE_COLOR       1
@@ -306,14 +323,14 @@ Saves an image to a specified file.
 \cvdefPy{SaveImage(filename,image)-> None}
 
 \begin{description}
-\cvarg{ filename}{Name of the file.}
-\cvarg{ image}{Image to be saved.}
+\cvarg{filename}{Name of the file.}
+\cvarg{image}{Image to be saved.}
 \end{description}
 
 The function \texttt{cvSaveImage} saves the image to the specified file. The image format is chosen based on the \texttt{filename} extension, see \cross{LoadImage}. Only 8-bit single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use \texttt{cvCvtScale} and \texttt{cvCvtColor} to convert it before saving, or use universal \texttt{cvSave} to save the image to XML or YAML format.
 
 
-\cvfunc{CvCapture}\label{CvCapture}
+\cvclass{CvCapture}\label{CvCapture}
 Video capturing structure.
 
 \cvdefC{typedef struct CvCapture CvCapture;}
@@ -383,7 +400,7 @@ Grabs the frame from a camera or file.
 \cvdefPy{GrabFrame(capture) -> int}
 
 \begin{description}
-\cvarg{ capture}{video capturing structure.}
+\cvarg{capture}{video capturing structure.}
 \end{description}
 
 The function \texttt{cvGrabFrame} grabs the frame from a camera or file. The grabbed frame is stored internally. The purpose of this function is to grab the frame \emph{quickly} so that syncronization can occur if it has to read from several cameras simultaneously. The grabbed frames are not exposed because they may be stored in a compressed format (as defined by the camera/driver). To retrieve the grabbed frame, \cross{RetrieveFrame} should be used.
@@ -396,7 +413,7 @@ Grabs and returns a frame from a camera or file.
 \cvdefPy{QueryFrame(capture) -> iplimage}
 
 \begin{description}
-\cvarg{ capture}{video capturing structure.}
+\cvarg{capture}{video capturing structure.}
 \end{description}
 
 The function \texttt{cvQueryFrame} grabs a frame from a camera or video file, decompresses it and returns it. This function is just a combination of \cross{GrabFrame} and \cross{RetrieveFrame}, but in one call. The returned image should not be released or modified by the user.  In the event of an error, the return value may be NULL.
@@ -421,7 +438,7 @@ Gets the image grabbed with cvGrabFrame.
 \cvdefPy{RetrieveFrame(capture) -> iplimage}
 
 \begin{description}
-\cvarg{ capture}{video capturing structure.}
+\cvarg{capture}{video capturing structure.}
 \end{description}
 
 The function \texttt{cvRetrieveFrame} returns the pointer to the image grabbed with the \cross{GrabFrame} function. The returned image should not be released or modified by the user.  In the event of an error, the return value may be NULL.
@@ -431,7 +448,7 @@ The function \texttt{cvRetrieveFrame} returns the pointer to the image grabbed w
 Sets video capturing properties.
 
 \cvdefC{int cvSetCaptureProperty( \par CvCapture* capture, \par int property\_id, \par double value );}
-\cvdefPy{SetCaptureProperty(capture, property\_id,double)}
+\cvdefPy{SetCaptureProperty(capture, property\_id,value)->None}
 
 \begin{description}
 \cvarg{capture}{video capturing structure.}
@@ -468,14 +485,14 @@ CvVideoWriter* cvCreateVideoWriter( \par const char* filename, \par int fourcc,
 }\cvdefPy{CreateVideoWriter(filename, fourcc, fps, frame\_size, is\_color) -> CvVideoWriter}
 
 \begin{description}
-\cvarg{ filename}{Name of the output video file.}
-\cvarg{ fourcc}{4-character code of codec used to compress the frames. For example,
+\cvarg{filename}{Name of the output video file.}
+\cvarg{fourcc}{4-character code of codec used to compress the frames. For example,
 \texttt{CV\_FOURCC('P','I','M,'1')} is a MPEG-1 codec,
 \texttt{CV\_FOURCC('M','J','P','G')} is a motion-jpeg codec etc.
 Under Win32 it is possible to pass -1 in order to choose compression method and additional compression parameters from dialog. Under Win32 if 0 is passed while using an avi filename it will create a video writer that creates an uncompressed avi file.}
-\cvarg{ fps}{Framerate of the created video stream.}
-\cvarg{ frame\_size}{Size of the  video frames.}
-\cvarg{ is\_color}{If it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only).}
+\cvarg{fps}{Framerate of the created video stream.}
+\cvarg{frame\_size}{Size of the  video frames.}
+\cvarg{is\_color}{If it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only).}
 \end{description}
 
 The function \texttt{cvCreateVideoWriter} creates the video writer structure.
@@ -490,7 +507,7 @@ Releases the AVI writer.
 \cvdefC{void cvReleaseVideoWriter( CvVideoWriter** writer );}
 
 \begin{description}
-\cvarg{ writer}{Pointer to the video file writer structure.}
+\cvarg{writer}{Pointer to the video file writer structure.}
 \end{description}
 
 The function \texttt{cvReleaseVideoWriter} finishes writing to the video file and releases the structure.
@@ -504,8 +521,8 @@ Writes a frame to a video file.
 \cvdefPy{WriteFrame(writer, image)->int}
 
 \begin{description}
-\cvarg{ writer}{Video writer structure}
-\cvarg{ image}{The written frame}
+\cvarg{writer}{Video writer structure}
+\cvarg{image}{The written frame}
 \end{description}
 
 The function \texttt{cvWriteFrame} writes/appends one frame to a video file.
@@ -605,7 +622,7 @@ The function \texttt{waitKey} waits for key event infinitely (when $\texttt{dela
 \section{Reading and Writing Images and Video}
 
 \cvCppFunc{imdecode}
-
+Reads an image from a buffer in memory.
 \cvdefCpp{Mat imdecode( const Mat\& buf, \par int flags );}
 \begin{description}
 \cvarg{buf}{The input array of vector of bytes}
@@ -618,7 +635,7 @@ If the buffer is too short or contains invalid data, the empty matrix will be re
 See \cross{imread} for the list of supported formats and the flags description. 
 
 \cvCppFunc{imencode}
-
+Encode an image into a memory buffer.
 \cvdefCpp{bool imencode( const string\& ext,\par
                const Mat\& img,\par
                vector<uchar>\& buf,\par
@@ -686,7 +703,7 @@ Saves an image to a specified file.
 The function \texttt{imwrite} saves the image to the specified file. The image format is chosen based on the \texttt{filename} extension, see \cross{imread} for the list of extensions. Only 8-bit (or 16-bit in the case of PNG, JPEG 2000 and TIFF) single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use \cross{Mat::convertTo}, and \cross{cvtColor} to convert it before saving, or use the universal XML I/O functions to save the image to XML or YAML format.
 
 
-\cvCppFunc{VideoCapture}
+\cvclass{VideoCapture}
 Class for video capturing from video files or cameras
 
 \begin{lstlisting}
@@ -768,7 +785,7 @@ int main(int, char**)
 \end{lstlisting}
 
 
-\cvCppFunc{VideoWriter}
+\cvclass{VideoWriter}
 Video writer class
 
 \begin{lstlisting}