From bffd77ed87fa6edc2a47b6d165766a404552bd84 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Sat, 28 Apr 2012 12:59:21 +0000 Subject: [PATCH] moved planar subdiv docs to legacy; added Input/OutputArray docs to core --- modules/core/doc/basic_structures.rst | 86 ++++++++++++++++++ modules/imgproc/doc/imgproc.rst | 1 - modules/legacy/doc/legacy.rst | 1 + modules/legacy/doc/pics/quadedge.png | Bin 0 -> 4679 bytes modules/legacy/doc/pics/subdiv.png | Bin 0 -> 2812 bytes .../doc/planar_subdivisions.rst | 0 6 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 modules/legacy/doc/pics/quadedge.png create mode 100644 modules/legacy/doc/pics/subdiv.png rename modules/{imgproc => legacy}/doc/planar_subdivisions.rst (100%) diff --git a/modules/core/doc/basic_structures.rst b/modules/core/doc/basic_structures.rst index 05f15e755..edf3b80bc 100644 --- a/modules/core/doc/basic_structures.rst +++ b/modules/core/doc/basic_structures.rst @@ -1814,6 +1814,84 @@ To use ``Mat_`` for multi-channel images/matrices, pass ``Vec`` as a ``Mat_`` pa img(i,j)[2] ^= (uchar)(i ^ j); +InputArray +---------- + +This is the proxy class for passing read-only input arrays into OpenCV functions. It is defined as :: + + typedef const _InputArray& InputArray; + +where ``_InputArray`` is a class that can be constructed from ``Mat``, ``Mat_``, ``Matx``, ``std::vector``, ``std::vector >`` or ``std::vector``. It can also be constructed from a matrix expression. + +Since this is mostly implementation-level class, and its interface may change in future versions, we do not describe it in details. There are a few key things, though, that should be kept in mind: + + * When you see in the reference manual or in OpenCV source code a function that takes ``InputArray``, it means that you can actually pass ``Mat``, ``Matx``, ``vector`` etc. (see above the complete list). + + * Optional input arguments: If some of the input arrays may be empty, pass ``cv::noArray()`` (or simply ``cv::Mat()`` as you probably did before). + + * The class is designed solely for passing parameters. That is, normally you *should not* declare class members, local and global variables of this type. + + * If you want to design your own function or a class method that can operate of arrays of multiple types, you can use ``InputArray`` (or ``OutputArray``) for the respective parameters. Inside a function you should use ``_InputArray::getMat()`` method to construct a matrix header for the array (without copying data). ``_InputArray::kind()`` can be used to distinguish ``Mat`` from ``vector<>`` etc., but normally it is not needed. + +Here is how you can use a function that takes ``InputArray`` :: + + std::vector vec; + // points or a circle + for( int i = 0; i < 30; i++ ) + vec.push_back(Point2f((float)(100 + 30*cos(i*CV_PI*2/5)), + (float)(100 - 30*sin(i*CV_PI*2/5)))); + cv::transform(vec, vec, cv::Matx23f(0.707, -0.707, 10, 0.707, 0.707, 20)); + +That is, we form an STL vector containing points, and apply in-place affine transformation to the vector using the 2x3 matrix created inline as ``Matx`` instance. + +Here is how such a function can be implemented (for simplicity, we implement a very specific case of it, according to the assertion statement inside) :: + + void myAffineTransform(InputArray _src, OutputArray _dst, InputArray _m) + { + // get Mat headers for input arrays. This is O(1) operation, + // unless _src and/or _m are matrix expressions. + Mat src = _src.getMat(), m = _m.getMat(); + CV_Assert( src.type() == CV_32FC2 && m.type() == CV_32F && m.size() == Size(3, 2) ); + + // [re]create the output array so that it has the proper size and type. + // In case of Mat it calls Mat::create, in case of STL vector it calls vector::resize. + _dst.create(src.size(), src.type()); + Mat dst = _dst.getMat(); + + for( int i = 0; i < src.rows; i++ ) + for( int j = 0; j < src.cols; j++ ) + { + Point2f pt = src.at(i, j); + dst.at(i, j) = Point2f(m.at(0, 0)*pt.x + + m.at(0, 1)*pt.y + + m.at(0, 2), + m.at(1, 0)*pt.x + + m.at(1, 1)*pt.y + + m.at(1, 2)); + } + } + +There is another related type, ``InputArrayOfArrays``, which is currently defined as a synonym for ``InputArray``: :: + + typedef InputArray InputArrayOfArrays; + +It denotes function arguments that are either vectors of vectors or vectors of matrices. A separate synonym is needed to generate Python/Java etc. wrappers properly. At the function implementation level their use is similar, but ``_InputArray::getMat(idx)`` should be used to get header for the idx-th component of the outer vector and ``_InputArray::size().area()`` should be used to find the number of components (vectors/matrices) of the outer vector. + + +OutputArray +----------- + +This type is very similar to ``InputArray`` except that it is used for input/output and output function parameters. Just like with ``InputArray``, OpenCV users should not care about ``OutputArray``, they just pass ``Mat``, ``vector`` etc. to the functions. The same limitation as for ``InputArray``: **Do not explicitly create OutputArray instances** applies here too. + +If you want to make your function polymorphic (i.e. accept different arrays as output parameters), it is also not very difficult. Take the sample above as the reference. Note that ``_OutputArray::create()`` needs to be called before ``_OutputArray::getMat()``. This way you guarantee that the output array is properly allocated. + +Optional output parameters. If you do not need certain output array to be computed and returned to you, pass ``cv::noArray()``, just like you would in the case of optional input array. At the implementation level, use ``_OutputArray::needed()`` to check if certain output array needs to be computed or not. + +There are several synonyms for ``OutputArray`` that are used to assist automatic Python/Java/... wrapper generators: :: + + typedef OutputArray OutputArrayOfArrays; + typedef OutputArray InputOutputArray; + typedef OutputArray InputOutputArrayOfArrays; NAryMatIterator --------------- @@ -2230,3 +2308,11 @@ It simplifies notation of some operations. :: M.ref(1, 2, 3) = M(4, 5, 6) + M(7, 8, 9); +Algorithm +--------- + +This is a base class for all more or less complex algorithms in OpenCV, especially for classes of algorithms, for which there can be multiple implementations. The examples are stereo correspondence (for which there are algorithms like block matching, semi-global block matching, graph-cut etc.), background subtraction (which can be done using mixture-of-gaussians models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck etc.). + +Algorithm performs several functions: + + * It provides virtual constructor. That is, if algorithm class is diff --git a/modules/imgproc/doc/imgproc.rst b/modules/imgproc/doc/imgproc.rst index 319fb2232..acaebc475 100644 --- a/modules/imgproc/doc/imgproc.rst +++ b/modules/imgproc/doc/imgproc.rst @@ -12,7 +12,6 @@ imgproc. Image Processing miscellaneous_transformations histograms structural_analysis_and_shape_descriptors - planar_subdivisions motion_analysis_and_object_tracking feature_detection object_detection diff --git a/modules/legacy/doc/legacy.rst b/modules/legacy/doc/legacy.rst index 8e6a826aa..ac5dde39f 100644 --- a/modules/legacy/doc/legacy.rst +++ b/modules/legacy/doc/legacy.rst @@ -9,3 +9,4 @@ legacy. Deprecated stuff motion_analysis expectation_maximization + planar_subdivisions diff --git a/modules/legacy/doc/pics/quadedge.png b/modules/legacy/doc/pics/quadedge.png new file mode 100644 index 0000000000000000000000000000000000000000..2fc6c2bfcf7cde160b422bff8d365e23d767ba7f GIT binary patch literal 4679 zcmV-N61eS&P)` zWfRwEd(F8LaDj0(%(-mh;s}R1mpqqpkE67`1YAzeWxlg<;=!G`=GeJjx5!U&d4*mOYGMiiOv~%= ztL{n>w_(<`ZM;%xt{rk(-+)^7}i&aDS+y$nA$AC`?%^TF#*kJ^$iIYN2 zA6MjE$DdB%%?Z5Yx%nMdDPi4sw(+lveVzVy9w8!xlgrg39>ZI9TR-vqVI`pc%d z+VIxm7es$NH-8KpZ6eo&iJL_tzz!4faWPh_-E&zB@h!sN*Lpbw-Ymto=APRkS7E#l^DX$2T@h~L8T+RquG2m!+HLH)Csml6 z{|~NA5LH~mbua8xC{p8mESGz36DY+=fhA;(bG^feHF3aVfI6;d2i@mGyw=#?t#kDE zap3iv2x`|4BVz*6x?Zc({IAdk!w(C>1_O&UZi<{HLW-o1dO#o|R zz3_^1zj0b7%7wD6;qb z`Y6y@?Oc5q4U-CIy!Jagy4U)-oXBbvmeEJ>JCgo$^M0_prm#1|BheOyD)LIXKRrJ9(W2OFV}R1FbioU4Dt*5l&O zyL5AbBB9aeBpi_-8(gOfBM1aumUBf_5LCWWi~5ca+bzymoxOVO1 zQkzAMAD2sZXAHS^85b+vj2YK5wucLpa&6ngrO?+e<8oQoN2ke!v97E)b*>ppxD-Bf zu!>7*&OzM9IC4>UC^GtTGQ_3L1O&O9G381zd}W49Fnnc+YbNK?%B6IaA{f51!X+BM zvcx6y*&6c=wWF`HuHvCEm&&YnS>q@ry*x^9HlK58;1V3AKo+>%@Kv*f3lwsRy7`*p-m!o#G&qAJ%FfnV(Tv zIr@^wdv~iY*^E!NEY2n2=8uP9kt-R^5{7QSY(!6iawV3eZtxkCrv zTkhrL*mm4NpSkMk$U~u8~!S+TGJ+RVCpIrOXv2v#NsdrJ0K>jKs@KE_~U* z6)!Wn@THrJxBc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8RVP7SZ%xwphcz3iRSszE!XW%Pc?qeec<6`4{+3UE0yLA-;ePQe&^0I2wz;H~fkGQf9}R8f3Vfc1 zh~?|^L7Xd_p|rMCHI?OCN8SHg=G^J529uOFD7}dU2a$RkQBT!!8_Pb6S?VvC_1vh+ zj?4I#O2Uv%?<7(YM#hgA{kEb2VyjIox$_+xsq^Z*V*He;9pZCA$70vhtTZy}R93t) z5jPdC^2M>_9#dDilN6aXKAU%RQ4aJ|kUcofwCCn^ zgy%?q9fkQ@9xi`Z&|9>`WDB>${XwP+mm$iL-7(JcE|_Jvjs={&wPIp)MvYe zEAP}PhGsY5?o)rQM(g!t-V*W}3*-6#Uc<3olv3^=x0qf=xq?3A_-VUMj`dN+68<*FQY;df*xrTbEN9T1vuqVg*QR>8b z-OmPgJC4}n$ literal 0 HcmV?d00001 diff --git a/modules/imgproc/doc/planar_subdivisions.rst b/modules/legacy/doc/planar_subdivisions.rst similarity index 100% rename from modules/imgproc/doc/planar_subdivisions.rst rename to modules/legacy/doc/planar_subdivisions.rst