OPENCV Learning Notes __image

Source: Internet
Author: User

OPENCV Overview and function Introduction

OpenCV is the intel® Open source computer Vision Library. It is composed of a series of C functions and a few C + + classes, which realizes many common algorithms in image processing and computer vision. OpenCV has a cross-platform medium and high level API that includes more than 300 C functions. It does not depend on other external libraries-although some external libraries can be used.

OpenCV is free for both non-commercial and commercial applications. (Details refer to license). Code Download Address: http://www.sourceforge.net/projects/opencvlibrary

OpenCV provides a transparent interface for intel®integrated performance Primitives (IPP). This means that if there are IPP libraries optimized for a particular processor, OpenCV will automatically load these libraries at run time. For more information on IPP please refer to: http://www.intel.com/software/products/ipp/index.htm

It has the following characteristics:
1 Open source code for C + +
2 optimized code based on Intel processor instruction set development
3. Unified structure and functional definition
4 powerful image and matrix computing power
5 convenient and flexible user interface
6 at the same time support Ms-windows, Linux platform
As a basic open source project for computer vision, image processing and pattern recognition, OPENCV can be used directly in many fields as the ideal tool for the second development.

OpenCV Function Introduction:

The OPENCV contains the following sections:

Cxcore: Some basic functions (basic operations of various data types, etc.).

CV: Image processing and computer vision functions (image processing, structural analysis, motion analysis, object tracking, pattern recognition, camera calibration)

Ml: Machine learning module, the current content is mainly classifier.

Cvaux: Some experimental functions (viewmorphing, three-dimensional tracking, PCA,HMM)

Highgui: User interaction section, (GUI, image video I/O, system call function)

Second, OPENCV installation

OpenCV2.0 just released, VC 2008 Express under the installation OpenCV2.0 please refer to:

http://www.opencv.org.cn/index.php/VC_2008_Express%E4%B8%8B%E5%AE%89%E8%A3%85OpenCV2.0

Third, the basic knowledge:

1, OPENCV data type conversion Operation summary

(1) Data format conversion in an image or matrix array:
Cvconvert (image, Image_temp);

Cvconvertscale (const cvarr* SRC, cvarr* DST, double scale cv_default (1), double shift Cv_default (0));

Cvscale (SRC, DST);

Converts Cvarr (iplimage or Cvmat,...) to Cvmat.
Cvgetmat (const cvarr* arr, cvmat* header, int* COI cv_default (NULL), int allownd cv_default (0));
Cvcopy (const cvarr* SRC, cvarr* DST, const cvarr* mask); Can realize the extraction of the non-regulation graph


(2) Multi-channel image in the array of data
Cvgetmat (const cvarr* Array, cvmat* mat, int* pcoi, int allownd)

Cvcopy (Img,mat);

Converts Cvarr (iplimage or Cvmat,...) to Cvmat.
Cvgetmat (const cvarr* arr, cvmat* header, int* COI cv_default (NULL), int allownd cv_default (0));


(3) The data in the array is converted into multichannel image
Cvcopy (const cvarr* SRC, cvarr* DST, const cvarr* mask=null);

Cvgetmat (const cvarr* arr, cvmat* header, int* COI cv_default (NULL), int allownd cv_default (0));

2. Some discoveries of binary function Cvadaptivethreshold and cvthreshold

The average gray level of the neighborhood of the pixel is computed by the adaptive binary value, and the value of the binary value is determined. If the entire area is almost the same grayscale, then the appropriate result cannot be given. The reason why looks like edge detection, because the window size set small, can be changed to a larger try.
Cvadaptivethreshold (SRC, DST, 255, Cv_adaptive_thresh_mean_c, cv_thresh_binary, 21); Window set to 21
There is no omnipotent two-value method, specific problems specific analysis, adaptive binary for light uneven text, barcode, etc., the effect is very good. Window size selection, consider the size of the object being detected. The threshold value in adaptive thresholding is determined entirely by the neighborhood you choose, if the neighborhood you choose is very small (such as 3x3), then it is clear that the threshold of "adaptive degree" is very high, which in the result image is the effect of edge detection. If the neighborhood selection is larger (such as 31x31), then the threshold of the "adaptive degree" is relatively low, which in the result image is two-valued effect.

3, using Gabor and AdaBoost (Multiboost) to do target detection image recognition

http://www.opencv.org.cn/forum/viewtopic.php?f=10&t=7790

4, Video Tracking method

Tracking method I know that there are klman filters. Particle filter. Camshift.meanshift. threshold segmentation based on mean shift:http://www.codesoso.com/code/mean_shift.aspx http://arslan-ai.spaces.live.com/blog/cns!CAE7EF891A2218BA!123.entry

5, how to access the image pixel

(the coordinates start at 0 and are the relative position of the origin of the image.) The origin of the image is either the upper left corner (IMG->ORIGIN=IPL_ORIGIN_TL) or the lower left corner (IMG->ORIGIN=IPL_ORIGIN_BL).

Suppose to have 8-bit 1-channel image I (iplimage* img):

---------------------------------------------------------------------

I (X,y) ~ ((uchar*) (Img->imagedata + img->widthstep*y)) [x]

---------------------------------------------------------------------

Suppose to have 8-bit 3-channel image I (iplimage* img):

---------------------------------------------------------------------

I (X,y) Blue ~ ((uchar*) (Img->imagedata + img->widthstep*y)) [x*3]

I (x,y) Green ~ ((uchar*) (Img->imagedata + img->widthstep*y)) [x*3+1]

I (X,y) Red ~ ((uchar*) (Img->imagedata + img->widthstep*y)) [x*3+2]

------------------------------------------------------------------------------

For example, to increase the brightness of a point (100,100) by 30, you can do this:

------------------------------------------------------------------------------

Cvpoint pt = {100,100};

((uchar*) (Img->imagedata + img->widthstep*pt.y)) [Pt.x*3] + + 30;

((uchar*) (Img->imagedata + img->widthstep*pt.y)) [Pt.x*3+1] + + 30;

((uchar*) (Img->imagedata + img->widthstep*pt.y)) [Pt.x*3+2] + + 30;

-----------------------------------------------------------------------------

or more efficiently:

-----------------------------------------------------------------------------

Cvpoint pt = {100,100};

uchar* temp_ptr = & ((uchar*) (Img->imagedata + img->widthstep*pt.y)) [pt.x*3];

Temp_ptr[0] + + 30;

TEMP_PTR[1] + + 30;

TEMP_PTR[2] + + 30;

-----------------------------------------------------------------------------

Assuming there are 32-bit floating-point numbers, 1-channel image I (iplimage* img):

-----------------------------------------------------------------------------

I (X,y) ~ ((float*) (Img->imagedata + img->widthstep*y)) [x]

-----------------------------------------------------------------------------

Now, in general, a false set of N-channel, type T images:

-----------------------------------------------------------------------------

I (X,y) C ~ ((t*) (Img->imagedata + img->widthstep*y)) [X*n + c]

-----------------------------------------------------------------------------

You can use macro Cv_image_elem (Image_header, Elemtype, y, X_NC)

-----------------------------------------------------------------------------

I (x,y) C ~ Cv_image_elem (img, T, y, X*n + c)

-----------------------------------------------------------------------------

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.