基于C++的OpenCV常⽤函数
C++版本的好处:
1、在于可以尽量避免使⽤指针这种危险的东西;
2、不⽤费⼼去release资源了,因为在其destructor⾥⾯,系统会⾃动帮你搞定。
3、在某些情况下会⽐C版本运⾏速度快。
在⽂件中包含 using namespace cv;
rectangle函数opencv1. Imread(CvLoadImage):loads an image from a file;
2. imshow(cvShowImage):displays an image in the specifiedwidow;
3. waitKey(cvWaitKey):waits for a pressed key;
4. cvtColor(cvCvtColor):converts an image from one colorspace to another;
5. reduce(cvReduce):reduces a matrix to a vector;
6. minMaxLoc(cvMinMaxLoc):finds the global minimum andmaximum in a whole array or sub-array;
7. namedWindow(cvNamedWindow):creates a window;
8. destroyWindow(cvDestroyWindow):destroys a window;
9. destroyAllWindows(cvDestroyAllWindows):destroys all of the HighGUIwindows;
10. imwrite(cvSaveImage):saves an image to a specified file;
11. resize(cvResize):resizes an image;
12. pyrDown(cvPyrDown):blurs an image and downsamples it;
13. pyrUp(cvPyrUp):upsamples an image and then blursit;
14. threshold(cvThreshold):applies a fixed-level threshold toeach array element;
15. adaptiveThreshold(cvAdaptiveThreshold):applies an adaptive threshold toan array;
16. VideoCapthure::open(cvCaptureFromFile):open video file or a capturingdevice for video capturing;
17. VideoCapture::isOpened:returns true if video capturinghas been initialized already;
18. VideoCapture::release(cvReleaseCapture):closes video file or capturingdevice;
19. VideoCapture::grab(cvGrabFrame):grabs the next frame from videofile or capturing device;
20. VideoCaputre::retrieve(cvRetrieveFrame):decodes and returns the grabbedvideo frame;
21. VideoCapture::read(cvQueryFrame):grabs,decodes and returns the nextvideo frame;
22. VideoCapture::get(cvGetCaptureProperty):returns the specified VideoCaptureproperty;
23. VideoCapture::set(cvSetCaptureProperty):sets a property in theVideoCapture;
24. VideoWriter::open:initializes or reinitializes videowriter;
25. VideoWriter::isOpened:returns true if video writer hasbeen successfully initialized;
26. VideoWriter::write:writes the next video frame;
27. Mat::row:creates a matrix header for thespecified matrix row;
28. Mat::col:creates a matrix header for thespecified matrix column;
28. Mat::col:creates a matrix header for thespecified matrix column;
29. Mat::rowRange:creates a matrix header for thespecified row span;
30. Mat::colRange:creates a matrix header for thespecified col span;
31. Mat::diag:extracts a diagonal from a matrix,or creates a diagonal matrix;
32. Mat::clone:creates a full copy of the arrayand the underlying data;
33. Mat::copyTo(cvCopy):copies the matrix to another one;
34. Mat::convertTo(cvConvertScale):converts an array to anotherdatatype with optional scaling;
35. Mat::assignTo:provides a functional form ofconvertTo;
36. Mat::setTo:sets all or some of the arrayelements to the specified value;
37. Mat::reshape:changes the shape and/or thenumber of channels of a 2D matrix without copying the data;
38. Mat::t:transposes a matrix;
39. Mat::inv:inverses a matrix;
40. Mat::mul:performs an element-wisemultiplication or division of the two matrices;
41. Mat::cross:computes a cross-product of two3-element vectors;
42. Mat::dot:computes a dot-product of twovectors;
43. Mat::zeros:returns a zero array of thespecified size and type;
44. Mat::ones:returns an array of all 1’s of thespecified size and type;
45. Mat::eye:returns an identity matrix of thespecified size and type;
46. Mat::create:allocates new array data if needed;
47. Mat::addref:increments the reference counter;
48. Mat::release:decrements the reference counterand deallocates the matrix if needed;
49. Mat::resize:changes the number of matrix rows;
50. Mat::reserve:reserves space for the certainnumber of rows;
51. Mat::push_back:adds elements to the bottom of thematrix;
52. Mat::pop_back:removes elements from the bottomof the matrix;
53. Mat::locateROI:locates the matrix header within aparent matrix;
54. Mat::adjustROI:adjusts a submatrix size andposition within the parent matrix;
55. Mat::operator:extracts a rectangular submatrix;
56. Mat::operatorCvMat:creates the CvMat header for thematrix;
57. Mat::operatorIplImage:creates the IplImage header forthe matrix;
58. Mat::total:returns the total number fo arrayelements;
59. Mat::isContinuous:reports whether the matrix iscontinuous or not;
60. Mat::elemSize:returns the matrix element size inbytes;
61. Mat::elemSize1:returns the size of each matrixelement channel in bytes;
62. Mat::type:returns the type of a matrixelement;
62. Mat::type:returns the type of a matrixelement;
63. Mat::depth:returns the depth of a matrixelement;
64. Mat::channels:returns the number of matrix channels;
65. Mat::step1:returns a normalized step;
66. Mat::size:returns a matrix size;
67. Mat::empty:returns true if the array has noelemens;
68. Mat::ptr:returns a pointer to the specifiedmatrix row;
69. Mat::at:returns a reference to thespecified array element;
70. Mat::begin:returns the matrix iterator andsets it to the first matrix element;
71. Mat::end:returns the matrix iterator andsets it to the after-last matrix element;
72. calcHist(cvCalcHist):calculates a histogram of a set ofarrays;
73. compareHist(cvCompareHist):compares two histograms;
74. equalizeHist(cvEqualizeHist):equalizes the histogram of agrayscale image(直⽅图均衡化);
75. normalize:normalizes the norm or value rangeof an array;
76. CascadeClassifier::CascadeClassifier:loads a classifier from a file;
77. CascadeClassifier::empth:checks whether the classifier hasbeen loaded;
78. CascadeClassifier::load(cvLoadHaarClassifierCascade):loads a classifier from a file;
79. CascadeClassifier::read:reads a classifier from aFileStorage node;
80. CascadeClassifier::delectMultiScale(cvHaarDetectObjects):detects objects of different sizesin the input image(检测图
像中的⽬标);
81. CascadeClassifier::setImage(cvSetImagesForHaarClassifierCascade):sets an image for detection(隐藏的
cascade(hidden cascade)指定图像);
82. CascadeClassifier::runAt(cvRunHaarClassifierCascade):runs the detector at the specifiedpoint(在给定位置的图像中运⾏
cascade of boosted classifier);
83. groupRectangles:groups the object candidaterectangles;
84. split(cvSplit):divides a multi-channel array intoseveral single-channel arrays;
85. merge(cvMerge):creates one multichannel array outof several single-channel ones;
86. mixChannels(cvMixChannels):copies specified channels frominput arrays to the specified channels of output
arrays;
87. setMouseCallback(cvSetMouseCallback):sets mouse handler for thespecified window;
88. bilateralFilter:applies the bilateral filter to animage(双边滤波);
89. blur(cvSmooth):blurs an image using thenormalized box filter(均值模糊);
90. medianBlur:blurs an image using the medianfilter(中值模糊);
91. boxFilter:blurs an image using the boxfilter;
92. GaussianBlur:blurs an image using a Gaussianfilter(⾼斯模糊);
93. getGaussianKernel:returns Gaussian filtercoefficients;
94. sepFilter2D:applies a separable linear filterto an image;
95. filter2D(cvFilter2D):convolves an image with the kernel;
96. norm(cvNorm):calculates an absolute array norm,an absolute difference norm, or a relative defference norm;
97. flip(cvFlip):filps a 2D array around vertical,horizontal, or both axes;
98. Algorithm::get:returns the algorithm parameter;
99. Algorithm::set:set the algorithm parameter;
100. Algorithm::write:stores algorithm parameters in afile storage;
101. Algorithm::read:reads algorithm parameters from afile storage;
102. Algorithm::getList:returns the list of registeredalgorithms;
103. Algorithm::create:creates algorithm instance by name;
104. FaceRecognizer::train:trains a FaceRecognizer with givendata and associated labels;
105. FaceRecognizer::update:updates a FaceRecognizer withgiven data and associated labels;
106. FaceRecognizer::predict:predicts a label and distance) for a given input image;
107. FaceRecognizer::save:saves a FaceRecognizer and itsmodel state;
108. FaceRecognizer::load:loads a FaceRecognizer and itsmodel state;
109. createEigenFaceRecognizer:;
110. createFisherFaceRecognizer:;
111. createBPHFaceRecognizer:;
112. getTextSize(cvGetTextSize):calculates the width and height ofa textstring;
113. putText(cvPutText):draws a text string;
114. getStructuringElement(cvCreateStructingElementEx):returns a structuring element ofthe specified size and shape for morphological operations;
115. morphologyEx(cvMorphologyEx):performs advanced morphologicaltransformations;
116. findContours(cvFindContours):finds contours in a binary image;
117. drawContours(cvDrawContours):draw contours outlines or filledcontours;
118. minAreaRect(cvMinAreaRect2):finds a rotated rectangle of theminimum area enclosing the input 2D point set;
119. floodFill(cvFloodFill):fills a connected component withthe given color;
120. getRectSubPix(cvGetRectSubPix):retrieves a pixel rectangle froman image with sub-pixel accuracy;
121. CvSVM::CvSVM:default and training constructors;
122. CvSVM::train:trains an SVM;
123. CvSVM::train_auto:trains an SVM with optimalparameters;
124. CvSVM::predict:predicts the response for inputsample(s);
125. CvSVM::get_default_grid:generates a grid for SVMparameters;
126. CvSVM::get_params:returns the current SVM parameters;
127. CvSVM::get_support_vector:retrieves a number of supportvectors and the particular vector;
128. CvSVM::get_var_count:returns thenumber of used features(variables count);
129. CvANN_MLP(multi-layerperceptrons)::CvANN_MLP:the constructors;
130. CvANN_MLP::create:constructs MLP with the specifiedtopology;
131. CvANN_MLP::train:trains/updates MLP;
132. CvANN_MLP::predict:predicts responses for inputsamples;
133. CvANN_MLP::get_layer_count:returns the number fo layers inthe MLP;
134. CvANN_MLP::get_layer_size:returns numbers of neurons in eachlayer of the MLP;
135. CvANN_MLP::get_weights:returns neurons weights of theparticular layer;
136. CvKNearest::CvKNearest:default and training constructors;
137. CvKNearest::train:trains the model;
138. CvKNearest::find_nearest:finds the neighbors and predictsresponses for input vectors;
139. CvKNearest::get_max_k:returns the number of maximumneighbors that may be passed to the method CvKNearest::find_nearest();
140. CvKNearest::get_var_count:returns the number of usedfeatures(variables count);
141. CvKNearest::get_sample_count:returns the total number of trainsamples;
142. CvKNearest::is_regression:returns type of the problem(truefor regression and false for classification);
143. HoughLines(cvHoughLines):finds lines in a binary imageusing the standard Hough transform;
144. HoughLinesP:finds line segments in a binaryimage using the probabilistic Hough transform;
145. HoughCircles(cvHoughCircles):finds circles in a grayscale imageusing the Hough transform;
146. line(cvLine):draws a line segment connectingtwo points;
147. fitLine(cvFitLine):fits a line to a 2D or 3D pointset;
148. fitEllipse(cvFitEllipse2):fits an ellipse around a set of 2Dpoints;
149. ellipse(cvEllipse、cvEllipseBox):draws a simple or thick ellipticarc or fills an ellipse sector;
150. boundingRect(cvBoundingRect):calculatesthe up-right bounding rectangle of a point set;
151. rectangle(cvRectangle):draws a simple, thick, or filledup-right rectangle;
152. minEnclosingCircle(cvMinEnclosingCircle):finds acircle of the minimum area enclosing a 2D point set;
153. circle(cvCircle):draw a circle;
154. fillPoly:fills the area bounded by one ormore polygons;
155. approxPolyDP(cvApproxPoly):approximates a polygonal curve(s)with the specified precision;
156. pointPolygonTest(cvPointPolygonTest):performs a point-in-contour test(判断点在多边形中的位置);
157. convexHull(cvConvexHull2):finds the convex hull of a pointset;
158. transpose(cvTranspose):transposes a matrix;
159. invert(cvInvert):finds the inverse orpseudo-inverse of a matrix;
160. getStructuringElement(cvCreateStructuringElementEx):returns a structuring element ofthe specified size and shape for morphological operations;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论