From e75df5631775dc512fba2d9c41598041c8beedaa Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 15 Mar 2013 16:55:58 +0400 Subject: [PATCH] Unified handling of InputOutputArrays in Python wrapper generator This makes arguments of type InputOutputArray required in python unless they have a default value in C++. As result following python functions changes signatures in non-trivial way: * calcOpticalFlowFarneback * calcOpticalFlowPyrLK * calibrateCamera * findContours * findTransformECC * floodFill * kmeans * PCACompute * stereoCalibrate And the following functions become return their modified inputs as a return value: * accumulate * accumulateProduct * accumulateSquare * accumulateWeighted * circle * completeSymm * cornerSubPix * drawChessboardCorners * drawContours * drawDataMatrixCodes * ellipse * fillConvexPoly * fillPoly * filterSpeckles * grabCut * insertChannel * line * patchNaNs * polylines * randn * randShuffle * randu * rectangle * setIdentity * updateMotionHistory * validateDisparity * watershed --- ...mera_calibration_and_3d_reconstruction.rst | 8 +++---- modules/core/doc/clustering.rst | 2 +- modules/core/doc/drawing_functions.rst | 23 ++++++++++--------- modules/core/doc/operations_on_arrays.rst | 14 ++++++----- modules/imgproc/doc/feature_detection.rst | 2 +- .../doc/miscellaneous_transformations.rst | 6 ++--- .../motion_analysis_and_object_tracking.rst | 8 +++---- ...uctural_analysis_and_shape_descriptors.rst | 2 +- modules/python/src2/gen2.py | 3 ++- .../softcascade/doc/softcascade_detector.rst | 2 +- .../motion_analysis_and_object_tracking.rst | 6 ++--- samples/python2/calibrate.py | 6 ++--- samples/python2/contours.py | 2 +- samples/python2/digits_video.py | 6 ++--- samples/python2/floodfill.py | 2 +- samples/python2/kmeans.py | 2 +- samples/python2/opt_flow.py | 2 +- samples/python2/squares.py | 2 +- 18 files changed, 51 insertions(+), 47 deletions(-) diff --git a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst index 1759dc584..26c73f1b6 100644 --- a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst +++ b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst @@ -117,7 +117,7 @@ Finds the camera intrinsic and extrinsic parameters from several views of a cali .. ocv:function:: double calibrateCamera( InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags=0, TermCriteria criteria=TermCriteria( TermCriteria::COUNT+TermCriteria::EPS, 30, DBL_EPSILON) ) -.. ocv:pyfunction:: cv2.calibrateCamera(objectPoints, imagePoints, imageSize[, cameraMatrix[, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs +.. ocv:pyfunction:: cv2.calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs .. ocv:cfunction:: double cvCalibrateCamera2( const CvMat* object_points, const CvMat* image_points, const CvMat* point_counts, CvSize image_size, CvMat* camera_matrix, CvMat* distortion_coeffs, CvMat* rotation_vectors=NULL, CvMat* translation_vectors=NULL, int flags=0, CvTermCriteria term_crit=cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,DBL_EPSILON) ) @@ -433,7 +433,7 @@ Renders the detected chessboard corners. .. ocv:function:: void drawChessboardCorners( InputOutputArray image, Size patternSize, InputArray corners, bool patternWasFound ) -.. ocv:pyfunction:: cv2.drawChessboardCorners(image, patternSize, corners, patternWasFound) -> None +.. ocv:pyfunction:: cv2.drawChessboardCorners(image, patternSize, corners, patternWasFound) -> image .. ocv:cfunction:: void cvDrawChessboardCorners( CvArr* image, CvSize pattern_size, CvPoint2D32f* corners, int count, int pattern_was_found ) .. ocv:pyoldfunction:: cv.DrawChessboardCorners(image, patternSize, corners, patternWasFound)-> None @@ -923,7 +923,7 @@ Filters off small noise blobs (speckles) in the disparity map .. ocv:function:: void filterSpeckles( InputOutputArray img, double newVal, int maxSpeckleSize, double maxDiff, InputOutputArray buf=noArray() ) -.. ocv:pyfunction:: cv2.filterSpeckles(img, newVal, maxSpeckleSize, maxDiff[, buf]) -> None +.. ocv:pyfunction:: cv2.filterSpeckles(img, newVal, maxSpeckleSize, maxDiff[, buf]) -> img, buf :param img: The input 16-bit signed disparity image @@ -1362,7 +1362,7 @@ Calibrates the stereo camera. .. ocv:function:: double stereoCalibrate( InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1, InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2, Size imageSize, OutputArray R, OutputArray T, OutputArray E, OutputArray F, TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6), int flags=CALIB_FIX_INTRINSIC ) -.. ocv:pyfunction:: cv2.stereoCalibrate(objectPoints, imagePoints1, imagePoints2, imageSize[, cameraMatrix1[, distCoeffs1[, cameraMatrix2[, distCoeffs2[, R[, T[, E[, F[, criteria[, flags]]]]]]]]]]) -> retval, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, R, T, E, F +.. ocv:pyfunction:: cv2.stereoCalibrate(objectPoints, imagePoints1, imagePoints2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, imageSize[, R[, T[, E[, F[, criteria[, flags]]]]]]) -> retval, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, R, T, E, F .. ocv:cfunction:: double cvStereoCalibrate( const CvMat* object_points, const CvMat* image_points1, const CvMat* image_points2, const CvMat* npoints, CvMat* camera_matrix1, CvMat* dist_coeffs1, CvMat* camera_matrix2, CvMat* dist_coeffs2, CvSize image_size, CvMat* R, CvMat* T, CvMat* E=0, CvMat* F=0, CvTermCriteria term_crit=cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,1e-6), int flags=CV_CALIB_FIX_INTRINSIC ) diff --git a/modules/core/doc/clustering.rst b/modules/core/doc/clustering.rst index 5b00d0405..60fb18928 100644 --- a/modules/core/doc/clustering.rst +++ b/modules/core/doc/clustering.rst @@ -9,7 +9,7 @@ Finds centers of clusters and groups input samples around the clusters. .. ocv:function:: double kmeans( InputArray data, int K, InputOutputArray bestLabels, TermCriteria criteria, int attempts, int flags, OutputArray centers=noArray() ) -.. ocv:pyfunction:: cv2.kmeans(data, K, criteria, attempts, flags[, bestLabels[, centers]]) -> retval, bestLabels, centers +.. ocv:pyfunction:: cv2.kmeans(data, K, bestLabels, criteria, attempts, flags[, centers]) -> retval, bestLabels, centers .. ocv:cfunction:: int cvKMeans2( const CvArr* samples, int cluster_count, CvArr* labels, CvTermCriteria termcrit, int attempts=1, CvRNG* rng=0, int flags=0, CvArr* _centers=0, double* compactness=0 ) diff --git a/modules/core/doc/drawing_functions.rst b/modules/core/doc/drawing_functions.rst index 8884f1928..6c0ac4b35 100644 --- a/modules/core/doc/drawing_functions.rst +++ b/modules/core/doc/drawing_functions.rst @@ -32,7 +32,7 @@ Draws a circle. .. ocv:function:: void circle(Mat& img, Point center, int radius, const Scalar& color, int thickness=1, int lineType=8, int shift=0) -.. ocv:pyfunction:: cv2.circle(img, center, radius, color[, thickness[, lineType[, shift]]]) -> None +.. ocv:pyfunction:: cv2.circle(img, center, radius, color[, thickness[, lineType[, shift]]]) -> img .. ocv:cfunction:: void cvCircle( CvArr* img, CvPoint center, int radius, CvScalar color, int thickness=1, int line_type=8, int shift=0 ) @@ -83,12 +83,13 @@ ellipse ----------- Draws a simple or thick elliptic arc or fills an ellipse sector. -.. ocv:function:: void ellipse(Mat& img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar& color, int thickness=1, int lineType=8, int shift=0) +.. ocv:function:: void ellipse(Mat& img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar& color, int thickness=1, int lineType=8, int shift=0) -.. ocv:function:: void ellipse(Mat& img, const RotatedRect& box, const Scalar& color, int thickness=1, int lineType=8) +.. ocv:function:: void ellipse(Mat& img, const RotatedRect& box, const Scalar& color, int thickness=1, int lineType=8) -.. ocv:pyfunction:: cv2.ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]) -> None -.. ocv:pyfunction:: cv2.ellipse(img, box, color[, thickness[, lineType]]) -> None +.. ocv:pyfunction:: cv2.ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]) -> img + +.. ocv:pyfunction:: cv2.ellipse(img, box, color[, thickness[, lineType]]) -> img .. ocv:cfunction:: void cvEllipse( CvArr* img, CvPoint center, CvSize axes, double angle, double start_angle, double end_angle, CvScalar color, int thickness=1, int line_type=8, int shift=0 ) @@ -163,7 +164,7 @@ Fills a convex polygon. .. ocv:function:: void fillConvexPoly(Mat& img, const Point* pts, int npts, const Scalar& color, int lineType=8, int shift=0) -.. ocv:pyfunction:: cv2.fillConvexPoly(img, points, color[, lineType[, shift]]) -> None +.. ocv:pyfunction:: cv2.fillConvexPoly(img, points, color[, lineType[, shift]]) -> img .. ocv:cfunction:: void cvFillConvexPoly( CvArr* img, const CvPoint* pts, int npts, CvScalar color, int line_type=8, int shift=0 ) @@ -193,7 +194,7 @@ Fills the area bounded by one or more polygons. .. ocv:function:: void fillPoly(Mat& img, const Point** pts, const int* npts, int ncontours, const Scalar& color, int lineType=8, int shift=0, Point offset=Point() ) -.. ocv:pyfunction:: cv2.fillPoly(img, pts, color[, lineType[, shift[, offset]]]) -> None +.. ocv:pyfunction:: cv2.fillPoly(img, pts, color[, lineType[, shift[, offset]]]) -> img .. ocv:cfunction:: void cvFillPoly( CvArr* img, CvPoint** pts, const int* npts, int contours, CvScalar color, int line_type=8, int shift=0 ) @@ -331,7 +332,7 @@ Draws a line segment connecting two points. .. ocv:function:: void line(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0) -.. ocv:pyfunction:: cv2.line(img, pt1, pt2, color[, thickness[, lineType[, shift]]]) -> None +.. ocv:pyfunction:: cv2.line(img, pt1, pt2, color[, thickness[, lineType[, shift]]]) -> img .. ocv:cfunction:: void cvLine( CvArr* img, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness=1, int line_type=8, int shift=0 ) @@ -421,7 +422,7 @@ Draws a simple, thick, or filled up-right rectangle. .. ocv:function:: void rectangle( Mat& img, Rect rec, const Scalar& color, int thickness=1, int lineType=8, int shift=0 ) -.. ocv:pyfunction:: cv2.rectangle(img, pt1, pt2, color[, thickness[, lineType[, shift]]]) -> None +.. ocv:pyfunction:: cv2.rectangle(img, pt1, pt2, color[, thickness[, lineType[, shift]]]) -> img .. ocv:cfunction:: void cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness=1, int line_type=8, int shift=0 ) @@ -455,7 +456,7 @@ Draws several polygonal curves. .. ocv:function:: void polylines( InputOutputArray img, InputArrayOfArrays pts, bool isClosed, const Scalar& color, int thickness=1, int lineType=8, int shift=0 ) -.. ocv:pyfunction:: cv2.polylines(img, pts, isClosed, color[, thickness[, lineType[, shift]]]) -> None +.. ocv:pyfunction:: cv2.polylines(img, pts, isClosed, color[, thickness[, lineType[, shift]]]) -> img .. ocv:cfunction:: void cvPolyLine( CvArr* img, CvPoint** pts, const int* npts, int contours, int is_closed, CvScalar color, int thickness=1, int line_type=8, int shift=0 ) @@ -488,7 +489,7 @@ Draws contours outlines or filled contours. .. ocv:function:: 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() ) -.. ocv:pyfunction:: cv2.drawContours(image, contours, contourIdx, color[, thickness[, lineType[, hierarchy[, maxLevel[, offset]]]]]) -> None +.. ocv:pyfunction:: cv2.drawContours(image, contours, contourIdx, color[, thickness[, lineType[, hierarchy[, maxLevel[, offset]]]]]) -> image .. ocv:cfunction:: void cvDrawContours( CvArr * img, CvSeq* contour, CvScalar external_color, CvScalar hole_color, int max_level, int thickness=1, int line_type=8, CvPoint offset=cvPoint(0,0) ) diff --git a/modules/core/doc/operations_on_arrays.rst b/modules/core/doc/operations_on_arrays.rst index 59b319d3e..64ca68618 100644 --- a/modules/core/doc/operations_on_arrays.rst +++ b/modules/core/doc/operations_on_arrays.rst @@ -592,7 +592,7 @@ Copies the lower or the upper half of a square matrix to another half. .. ocv:function:: void completeSymm(InputOutputArray mtx, bool lowerToUpper=false) -.. ocv:pyfunction:: cv2.completeSymm(mtx[, lowerToUpper]) -> None +.. ocv:pyfunction:: cv2.completeSymm(mtx[, lowerToUpper]) -> mtx :param mtx: input-output floating-point square matrix. @@ -2299,7 +2299,9 @@ Performs Principal Component Analysis of the supplied dataset. .. ocv:function:: PCA& PCA::operator()(InputArray data, InputArray mean, int flags, double retainedVariance) -.. ocv:pyfunction:: cv2.PCACompute(data[, mean[, eigenvectors[, maxComponents]]]) -> mean, eigenvectors +.. ocv:pyfunction:: cv2.PCACompute(data, mean[, eigenvectors[, maxComponents]]) -> mean, eigenvectors + +.. ocv:pyfunction:: cv2.PCACompute(data, mean, retainedVariance[, eigenvectors]) -> mean, eigenvectors :param data: input samples stored as the matrix rows or as the matrix columns. @@ -2670,7 +2672,7 @@ Generates a single uniformly-distributed random number or an array of random num .. ocv:function:: void randu( InputOutputArray dst, InputArray low, InputArray high ) -.. ocv:pyfunction:: cv2.randu(dst, low, high) -> None +.. ocv:pyfunction:: cv2.randu(dst, low, high) -> dst :param dst: output array of random numbers; the array must be pre-allocated. @@ -2701,7 +2703,7 @@ Fills the array with normally distributed random numbers. .. ocv:function:: void randn( InputOutputArray dst, InputArray mean, InputArray stddev ) -.. ocv:pyfunction:: cv2.randn(dst, mean, stddev) -> None +.. ocv:pyfunction:: cv2.randn(dst, mean, stddev) -> dst :param dst: output array of random numbers; the array must be pre-allocated and have 1 to 4 channels. @@ -2724,7 +2726,7 @@ Shuffles the array elements randomly. .. ocv:function:: void randShuffle( InputOutputArray dst, double iterFactor=1., RNG* rng=0 ) -.. ocv:pyfunction:: cv2.randShuffle(dst[, iterFactor]) -> None +.. ocv:pyfunction:: cv2.randShuffle(dst[, iterFactor]) -> dst :param dst: input/output numerical 1D array. @@ -2864,7 +2866,7 @@ Initializes a scaled identity matrix. .. ocv:function:: void setIdentity( InputOutputArray mtx, const Scalar& s=Scalar(1) ) -.. ocv:pyfunction:: cv2.setIdentity(mtx[, s]) -> None +.. ocv:pyfunction:: cv2.setIdentity(mtx[, s]) -> mtx .. ocv:cfunction:: void cvSetIdentity(CvArr* mat, CvScalar value=cvRealScalar(1)) diff --git a/modules/imgproc/doc/feature_detection.rst b/modules/imgproc/doc/feature_detection.rst index c705842f2..5098ba135 100644 --- a/modules/imgproc/doc/feature_detection.rst +++ b/modules/imgproc/doc/feature_detection.rst @@ -162,7 +162,7 @@ Refines the corner locations. .. ocv:function:: void cornerSubPix( InputArray image, InputOutputArray corners, Size winSize, Size zeroZone, TermCriteria criteria ) -.. ocv:pyfunction:: cv2.cornerSubPix(image, corners, winSize, zeroZone, criteria) -> None +.. ocv:pyfunction:: cv2.cornerSubPix(image, corners, winSize, zeroZone, criteria) -> corners .. ocv:cfunction:: void cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners, int count, CvSize win, CvSize zero_zone, CvTermCriteria criteria ) diff --git a/modules/imgproc/doc/miscellaneous_transformations.rst b/modules/imgproc/doc/miscellaneous_transformations.rst index 4ebf6d5ee..a82923fab 100644 --- a/modules/imgproc/doc/miscellaneous_transformations.rst +++ b/modules/imgproc/doc/miscellaneous_transformations.rst @@ -488,7 +488,7 @@ Fills a connected component with the given color. .. ocv:function:: int floodFill( InputOutputArray image, InputOutputArray mask, Point seedPoint, Scalar newVal, Rect* rect=0, Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), int flags=4 ) -.. ocv:pyfunction:: cv2.floodFill(image, mask, seedPoint, newVal[, loDiff[, upDiff[, flags]]]) -> retval, rect +.. ocv:pyfunction:: cv2.floodFill(image, mask, seedPoint, newVal[, loDiff[, upDiff[, flags]]]) -> retval, image, mask, rect .. ocv:cfunction:: void cvFloodFill( CvArr* image, CvPoint seed_point, CvScalar new_val, CvScalar lo_diff=cvScalarAll(0), CvScalar up_diff=cvScalarAll(0), CvConnectedComp* comp=NULL, int flags=4, CvArr* mask=NULL ) .. ocv:pyoldfunction:: cv.FloodFill(image, seed_point, new_val, lo_diff=(0, 0, 0, 0), up_diff=(0, 0, 0, 0), flags=4, mask=None)-> comp @@ -731,7 +731,7 @@ Performs a marker-based image segmentation using the watershed algorithm. .. ocv:cfunction:: void cvWatershed( const CvArr* image, CvArr* markers ) -.. ocv:pyfunction:: cv2.watershed(image, markers) -> None +.. ocv:pyfunction:: cv2.watershed(image, markers) -> markers :param image: Input 8-bit 3-channel image. @@ -753,7 +753,7 @@ Runs the GrabCut algorithm. .. ocv:function:: void grabCut( InputArray img, InputOutputArray mask, Rect rect, InputOutputArray bgdModel, InputOutputArray fgdModel, int iterCount, int mode=GC_EVAL ) -.. ocv:pyfunction:: cv2.grabCut(img, mask, rect, bgdModel, fgdModel, iterCount[, mode]) -> None +.. ocv:pyfunction:: cv2.grabCut(img, mask, rect, bgdModel, fgdModel, iterCount[, mode]) -> mask, bgdModel, fgdModel :param img: Input 8-bit 3-channel image. diff --git a/modules/imgproc/doc/motion_analysis_and_object_tracking.rst b/modules/imgproc/doc/motion_analysis_and_object_tracking.rst index 80834819b..bcc372a6a 100644 --- a/modules/imgproc/doc/motion_analysis_and_object_tracking.rst +++ b/modules/imgproc/doc/motion_analysis_and_object_tracking.rst @@ -9,7 +9,7 @@ Adds an image to the accumulator. .. ocv:function:: void accumulate( InputArray src, InputOutputArray dst, InputArray mask=noArray() ) -.. ocv:pyfunction:: cv2.accumulate(src, dst[, mask]) -> None +.. ocv:pyfunction:: cv2.accumulate(src, dst[, mask]) -> dst .. ocv:cfunction:: void cvAcc( const CvArr* image, CvArr* sum, const CvArr* mask=NULL ) @@ -45,7 +45,7 @@ Adds the square of a source image to the accumulator. .. ocv:function:: void accumulateSquare( InputArray src, InputOutputArray dst, InputArray mask=noArray() ) -.. ocv:pyfunction:: cv2.accumulateSquare(src, dst[, mask]) -> None +.. ocv:pyfunction:: cv2.accumulateSquare(src, dst[, mask]) -> dst .. ocv:cfunction:: void cvSquareAcc( const CvArr* image, CvArr* sqsum, const CvArr* mask=NULL ) @@ -79,7 +79,7 @@ Adds the per-element product of two input images to the accumulator. .. ocv:function:: void accumulateProduct( InputArray src1, InputArray src2, InputOutputArray dst, InputArray mask=noArray() ) -.. ocv:pyfunction:: cv2.accumulateProduct(src1, src2, dst[, mask]) -> None +.. ocv:pyfunction:: cv2.accumulateProduct(src1, src2, dst[, mask]) -> dst .. ocv:cfunction:: void cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc, const CvArr* mask=NULL ) @@ -115,7 +115,7 @@ Updates a running average. .. ocv:function:: void accumulateWeighted( InputArray src, InputOutputArray dst, double alpha, InputArray mask=noArray() ) -.. ocv:pyfunction:: cv2.accumulateWeighted(src, dst, alpha[, mask]) -> None +.. ocv:pyfunction:: cv2.accumulateWeighted(src, dst, alpha[, mask]) -> dst .. ocv:cfunction:: void cvRunningAvg( const CvArr* image, CvArr* acc, double alpha, const CvArr* mask=NULL ) .. ocv:pyoldfunction:: cv.RunningAvg(image, acc, alpha, mask=None)-> None diff --git a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst index 9647a7626..4c1911a77 100644 --- a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst +++ b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst @@ -159,7 +159,7 @@ Finds contours in a binary image. .. ocv:function:: void findContours( InputOutputArray image, OutputArrayOfArrays contours, int mode, int method, Point offset=Point()) -.. ocv:pyfunction:: cv2.findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> contours, hierarchy +.. ocv:pyfunction:: cv2.findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy .. ocv:cfunction:: int cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour, int header_size=sizeof(CvContour), int mode=CV_RETR_LIST, int method=CV_CHAIN_APPROX_SIMPLE, CvPoint offset=cvPoint(0,0) ) diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index 93ab5ece6..c7aa72544 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -354,6 +354,7 @@ class ArgInfo(object): elif m == "/IO": self.inputarg = True self.outputarg = True + self.returnarg = True elif m.startswith("/A"): self.isarray = True self.arraylen = m[2:].strip() @@ -427,7 +428,7 @@ class FuncVariant(object): continue if a.returnarg: outlist.append((a.name, argno)) - if (not a.inputarg or a.returnarg) and a.isbig(): + if (not a.inputarg) and a.isbig(): outarr_list.append((a.name, argno)) continue if not a.inputarg: diff --git a/modules/softcascade/doc/softcascade_detector.rst b/modules/softcascade/doc/softcascade_detector.rst index 763e862cd..49d1ab0a3 100644 --- a/modules/softcascade/doc/softcascade_detector.rst +++ b/modules/softcascade/doc/softcascade_detector.rst @@ -131,7 +131,7 @@ Destructor for ChannelFeatureBuilder. .. ocv:function:: softcascade::ChannelFeatureBuilder::~ChannelFeatureBuilder() -.. ocv:pyfunction:: cv2.softcascade_ChannelFeatureBuilder_create() -> retval +.. ocv:pyfunction:: cv2.softcascade_ChannelFeatureBuilder_create(featureType) -> retval softcascade::ChannelFeatureBuilder::operator() diff --git a/modules/video/doc/motion_analysis_and_object_tracking.rst b/modules/video/doc/motion_analysis_and_object_tracking.rst index 53922a56c..a193c23a1 100644 --- a/modules/video/doc/motion_analysis_and_object_tracking.rst +++ b/modules/video/doc/motion_analysis_and_object_tracking.rst @@ -10,7 +10,7 @@ Calculates an optical flow for a sparse feature set using the iterative Lucas-Ka .. ocv:function:: void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg, InputArray prevPts, InputOutputArray nextPts, OutputArray status, OutputArray err, Size winSize=Size(21,21), int maxLevel=3, TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), int flags=0, double minEigThreshold=1e-4 ) -.. ocv:pyfunction:: cv2.calcOpticalFlowPyrLK(prevImg, nextImg, prevPts[, nextPts[, status[, err[, winSize[, maxLevel[, criteria[, flags[, minEigThreshold]]]]]]]]) -> nextPts, status, err +.. ocv:pyfunction:: cv2.calcOpticalFlowPyrLK(prevImg, nextImg, prevPts, nextPts[, status[, err[, winSize[, maxLevel[, criteria[, flags[, minEigThreshold]]]]]]]) -> nextPts, status, err .. ocv:cfunction:: void cvCalcOpticalFlowPyrLK( const CvArr* prev, const CvArr* curr, CvArr* prev_pyr, CvArr* curr_pyr, const CvPoint2D32f* prev_features, CvPoint2D32f* curr_features, int count, CvSize win_size, int level, char* status, float* track_error, CvTermCriteria criteria, int flags ) .. ocv:pyoldfunction:: cv.CalcOpticalFlowPyrLK(prev, curr, prevPyr, currPyr, prevFeatures, winSize, level, criteria, flags, guesses=None) -> (currFeatures, status, track_error) @@ -77,7 +77,7 @@ Computes a dense optical flow using the Gunnar Farneback's algorithm. .. ocv:cfunction:: void cvCalcOpticalFlowFarneback( const CvArr* prev, const CvArr* next, CvArr* flow, double pyr_scale, int levels, int winsize, int iterations, int poly_n, double poly_sigma, int flags ) -.. ocv:pyfunction:: cv2.calcOpticalFlowFarneback(prev, next, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags[, flow]) -> flow +.. ocv:pyfunction:: cv2.calcOpticalFlowFarneback(prev, next, flow, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags) -> flow :param prev: first 8-bit single-channel input image. @@ -204,7 +204,7 @@ Updates the motion history image by a moving silhouette. .. ocv:function:: void updateMotionHistory( InputArray silhouette, InputOutputArray mhi, double timestamp, double duration ) -.. ocv:pyfunction:: cv2.updateMotionHistory(silhouette, mhi, timestamp, duration) -> None +.. ocv:pyfunction:: cv2.updateMotionHistory(silhouette, mhi, timestamp, duration) -> mhi .. ocv:cfunction:: void cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi, double timestamp, double duration ) .. ocv:pyoldfunction:: cv.UpdateMotionHistory(silhouette, mhi, timestamp, duration)-> None diff --git a/samples/python2/calibrate.py b/samples/python2/calibrate.py index 37d3de245..e23cc323c 100755 --- a/samples/python2/calibrate.py +++ b/samples/python2/calibrate.py @@ -27,7 +27,7 @@ if __name__ == '__main__': img_mask = img_mask[0] except: img_mask = '../cpp/left*.jpg' - + img_names = glob(img_mask) debug_dir = args.get('--debug') square_size = float(args.get('--square_size', 1.0)) @@ -46,7 +46,7 @@ if __name__ == '__main__': if img is None: print "Failed to load", fn continue - + h, w = img.shape[:2] found, corners = cv2.findChessboardCorners(img, pattern_size) if found: @@ -65,7 +65,7 @@ if __name__ == '__main__': print 'ok' - rms, camera_matrix, dist_coefs, rvecs, tvecs = cv2.calibrateCamera(obj_points, img_points, (w, h)) + rms, camera_matrix, dist_coefs, rvecs, tvecs = cv2.calibrateCamera(obj_points, img_points, (w, h), None, None) print "RMS:", rms print "camera matrix:\n", camera_matrix print "distortion coefficients: ", dist_coefs.ravel() diff --git a/samples/python2/contours.py b/samples/python2/contours.py index f8cc12c0c..f81f21231 100755 --- a/samples/python2/contours.py +++ b/samples/python2/contours.py @@ -46,7 +46,7 @@ if __name__ == '__main__': img = make_image() h, w = img.shape[:2] - contours0, hierarchy = cv2.findContours( img.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) + _, contours0, hierarchy = cv2.findContours( img.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) contours = [cv2.approxPolyDP(cnt, 3, True) for cnt in contours0] def update(levels): diff --git a/samples/python2/digits_video.py b/samples/python2/digits_video.py index 2aa9c1676..ca72a9350 100755 --- a/samples/python2/digits_video.py +++ b/samples/python2/digits_video.py @@ -14,9 +14,9 @@ from common import mosaic from digits import * def main(): - try: + try: src = sys.argv[1] - except: + except: src = 0 cap = video.create_capture(src) @@ -35,7 +35,7 @@ def main(): bin = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 31, 10) bin = cv2.medianBlur(bin, 3) - contours, heirs = cv2.findContours( bin.copy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE) + _, contours, heirs = cv2.findContours( bin.copy(), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE) try: heirs = heirs[0] except: diff --git a/samples/python2/floodfill.py b/samples/python2/floodfill.py index 16c6470c8..ef19141f8 100755 --- a/samples/python2/floodfill.py +++ b/samples/python2/floodfill.py @@ -29,7 +29,7 @@ if __name__ == '__main__': if img is None: print 'Failed to load image file:', fn sys.exit(1) - + h, w = img.shape[:2] mask = np.zeros((h+2, w+2), np.uint8) seed_pt = None diff --git a/samples/python2/kmeans.py b/samples/python2/kmeans.py index 0656fa7ad..ecf8c6f37 100755 --- a/samples/python2/kmeans.py +++ b/samples/python2/kmeans.py @@ -32,7 +32,7 @@ if __name__ == '__main__': points, _ = make_gaussians(cluster_n, img_size) term_crit = (cv2.TERM_CRITERIA_EPS, 30, 0.1) - ret, labels, centers = cv2.kmeans(points, cluster_n, term_crit, 10, 0) + ret, labels, centers = cv2.kmeans(points, cluster_n, None, term_crit, 10, 0) img = np.zeros((img_size, img_size, 3), np.uint8) for (x, y), label in zip(np.int32(points), labels.ravel()): diff --git a/samples/python2/opt_flow.py b/samples/python2/opt_flow.py index 0dba85f63..14efbfa8f 100755 --- a/samples/python2/opt_flow.py +++ b/samples/python2/opt_flow.py @@ -63,7 +63,7 @@ if __name__ == '__main__': while True: ret, img = cam.read() gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) - flow = cv2.calcOpticalFlowFarneback(prevgray, gray, 0.5, 3, 15, 3, 5, 1.2, 0) + flow = cv2.calcOpticalFlowFarneback(prevgray, gray, None, 0.5, 3, 15, 3, 5, 1.2, 0) prevgray = gray cv2.imshow('flow', draw_flow(gray, flow)) diff --git a/samples/python2/squares.py b/samples/python2/squares.py index 36676b454..c12b88401 100755 --- a/samples/python2/squares.py +++ b/samples/python2/squares.py @@ -24,7 +24,7 @@ def find_squares(img): bin = cv2.dilate(bin, None) else: retval, bin = cv2.threshold(gray, thrs, 255, cv2.THRESH_BINARY) - contours, hierarchy = cv2.findContours(bin, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) + bin, contours, hierarchy = cv2.findContours(bin, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) for cnt in contours: cnt_len = cv2.arcLength(cnt, True) cnt = cv2.approxPolyDP(cnt, 0.02*cnt_len, True)