OpenCV basic functions

Source: Internet
Author: User

CvLoadImage ()
As the name suggests, it means to load an image. Its usage is
IplImage * cvLoadImage ("file name", parameter );
For more information about parameters, see the description of naming rules. The returned message is the IplImage data structure. Its Parameter categories include:

# Define CV_LOAD_IMAGE_UNCHANGED-1 source Image
# Define CV_LOAD_IMAGE_GRAYSCALE 0 grayscale
# Define CV_LOAD_IMAGE_COLOR 1 color
# Define CV_LOAD_IMAGE_ANYDEPTH 2 any color
# Define CV_LOAD_IMAGE_ANYCOLOR 4 any color

If the original image is a grayscale image, it cannot be changed to a color because of the file format, but the color image can be changed to a grayscale image at will. The parameters can be replaced by uppercase letters or numbers.

CvNamedWindow ()
This sub-program is a sub-program named for the Windows interface. Its usage is as follows:
CvNamedWindow ("window name", parameter );
However, it has only one parameter.

# Define CV_WINDOW_AUTOSIZE 1 automatically adjusts the image size

AUTOSIZE allows the image to become the original image size, that is, the image dimension is not adjusted, but the image size is too large to cause problems, such as RainMan. The dimension is 1200*1600, the image occupies the entire screen layout. cvResizeWindow () is required for fine-tuning. However, cvNamedWindow () cannot be set to 1 (CV_WINDOW_AUTOSIZE). You must set the parameter to 0 or another number other than 1.

CvMoveWindow ()
Move the GUI window to the position on "screen coordinates. when we move the mouse, it is actually changing the coordinate axis under the Windows operating system. This function allows us to move the made GUI window to the location of the specified screen coordinate based on the upper right corner. usage:
CvMoveWindow ("window name", screen X axis Number, screen Y axis number );

CvResizeWindow ()
When you scale a window, the image will change proportionally, but the cvNamedWindow () parameter must be set to 1.
CvResizeWindow ("window name", zoom width, zoom height );

CvGetWindowHandle ()
The ID generated by a window. When we create a window, the job system randomly gives a window ID. Each time we re-open this ID, it will be different and can be regarded as a pure number, however, it is usually set up by the (void *) data type. Here, we use the window name to find the window ID.
CvGetWindowHandle ("window name ");

CvGetWindowName ()
Use ID to check the window name.
CvGetWindowName (window ID );

CvShowImage ()
A batch of snapshots.
CvShowImage ("your window name", IplImage data structure or CvArr data structure );

CvWaitKey ()
A keyboard event is required to show the image. If cvShowImage () is enabled, you must use cvWaitKey () instead of stdlib. replacing system ("pause") in h ", cvWaitKey () is dedicated to waiting for keyboard commands under the GUI interface dedicated to OpenCV, rather than command prompt characters in the black and white environment, there are two types of Keyboard Events: block and unblock, which can be read in books related to operating system principles. cvWaitKey (0) is the block type ), it will wait until the keyboard event occurs, and input a cvWaitKey (10) number greater than zero in it. It will automatically output-1 after 10 milliseconds, it indicates that the keyboard hit event is not received within 10 milliseconds. Therefore, the typical sub-program notation is
CvWaitKey (number );

CvDestroyWindow ()
Clear Windows Memory
CvDestroyWindow ("window name ')

CvReleaseImage ()
Clear IplImage Graphic Data Structure memory
CvReleaseImage (IplImage Data Structure name)

CvCreateTrackbar ()
Create a Trackbar in the target window. The start value starts from 0. Set the position of the Trackbar indicator and the maximum value of the Trackbar, and give it a controllable event name, this Trackbar event can be freely named, but it is necessary for him to enter an int type variable such as void xxx (int position ).
CvCreateTrackbar ("Trackbar name", "target window name", indicator start value, Trackbar maximum value, Trackbar event sub-program name );

CvGetTrackbarPos ()
To view the position of a Trackbar, you must give it the name of the Trackbar and the name of the target window.
Int cvGetTrackbarPos ("Trackbar name", "target window name ");

CvSetTrackbarPos ()
To reset the position of a Trackbar, you must give it the Trackbar name and the target window name.
CvGetTrackbarPos ("Trackbar name", "target window name", new Axis Pulling position data );
CvSize ()
Initialize the CvSize data structure and place the integer of the length and width
CvSize cvSize (value of width, value of height );

CvCreateImage ()
Initialize the IplImage data structure and create a basic blank image format. For the format content, refer to the naming rules and then the number of other channels (number of two-dimensional arrays ).
CvCreateImage (CvSize data structure, IPL_DEPTH _ series parameters, number of channels );

CvThreshold ()
This is an example of the algorithm function. It is a sub-program collected by the algorithm related to the threshold value. The first is an input graph and the second is a graph of the calculation result, the next step is the maximum threshold value and the binarization threshold value parameter.
CvThreshold (original image IplImage data structure. The calculated result is IplImage data structure, threshold value, maximum threshold value, CV_THRESH_BINARY );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.