TODO
Creates a window (image placeholder)
int cvNamedWindow( const char* name, unsigned long flags );
The function cvNamedWindow creates a window which can be used as a placeholder for images and trackbars. Created windows are reffered by their names.
Destroys a window
void cvDestroyWindow( const char* name );
The function cvDestroyWindow destroyes the window with the given name.
Sets window sizes
void cvResizeWindow( const char* name, int width, int height );
The function cvResizeWindow changes the sizes of the window.
Gets window handle by name
void* cvGetWindowHandle( const char* name );
The function cvGetWindowHandle returns native window handle (HWND in case of Win32 and Widget in case of X Window).
Gets window name by handle
const char* cvGetWindowName( void* window_handle );
The function cvGetWindowName returns the name of window given its native handle(HWND in case of Win32 and Widget in case of X Window).
Creates the trackbar and attaches it to the specified window
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 );
The function cvCreateTrackbar creates the trackbar(slider) 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.
Retrieves trackbar position
int cvGetTrackbarPos( const char* trackbar_name, const char* window_name );
The function cvGetTrackbarPos returns the ciurrent position of the specified trackbar.
Sets trackbar position
void cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos );
The function cvSetTrackbarPos sets the position of the specified trackbar.
Assigns callback for mouse events
#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) );
HIGHGUI_API void cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse );
void Foo(int event, int x, int y, int flags);where event is one of CV_EVENT_*, x and y are coordinates of mouse pointer in image coordinates (not window coordinates) and flags is a combination of CV_EVENT_FLAG.
The function cvSetMouseCallback sets the callback function for mouse events occuting within the specified window. To see how it works, look at opencv/samples/c/ffilldemo.c demo
Loads an image from file
IplImage* cvLoadImage( const char* filename, int iscolor CV_DEFAULT(1));
The function cvLoadImage loads an image from the specified file and returns the pointer to the loaded image. Currently the following file formats are supported: Windows bitmaps - BMP, DIB; JPEG files - JPEG, JPG, JPE; Portable Network Graphics - PNG; Portable image format - PBM, PGM, PPM; Sun rasters - SR, RAS; TIFF files - TIFF, TIF.
If "filename" does not contain full path, the file is searched in the current directory and in directories specified by cvAddSearchPath
Saves an image to the file
int cvSaveImage( const char* filename, const CvArr* image );
The function cvSaveImage saves the image to the specified file.
Shows the image in the specified window
void cvShowImage( const char* name, const CvArr* image );
The function cvShowImage shows the image in the specified window. If the window was created with CV_WINDOW_AUTOSIZE flag then the image will be shown with its original size otherwise the image will be scaled to fit the window.
Converts one image to another with optional vertical flip
void cvConvertImage( const CvArr* src, CvArr* dst, int flip CV_DEFAULT(0));
The function cvConvertImage converts one image to another and flips the result vertically if required. This function does the same conversions as cvCvtColor function, but do this automatically accordingly to formats of input and output images.
Structure for getting video from camera or AVI file
typedef struct CvCapture CvCapture;
The structure CvCapture does not have public interface and is used only as a parameter for video capture functions.
Allocates CvCapture structure binds it to the specified AVI file
CvCapture* cvCaptureFromAVI( const char* filename );
The function cvCaptureFromAVI allocates and initialized the CvCapture structure for reading the video stream from the specified AVI file.
After the allocated structure is not used any more it should be released by cvReleaseCapture function.
Allocates CvCapture structure and binds it to the video camera
CvCapture* cvCaptureFromCAM( int index );
The function cvCaptureFromCAM allocates and initialized the CvCapture structure for reading a video stream from the camera. Currently two camera interfaces can be used: Video for Windows (VFW) and Matrox Imaging Library (MIL). To connect to VFW camera the parameter "index" should be in range 0-10, to connect to MIL camera the parameter "index" should be in range 100-115. If -1 is passed then the function searches for VFW camera first and then for MIL camera.
After the allocated CvCapture structure is not used any more it should be released by cvReleaseCapture function.
Releases the CvCapture structure
void cvReleaseCapture( CvCapture** capture );
The function cvReleaseCapture releases the CvCapture structure allocated by cvCaptureFromAVI or cvCaptureFromCAM.
Grabs frame from camera or AVI
int cvGrabFrame( CvCapture* capture );
The function cvGrabFrame grabs the frame from camera or AVI. The grabbed frame is stored internally. The purpose of this function is to grab frame fast what is important for syncronization in case of reading from several cameras simultaneously. The grabbed frames are not exposed because they may be stored in compressed format (as defined by camera/driver). To get access to the grabbed frame cvGrabFrame should be followed by cvRetrieveFrame.
Gets the image grabbed with cvGrabFrame
IplImage* cvRetrieveFrame( CvCapture* capture );
The function cvRetrieveFrame returns the pointer to the image grabbed with cvGrabFrame function. The returned image should not be released by the user.
Grabs and returns a frame from camera or AVI
IplImage* cvQueryFrame( CvCapture* capture );
The function cvQueryFrame grabs a frame from camera or AVI and returns the pointer to grabbed image. Actually this function just successively calls cvGrabFrame and cvRetrieveFrame. The returned image should not be released by the user.
Gets camera/AVI properties
double cvGetCaptureProperty( CvCapture* capture, int property_id );
The function cvGetCaptureProperty retrieves the specified property of camera or AVI.
Sets camera/AVI properties
int cvSetCaptureProperty( CvCapture* capture, int property_id, double value );
The function cvSetCaptureProperty sets the specified property of camera or AVI. Currently the function works only for setting some AVI properties: CV_CAP_PROP_POS_MSEC, CV_CAP_PROP_POS_FRAMES, CV_CAP_PROP_POS_AVI_RATIO
Creates AVI writer
typedef struct CvAVIWriter CvAVIWriter; CvAVIWriter* cvCreateAVIWriter( const char* filename, int fourcc, double fps, CvSize frameSize )
The function cvCreateAVIWriter allocates and initializes the hidden structure CvAVIWriter that is used for writing AVI files frame by frame.
NOTE: Writing to AVIs works under Win32 only
Releases AVI writer
void cvReleaseAVIWriter( CvAVIWriter** writer );
The function cvReleaseAVIWriter closes the AVI file being written and deallocates the memory used by CvAVIWriter structure.
Writes a frame to AVI file
int cvWriteToAVI( CvAVIWriter* writer, const IplImage* image );
The function cvWriteToAVI writes/appends one frame to AVI file binded to "writer".
Initializes HighGUI
void cvInitSystem( int argc, char** argv );
The function cvInitSystem initializes HighGUI. If it wasn't called explicitly by the user before the first window is created, it is called implicitly then with argc=0, argv=NULL. Under Win32 there is no need to call it explicitly. Under X Window the arguments are used for creating Application Shell that is a standard way to define a look of HighGUI windows and controls.
Waits for pressed key
int cvWaitKey(int delay CV_DEFAULT(0));
The function cvWaitKey waits for key event infinitely (delay<=0) or for "delay" milliseconds. Returns the code of pressed key or -1 if key was not pressed until the specified timeout has elapsed.
Note: This function is the only method in HighGUI to fetch and handle events so it needs to be called periodically for normal event processing.
Adds the specified path to the list of search paths;
/* add folder to the image search path (used by cvLoadImage) */ void cvAddSearchPath( const char* path );
The function cvAddSearchPath adds the specified folder to the search path list. The search path list is used by cvLoadImage function.