From 5649f3575743d6ec5e4bac8accb85eaab7c66c07 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Thu, 7 Jul 2011 11:43:21 +0000 Subject: [PATCH] some more bugfixed in 2.3 propagated to trunk --- doc/CMakeLists.txt | 14 +- modules/core/doc/old_basic_structures.rst | 2 +- modules/gpu/CMakeLists.txt | 2 +- .../doc/miscellaneous_transformations.rst | 13 +- ...uctural_analysis_and_shape_descriptors.rst | 16 +- .../include/opencv2/imgproc/imgproc.hpp | 24 +-- modules/objdetect/src/cascadedetect.cpp | 2 + modules/python/src2/opencv_extra_api.hpp | 199 ------------------ 8 files changed, 33 insertions(+), 239 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index d5d65bf6f9..6ad33cde09 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -26,14 +26,14 @@ add_custom_target(docs ${CMAKE_CURRENT_SOURCE_DIR}/.. . COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/pics ${CMAKE_CURRENT_BINARY_DIR}/doc/opencv1/pics - COMMAND ${CMAKE_COMMAND} -E copy + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PDFLATEX_COMPILER} opencv2refman - COMMAND ${PDFLATEX_COMPILER} opencv2refman - COMMAND ${PDFLATEX_COMPILER} opencv_user - COMMAND ${PDFLATEX_COMPILER} opencv_user - COMMAND ${PDFLATEX_COMPILER} opencv_tutorials - COMMAND ${PDFLATEX_COMPILER} opencv_tutorials + COMMAND ${PDFLATEX_COMPILER} opencv2refman.tex + COMMAND ${PDFLATEX_COMPILER} opencv2refman.tex + COMMAND ${PDFLATEX_COMPILER} opencv_user.tex + COMMAND ${PDFLATEX_COMPILER} opencv_user.tex + COMMAND ${PDFLATEX_COMPILER} opencv_tutorials.tex + COMMAND ${PDFLATEX_COMPILER} opencv_tutorials.tex DEPENDS ${OPENCV_DOC_DEPS} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating the PDF Manuals") diff --git a/modules/core/doc/old_basic_structures.rst b/modules/core/doc/old_basic_structures.rst index ef742ce7e0..4e0c189752 100644 --- a/modules/core/doc/old_basic_structures.rst +++ b/modules/core/doc/old_basic_structures.rst @@ -1655,7 +1655,7 @@ Initializes a random number generator state. The function initializes a random number generator and returns the state. The pointer to the state can be then passed to the :ocv:cfunc:`RandInt`, :ocv:cfunc:`RandReal` and :ocv:cfunc:`RandArr` functions. In the current implementation a multiply-with-carry generator is used. -.. sealso:: the C++ class :ocv:class:`RNG` replaced ``CvRNG``. +.. seealso:: the C++ class :ocv:class:`RNG` replaced ``CvRNG``. RandArr diff --git a/modules/gpu/CMakeLists.txt b/modules/gpu/CMakeLists.txt index 170207a457..19fae4608d 100644 --- a/modules/gpu/CMakeLists.txt +++ b/modules/gpu/CMakeLists.txt @@ -218,7 +218,7 @@ if(BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test) # Additional target properties set_target_properties(${the_test_target} PROPERTIES DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" - RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}" ) if(ENABLE_SOLUTION_FOLDERS) diff --git a/modules/imgproc/doc/miscellaneous_transformations.rst b/modules/imgproc/doc/miscellaneous_transformations.rst index b72c13281e..f6ea42b32f 100644 --- a/modules/imgproc/doc/miscellaneous_transformations.rst +++ b/modules/imgproc/doc/miscellaneous_transformations.rst @@ -497,10 +497,9 @@ Fills a connected component with the given color. :param image: Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the function unless the ``FLOODFILL_MASK_ONLY`` flag is set in the second variant of the function. See the details below. :param mask: (For the second function only) Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels taller. The function uses and updates the mask, so you take responsibility of initializing the ``mask`` content. Flood-filling cannot go across non-zero pixels in the mask. For example, an edge detector output can be used as a mask to stop filling at edges. It is possible to use the same mask in multiple calls to the function to make sure the filled area does not overlap. - - .. note:: - Since the mask is larger than the filled image, a pixel :math:`(x, y)` in ``image`` corresponds to the pixel :math:`(x+1, y+1)` in the ``mask`` . - + + .. note:: Since the mask is larger than the filled image, a pixel :math:`(x, y)` in ``image`` corresponds to the pixel :math:`(x+1, y+1)` in the ``mask`` . + :param seed: Starting point. :param newVal: New value of the repainted domain pixels. @@ -782,11 +781,7 @@ should be set to 0's. In the function output, each pixel in markers is set to a value of the "seed" components or to -1 at boundaries between the regions. -.. note:: Every two neighbor connected -components are not necessarily separated by a watershed boundary (-1's pixels); for -example, when such tangent components exist in the initial -marker image. Visual demonstration and usage example of the function -can be found in the OpenCV samples directory (see the ``watershed.cpp`` demo). +.. note:: Every two neighbor connected components are not necessarily separated by a watershed boundary (-1's pixels); for example, when such tangent components exist in the initial marker image. Visual demonstration and usage example of the function can be found in the OpenCV samples directory (see the ``watershed.cpp`` demo). .. seealso:: :ocv:func:`findContours` diff --git a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst index 913dfce75f..247617d879 100644 --- a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst +++ b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst @@ -59,14 +59,12 @@ The normalized central moments \texttt{nu} _{ji}= \frac{\texttt{mu}_{ji}}{\texttt{m}_{00}^{(i+j)/2+1}} . .. note:: -:math:`\texttt{mu}_{00}=\texttt{m}_{00}`, -:math:`\texttt{nu}_{00}=1` -:math:`\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0` , hence the values are not stored. -The moments of a contour are defined in the same way but computed using the Green's formula -(see -http://en.wikipedia.org/wiki/Green_theorem -). So, due to a limited raster resolution, the moments computed for a contour are slightly different from the moments computed for the same rasterized contour. + :math:`\texttt{mu}_{00}=\texttt{m}_{00}`, + :math:`\texttt{nu}_{00}=1` + :math:`\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0` , hence the values are not stored. + +The moments of a contour are defined in the same way but computed using the Green's formula (see http://en.wikipedia.org/wiki/Green_theorem). So, due to a limited raster resolution, the moments computed for a contour are slightly different from the moments computed for the same rasterized contour. .. seealso:: @@ -146,9 +144,7 @@ Finds contours in a binary image. The function retrieves contours from the binary image using the algorithm [Suzuki85]_. The contours are a useful tool for shape analysis and object detection and recognition. See ``squares.c`` in the OpenCV sample directory. -.. note:: -Source ``image`` is modified by this function. - +.. note:: Source ``image`` is modified by this function. drawContours diff --git a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp index e233e0f03d..a843889558 100644 --- a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp @@ -455,9 +455,9 @@ CV_EXPORTS_W void preCornerDetect( InputArray src, OutputArray dst, int ksize, int borderType=BORDER_DEFAULT ); //! adjusts the corner locations with sub-pixel accuracy to maximize the certain cornerness criteria -CV_EXPORTS void cornerSubPix( InputArray image, InputOutputArray corners, - Size winSize, Size zeroZone, - TermCriteria criteria ); +CV_EXPORTS_W void cornerSubPix( InputArray image, InputOutputArray corners, + Size winSize, Size zeroZone, + TermCriteria criteria ); //! finds the strong enough corners where the cornerMinEigenVal() or cornerHarris() report the local maxima CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners, @@ -807,7 +807,7 @@ enum }; //! retrieves contours and the hierarchical information from black-n-white image. -CV_EXPORTS void findContours( InputOutputArray image, OutputArrayOfArrays contours, +CV_EXPORTS_W void findContours( InputOutputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset=Point()); @@ -816,16 +816,16 @@ CV_EXPORTS void findContours( InputOutputArray image, OutputArrayOfArrays contou int mode, int method, Point offset=Point()); //! draws contours in the image -CV_EXPORTS void drawContours( InputOutputArray image, InputArrayOfArrays contours, +CV_EXPORTS_W void drawContours( InputOutputArray image, InputArrayOfArrays contours, int contourIdx, const Scalar& color, int thickness=1, int lineType=8, InputArray hierarchy=noArray(), int maxLevel=INT_MAX, Point offset=Point() ); //! approximates contour or a curve using Douglas-Peucker algorithm -CV_EXPORTS void approxPolyDP( InputArray curve, - OutputArray approxCurve, - double epsilon, bool closed ); +CV_EXPORTS_W void approxPolyDP( InputArray curve, + OutputArray approxCurve, + double epsilon, bool closed ); //! computes the contour perimeter (closed=true) or a curve length CV_EXPORTS_W double arcLength( InputArray curve, bool closed ); @@ -842,8 +842,8 @@ CV_EXPORTS_W void minEnclosingCircle( InputArray points, CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2, int method, double parameter ); //! computes convex hull for a set of 2D points. -CV_EXPORTS void convexHull( InputArray points, OutputArray hull, - bool clockwise=false, bool returnPoints=true ); +CV_EXPORTS_W void convexHull( InputArray points, OutputArray hull, + bool clockwise=false, bool returnPoints=true ); //! returns true iff the contour is convex. Does not support contours with self-intersection CV_EXPORTS_W bool isContourConvex( InputArray contour ); @@ -852,8 +852,8 @@ CV_EXPORTS_W bool isContourConvex( InputArray contour ); CV_EXPORTS_W RotatedRect fitEllipse( InputArray points ); //! fits line to the set of 2D points using M-estimator algorithm -CV_EXPORTS void fitLine( InputArray points, OutputArray line, int distType, - double param, double reps, double aeps ); +CV_EXPORTS_W void fitLine( InputArray points, OutputArray line, int distType, + double param, double reps, double aeps ); //! checks if the point is inside the contour. Optionally computes the signed distance from the point to the contour boundary CV_EXPORTS_W double pointPolygonTest( InputArray contour, Point2f pt, bool measureDist ); diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index 696db7ba24..1db2ab7297 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -846,6 +846,8 @@ bool CascadeClassifier::empty() const bool CascadeClassifier::load(const string& filename) { oldCascade.release(); + data = Data(); + featureEvaluator.release(); FileStorage fs(filename, FileStorage::READ); if( !fs.isOpened() ) diff --git a/modules/python/src2/opencv_extra_api.hpp b/modules/python/src2/opencv_extra_api.hpp index edc65d3a90..eee9e5a75f 100644 --- a/modules/python/src2/opencv_extra_api.hpp +++ b/modules/python/src2/opencv_extra_api.hpp @@ -205,207 +205,8 @@ CV_WRAP void calcBackProject( const vector& images, const vector& chan } -static void addChildContour(const vector& contours, - const Mat& hierarchy, - int i, vector& seq, - vector& block) -{ - size_t count = contours.size(); - for( ; i >= 0; i = ((const Vec4i*)hierarchy.data)[i][0] ) - { - const vector& ci = contours[i]; - cvMakeSeqHeaderForArray(CV_SEQ_POLYGON, sizeof(CvSeq), sizeof(Point), - !ci.empty() ? (void*)&ci[0] : 0, (int)ci.size(), - &seq[i], &block[i] ); - const Vec4i h_i = ((const Vec4i*)hierarchy.data)[i]; - int h_next = h_i[0], h_prev = h_i[1], v_next = h_i[2], v_prev = h_i[3]; - - seq[i].h_next = (size_t)h_next < count ? &seq[h_next] : 0; - seq[i].h_prev = (size_t)h_prev < count ? &seq[h_prev] : 0; - seq[i].v_next = (size_t)v_next < count ? &seq[v_next] : 0; - seq[i].v_prev = (size_t)v_prev < count ? &seq[v_prev] : 0; - - if( v_next >= 0 ) - addChildContour(contours, hierarchy, v_next, seq, block); - } -} - -//! draws contours in the image -CV_WRAP static inline void drawContours( Mat& image, const vector& contours, - int contourIdx, const Scalar& color, - int thickness=1, int lineType=8, - const Mat& hierarchy=Mat(), - int maxLevel=INT_MAX, Point offset=Point() ) -{ - CvMat _image = image; - - size_t i = 0, first = 0, last = contours.size(); - vector seq; - vector block; - - if( !last ) - return; - - seq.resize(last); - block.resize(last); - - for( i = first; i < last; i++ ) - seq[i].first = 0; - - if( contourIdx >= 0 ) - { - CV_Assert( 0 <= contourIdx && contourIdx < (int)last ); - first = contourIdx; - last = contourIdx + 1; - } - - for( i = first; i < last; i++ ) - { - const Mat& ci = contours[i]; - int ci_size = ci.checkVector(2, CV_32S); - CV_Assert( ci_size >= 0 ); - cvMakeSeqHeaderForArray(CV_SEQ_POLYGON, sizeof(CvSeq), sizeof(Point), - ci_size > 0 ? ci.data : 0, ci_size, &seq[i], &block[i] ); - } - - if( hierarchy.empty() || maxLevel == 0 ) - for( i = first; i < last; i++ ) - { - seq[i].h_next = i < last-1 ? &seq[i+1] : 0; - seq[i].h_prev = i > first ? &seq[i-1] : 0; - } - else - { - int hsz = hierarchy.checkVector(4, CV_32S); - size_t count = last - first; - CV_Assert((size_t)hsz == contours.size()); - if( count == contours.size() ) - { - for( i = first; i < last; i++ ) - { - const Vec4i& h_i = ((const Vec4i*)hierarchy.data)[i]; - int h_next = h_i[0], h_prev = h_i[1], v_next = h_i[2], v_prev = h_i[3]; - - seq[i].h_next = (size_t)h_next < count ? &seq[h_next] : 0; - seq[i].h_prev = (size_t)h_prev < count ? &seq[h_prev] : 0; - seq[i].v_next = (size_t)v_next < count ? &seq[v_next] : 0; - seq[i].v_prev = (size_t)v_prev < count ? &seq[v_prev] : 0; - } - } - else - { - int child = ((const Vec4i*)hierarchy.data)[first][2]; - if( child >= 0 ) - { - addChildContour(contours, hierarchy, child, seq, block); - seq[first].v_next = &seq[child]; - } - } - } - - cvDrawContours( &_image, &seq[first], color, color, contourIdx >= 0 ? - -maxLevel : maxLevel, thickness, lineType, offset ); -} - - -CV_WRAP static inline void approxPolyDP( const Mat& curve, - CV_OUT Mat& approxCurve, - double epsilon, bool closed ) -{ - if( curve.depth() == CV_32S ) - { - vector result; - approxPolyDP(curve, result, epsilon, closed); - Mat(result).copyTo(approxCurve); - } - else if( curve.depth() == CV_32F ) - { - vector result; - approxPolyDP(curve, result, epsilon, closed); - Mat(result).copyTo(approxCurve); - } - else - CV_Error(CV_StsUnsupportedFormat, ""); -} - - -CV_WRAP static inline void convexHull( const Mat& points, CV_OUT Mat& hull, bool returnPoints=true, bool clockwise=false ) -{ - if( !returnPoints ) - { - vector h; - convexHull(points, h, clockwise); - Mat(h).copyTo(hull); - } - else if( points.depth() == CV_32S ) - { - vector h; - convexHull(points, h, clockwise); - Mat(h).copyTo(hull); - } - else if( points.depth() == CV_32F ) - { - vector h; - convexHull(points, h, clockwise); - Mat(h).copyTo(hull); - } -} - -CV_WRAP static inline void fitLine( const Mat& points, CV_OUT vector& line, - int distType, double param, double reps, double aeps ) -{ - if(points.channels() == 2 || points.cols == 2) - { - line.resize(4); - fitLine(points, *(Vec4f*)&line[0], distType, param, reps, aeps); - } - else - { - line.resize(6); - fitLine(points, *(Vec6f*)&line[0], distType, param, reps, aeps); - } -} - -CV_WRAP static inline int estimateAffine3D( const Mat& from, const Mat& to, - CV_OUT Mat& dst, CV_OUT Mat& outliers, - double param1 = 3.0, double param2 = 0.99 ) -{ - vector outliers_vec; - int res = estimateAffine3D(from, to, dst, outliers_vec, param1, param2); - Mat(outliers_vec).copyTo(outliers); - return res; -} - - -CV_WRAP static inline void cornerSubPix( const Mat& image, Mat& corners, - Size winSize, Size zeroZone, - TermCriteria criteria ) -{ - int n = corners.checkVector(2, CV_32F); - CV_Assert(n >= 0); - - if( n == 0 ) - return; - - CvMat _image = image; - cvFindCornerSubPix(&_image, (CvPoint2D32f*)corners.data, n, winSize, zeroZone, criteria); -} - /////////////////////////////// calib3d /////////////////////////////////////////// -CV_WRAP static inline void convertPointsHomogeneous( const Mat& src, CV_OUT Mat& dst ) -{ - int n; - if( (n = src.checkVector(2)) >= 0 ) - dst.create(n, 2, src.depth()); - else if( (n = src.checkVector(3)) >= 0 ) - dst.create(n, 3, src.depth()); - else - CV_Error(CV_StsBadSize, ""); - CvMat _src = src, _dst = dst; - cvConvertPointsHomogeneous(&_src, &_dst); -} - //! finds circles' grid pattern of the specified size in the image CV_WRAP static inline void findCirclesGridDefault( InputArray image, Size patternSize, OutputArray centers, int flags=CALIB_CB_SYMMETRIC_GRID )