diff --git a/lib/src/calib3d/calib3d.dart b/lib/src/calib3d/calib3d.dart index d14c8abf..76d7899c 100644 --- a/lib/src/calib3d/calib3d.dart +++ b/lib/src/calib3d/calib3d.dart @@ -299,3 +299,33 @@ Mat drawChessboardCorners( ); return (Mat.fromPointer(p), inliers); } + +/// FindHomography finds an optimal homography matrix using 4 or more point pairs (as opposed to GetPerspectiveTransform, which uses exactly 4) +/// +/// For further details, please see: +/// https:///docs.opencv.org/master/d9/d0c/group__calib3d.html#ga4abc2ece9fab9398f2e560d53c8c9780 +Mat findHomography( + InputArray srcPoints, + InputArray dstPoints, { + int method = 0, + double ransacReprojThreshold = 3, + OutputArray? mask, + int maxIters = 2000, + double confidence = 0.995, +}) { + mask ??= Mat.empty(); + final mat = calloc(); + cvRun( + () => ccalib3d.FindHomography( + srcPoints.ref, + dstPoints.ref, + method, + ransacReprojThreshold, + mask!.ref, + maxIters, + confidence, + mat, + ), + ); + return Mat.fromPointer(mat); +} diff --git a/lib/src/calib3d/calib3d_async.dart b/lib/src/calib3d/calib3d_async.dart index bef490f6..76af3743 100644 --- a/lib/src/calib3d/calib3d_async.dart +++ b/lib/src/calib3d/calib3d_async.dart @@ -286,3 +286,28 @@ Future<(Mat, Mat inliers)> estimateAffine2DAsync( ), matCompleter2, ); + +/// FindHomography finds an optimal homography matrix using 4 or more point pairs (as opposed to GetPerspectiveTransform, which uses exactly 4) +/// +/// For further details, please see: +/// https:///docs.opencv.org/master/d9/d0c/group__calib3d.html#ga4abc2ece9fab9398f2e560d53c8c9780 +Future<(Mat, Mat)> findHomographyAsync( + InputArray srcPoints, + InputArray dstPoints, { + int method = 0, + double ransacReprojThreshold = 3, + int maxIters = 2000, + double confidence = 0.995, +}) async => + cvRunAsync2( + (callback) => ccalib3d.FindHomography_Async( + srcPoints.ref, + dstPoints.ref, + method, + ransacReprojThreshold, + maxIters, + confidence, + callback, + ), + matCompleter2, + ); diff --git a/lib/src/g/calib3d.g.dart b/lib/src/g/calib3d.g.dart index 828de13d..62e82b2c 100644 --- a/lib/src/g/calib3d.g.dart +++ b/lib/src/g/calib3d.g.dart @@ -291,6 +291,64 @@ class CvNativeCalib3d { ffi.Pointer Function( Mat, Size, Mat, int, Mat, ffi.Pointer)>(); + ffi.Pointer FindHomography( + Mat src, + Mat dst, + int method, + double ransacReprojThreshold, + Mat mask, + int maxIters, + double confidence, + ffi.Pointer rval, + ) { + return _FindHomography( + src, + dst, + method, + ransacReprojThreshold, + mask, + maxIters, + confidence, + rval, + ); + } + + late final _FindHomographyPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(Mat, Mat, ffi.Int, ffi.Double, Mat, + ffi.Int, ffi.Double, ffi.Pointer)>>('FindHomography'); + late final _FindHomography = _FindHomographyPtr.asFunction< + ffi.Pointer Function( + Mat, Mat, int, double, Mat, int, double, ffi.Pointer)>(); + + ffi.Pointer FindHomography_Async( + Mat src, + Mat dst, + int method, + double ransacReprojThreshold, + int maxIters, + double confidence, + imp1.CvCallback_2 callback, + ) { + return _FindHomography_Async( + src, + dst, + method, + ransacReprojThreshold, + maxIters, + confidence, + callback, + ); + } + + late final _FindHomography_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(Mat, Mat, ffi.Int, ffi.Double, ffi.Int, + ffi.Double, imp1.CvCallback_2)>>('FindHomography_Async'); + late final _FindHomography_Async = _FindHomography_AsyncPtr.asFunction< + ffi.Pointer Function( + Mat, Mat, int, double, int, double, imp1.CvCallback_2)>(); + ffi.Pointer Fisheye_EstimateNewCameraMatrixForUndistortRectify( Mat k, Mat d, diff --git a/lib/src/g/calib3d.yaml b/lib/src/g/calib3d.yaml index 268401d6..0d3aee99 100644 --- a/lib/src/g/calib3d.yaml +++ b/lib/src/g/calib3d.yaml @@ -22,6 +22,10 @@ files: name: FindChessboardCornersSB c:@F@FindChessboardCornersSBWithMeta: name: FindChessboardCornersSBWithMeta + c:@F@FindHomography: + name: FindHomography + c:@F@FindHomography_Async: + name: FindHomography_Async c:@F@Fisheye_EstimateNewCameraMatrixForUndistortRectify: name: Fisheye_EstimateNewCameraMatrixForUndistortRectify c:@F@Fisheye_UndistortImage: diff --git a/lib/src/g/imgproc.g.dart b/lib/src/g/imgproc.g.dart index 6bb8b6f8..22147436 100644 --- a/lib/src/g/imgproc.g.dart +++ b/lib/src/g/imgproc.g.dart @@ -2238,64 +2238,6 @@ class CvNativeImgproc { late final _FindContours_Async = _FindContours_AsyncPtr.asFunction< ffi.Pointer Function(Mat, int, int, imp1.CvCallback_2)>(); - ffi.Pointer FindHomography( - Mat src, - Mat dst, - int method, - double ransacReprojThreshold, - Mat mask, - int maxIters, - double confidence, - ffi.Pointer rval, - ) { - return _FindHomography( - src, - dst, - method, - ransacReprojThreshold, - mask, - maxIters, - confidence, - rval, - ); - } - - late final _FindHomographyPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(Mat, Mat, ffi.Int, ffi.Double, Mat, - ffi.Int, ffi.Double, ffi.Pointer)>>('FindHomography'); - late final _FindHomography = _FindHomographyPtr.asFunction< - ffi.Pointer Function( - Mat, Mat, int, double, Mat, int, double, ffi.Pointer)>(); - - ffi.Pointer FindHomography_Async( - Mat src, - Mat dst, - int method, - double ransacReprojThreshold, - int maxIters, - double confidence, - imp1.CvCallback_2 callback, - ) { - return _FindHomography_Async( - src, - dst, - method, - ransacReprojThreshold, - maxIters, - confidence, - callback, - ); - } - - late final _FindHomography_AsyncPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(Mat, Mat, ffi.Int, ffi.Double, ffi.Int, - ffi.Double, imp1.CvCallback_2)>>('FindHomography_Async'); - late final _FindHomography_Async = _FindHomography_AsyncPtr.asFunction< - ffi.Pointer Function( - Mat, Mat, int, double, int, double, imp1.CvCallback_2)>(); - ffi.Pointer FitEllipse( VecPoint pts, ffi.Pointer rval, @@ -2382,6 +2324,76 @@ class CvNativeImgproc { ffi.Pointer Function( VecPoint, int, double, double, double, imp1.CvCallback_1)>(); + ffi.Pointer FloodFill( + Mat src, + Mat mask, + Point seedPoint, + Scalar newVal, + ffi.Pointer rect, + Scalar loDiff, + Scalar upDiff, + int flags, + ffi.Pointer rval, + ) { + return _FloodFill( + src, + mask, + seedPoint, + newVal, + rect, + loDiff, + upDiff, + flags, + rval, + ); + } + + late final _FloodFillPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + Mat, + Mat, + Point, + Scalar, + ffi.Pointer, + Scalar, + Scalar, + ffi.Int, + ffi.Pointer)>>('FloodFill'); + late final _FloodFill = _FloodFillPtr.asFunction< + ffi.Pointer Function(Mat, Mat, Point, Scalar, ffi.Pointer, + Scalar, Scalar, int, ffi.Pointer)>(); + + ffi.Pointer FloodFill_Async( + Mat src, + Mat mask, + Point seedPoint, + Scalar newVal, + Scalar loDiff, + Scalar upDiff, + int flags, + imp1.CvCallback_2 callback, + ) { + return _FloodFill_Async( + src, + mask, + seedPoint, + newVal, + loDiff, + upDiff, + flags, + callback, + ); + } + + late final _FloodFill_AsyncPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(Mat, Mat, Point, Scalar, Scalar, + Scalar, ffi.Int, imp1.CvCallback_2)>>('FloodFill_Async'); + late final _FloodFill_Async = _FloodFill_AsyncPtr.asFunction< + ffi.Pointer Function( + Mat, Mat, Point, Scalar, Scalar, Scalar, int, imp1.CvCallback_2)>(); + ffi.Pointer GaussianBlur( Mat src, Mat dst, @@ -5278,53 +5290,53 @@ class CvNativeImgproc { late final _SpatialGradient_Async = _SpatialGradient_AsyncPtr.asFunction< ffi.Pointer Function(Mat, int, int, imp1.CvCallback_2)>(); - ffi.Pointer SqBoxFilter( + ffi.Pointer SqBoxFilter_Async( Mat src, - Mat dst, int ddepth, Size ps, - Point anchor, - bool normalize, - int borderType, + imp1.CvCallback_1 callback, ) { - return _SqBoxFilter( + return _SqBoxFilter_Async( src, - dst, ddepth, ps, - anchor, - normalize, - borderType, + callback, ); } - late final _SqBoxFilterPtr = _lookup< + late final _SqBoxFilter_AsyncPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(Mat, Mat, ffi.Int, Size, Point, - ffi.Bool, ffi.Int)>>('SqBoxFilter'); - late final _SqBoxFilter = _SqBoxFilterPtr.asFunction< - ffi.Pointer Function(Mat, Mat, int, Size, Point, bool, int)>(); + ffi.Pointer Function( + Mat, ffi.Int, Size, imp1.CvCallback_1)>>('SqBoxFilter_Async'); + late final _SqBoxFilter_Async = _SqBoxFilter_AsyncPtr.asFunction< + ffi.Pointer Function(Mat, int, Size, imp1.CvCallback_1)>(); - ffi.Pointer SqBoxFilter_Async( + ffi.Pointer SqrBoxFilter( Mat src, + Mat dst, int ddepth, Size ps, - imp1.CvCallback_1 callback, + Point anchor, + bool normalize, + int borderType, ) { - return _SqBoxFilter_Async( + return _SqrBoxFilter( src, + dst, ddepth, ps, - callback, + anchor, + normalize, + borderType, ); } - late final _SqBoxFilter_AsyncPtr = _lookup< + late final _SqrBoxFilterPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - Mat, ffi.Int, Size, imp1.CvCallback_1)>>('SqBoxFilter_Async'); - late final _SqBoxFilter_Async = _SqBoxFilter_AsyncPtr.asFunction< - ffi.Pointer Function(Mat, int, Size, imp1.CvCallback_1)>(); + ffi.Pointer Function(Mat, Mat, ffi.Int, Size, Point, + ffi.Bool, ffi.Int)>>('SqrBoxFilter'); + late final _SqrBoxFilter = _SqrBoxFilterPtr.asFunction< + ffi.Pointer Function(Mat, Mat, int, Size, Point, bool, int)>(); void Subdiv2D_Close( Subdiv2DPtr self, diff --git a/lib/src/g/imgproc.yaml b/lib/src/g/imgproc.yaml index 7c3e0128..5d72394d 100644 --- a/lib/src/g/imgproc.yaml +++ b/lib/src/g/imgproc.yaml @@ -196,10 +196,6 @@ files: name: FindContours c:@F@FindContours_Async: name: FindContours_Async - c:@F@FindHomography: - name: FindHomography - c:@F@FindHomography_Async: - name: FindHomography_Async c:@F@FitEllipse: name: FitEllipse c:@F@FitEllipse_Async: @@ -208,6 +204,10 @@ files: name: FitLine c:@F@FitLine_Async: name: FitLine_Async + c:@F@FloodFill: + name: FloodFill + c:@F@FloodFill_Async: + name: FloodFill_Async c:@F@GaussianBlur: name: GaussianBlur c:@F@GaussianBlur_Async: @@ -436,10 +436,10 @@ files: name: SpatialGradient c:@F@SpatialGradient_Async: name: SpatialGradient_Async - c:@F@SqBoxFilter: - name: SqBoxFilter c:@F@SqBoxFilter_Async: name: SqBoxFilter_Async + c:@F@SqrBoxFilter: + name: SqrBoxFilter c:@F@Subdiv2D_Close: name: Subdiv2D_Close c:@F@Subdiv2D_Close_Async: diff --git a/lib/src/imgproc/imgproc.dart b/lib/src/imgproc/imgproc.dart index 9e1a681f..dfecc4e4 100644 --- a/lib/src/imgproc/imgproc.dart +++ b/lib/src/imgproc/imgproc.dart @@ -225,7 +225,7 @@ Mat sqrBoxFilter( dst ??= Mat.empty(); anchor ??= Point(-1, -1); cvRun( - () => cimgproc.SqBoxFilter(src.ref, dst!.ref, depth, ksize.cvd.ref, anchor!.ref, normalize, borderType), + () => cimgproc.SqrBoxFilter(src.ref, dst!.ref, depth, ksize.cvd.ref, anchor!.ref, normalize, borderType), ); return dst; } @@ -313,6 +313,41 @@ Mat erode( return (dst, labels); } +/// Fills a connected component with the given color. +/// +/// https://docs.opencv.org/4.x/d7/d1b/group__imgproc__misc.html#ga366aae45a6c1289b341d140839f18717 +(int rval, Mat image, Mat mask, Rect rect) floodFill( + InputOutputArray image, + Point seedPoint, + Scalar newVal, { + InputOutputArray? mask, + Scalar? loDiff, + Scalar? upDiff, + int flags = 4, +}) { + loDiff ??= Scalar(); + upDiff ??= Scalar(); + mask ??= Mat.empty(); + final pRect = calloc(); + final pRval = calloc(); + cvRun( + () => cimgproc.FloodFill( + image.ref, + mask!.ref, + seedPoint.ref, + newVal.ref, + pRect, + loDiff!.ref, + upDiff!.ref, + flags, + pRval, + ), + ); + final rval = pRval.value; + calloc.free(pRval); + return (rval, image, mask, Rect.fromPointer(pRect)); +} + /// BoundingRect calculates the up-right bounding rectangle of a point set. /// /// For further details, please see: @@ -1341,36 +1376,6 @@ Mat getAffineTransform2f(VecPoint2f src, VecPoint2f dst) { return Mat.fromPointer(mat); } -/// FindHomography finds an optimal homography matrix using 4 or more point pairs (as opposed to GetPerspectiveTransform, which uses exactly 4) -/// -/// For further details, please see: -/// https:///docs.opencv.org/master/d9/d0c/group__calib3d.html#ga4abc2ece9fab9398f2e560d53c8c9780 -Mat findHomography( - InputArray srcPoints, - InputArray dstPoints, { - int method = 0, - double ransacReprojThreshold = 3, - OutputArray? mask, - int maxIters = 2000, - double confidence = 0.995, -}) { - mask ??= Mat.empty(); - final mat = calloc(); - cvRun( - () => cimgproc.FindHomography( - srcPoints.ref, - dstPoints.ref, - method, - ransacReprojThreshold, - mask!.ref, - maxIters, - confidence, - mat, - ), - ); - return Mat.fromPointer(mat); -} - /// DrawContours draws contours outlines or filled contours. /// /// For further details, please see: diff --git a/lib/src/imgproc/imgproc_async.dart b/lib/src/imgproc/imgproc_async.dart index f7d4cf08..2f697833 100644 --- a/lib/src/imgproc/imgproc_async.dart +++ b/lib/src/imgproc/imgproc_async.dart @@ -242,7 +242,6 @@ Future erodeAsync( /// /// For further details, please see: /// https:///docs.opencv.org/master/d7/d1b/group__imgproc__misc.html#ga8a0b7fdfcb7a13dde018988ba3a43042 - Future<(Mat dst, Mat labels)> distanceTransformAsync( Mat src, int distanceType, @@ -254,6 +253,37 @@ Future<(Mat dst, Mat labels)> distanceTransformAsync( matCompleter2, ); +/// Fills a connected component with the given color. +/// +/// https://docs.opencv.org/4.x/d7/d1b/group__imgproc__misc.html#ga366aae45a6c1289b341d140839f18717 +Future<(int rval, Mat image, Mat mask, Rect rect)> floodFillAsync( + InputOutputArray image, + Point seedPoint, + Scalar newVal, { + InputOutputArray? mask, + Scalar? loDiff, + Scalar? upDiff, + int flags = 4, +}) async => + cvRunAsync2( + (callback) => cimgproc.FloodFill_Async( + image.ref, + mask?.ref ?? Mat.empty().ref, + seedPoint.ref, + newVal.ref, + loDiff?.ref ?? Scalar().ref, + upDiff?.ref ?? Scalar().ref, + flags, + callback, + ), + (c, prval, prect) { + final rval = prval.cast().value; + calloc.free(prval); + final rect = Rect.fromPointer(prect.cast()); + c.complete((rval, image, mask ?? Mat.empty(), rect)); + }, + ); + /// BoundingRect calculates the up-right bounding rectangle of a point set. /// /// For further details, please see: @@ -1242,31 +1272,6 @@ Future getAffineTransform2fAsync(VecPoint2f src, VecPoint2f dst) async => c matCompleter, ); -/// FindHomography finds an optimal homography matrix using 4 or more point pairs (as opposed to GetPerspectiveTransform, which uses exactly 4) -/// -/// For further details, please see: -/// https:///docs.opencv.org/master/d9/d0c/group__calib3d.html#ga4abc2ece9fab9398f2e560d53c8c9780 -Future<(Mat, Mat)> findHomographyAsync( - InputArray srcPoints, - InputArray dstPoints, { - int method = 0, - double ransacReprojThreshold = 3, - int maxIters = 2000, - double confidence = 0.995, -}) async => - cvRunAsync2( - (callback) => cimgproc.FindHomography_Async( - srcPoints.ref, - dstPoints.ref, - method, - ransacReprojThreshold, - maxIters, - confidence, - callback, - ), - matCompleter2, - ); - /// DrawContours draws contours outlines or filled contours. /// /// For further details, please see: diff --git a/src/calib3d/calib3d.cpp b/src/calib3d/calib3d.cpp index 5a0ae587..c72133d5 100644 --- a/src/calib3d/calib3d.cpp +++ b/src/calib3d/calib3d.cpp @@ -219,3 +219,20 @@ CvStatus *EstimateAffine2DWithParams( ))}; END_WRAP } + +CvStatus *FindHomography( + Mat src, + Mat dst, + int method, + double ransacReprojThreshold, + Mat mask, + const int maxIters, + const double confidence, + Mat *rval +) { + BEGIN_WRAP + *rval = {new cv::Mat(cv::findHomography( + *src.ptr, *dst.ptr, method, ransacReprojThreshold, *mask.ptr, maxIters, confidence + ))}; + END_WRAP +} diff --git a/src/calib3d/calib3d.h b/src/calib3d/calib3d.h index c616f939..29b1a812 100644 --- a/src/calib3d/calib3d.h +++ b/src/calib3d/calib3d.h @@ -20,34 +20,89 @@ extern "C" { #include // Calib CvStatus *Fisheye_UndistortImage(Mat distorted, Mat undistorted, Mat k, Mat d); -CvStatus *Fisheye_UndistortImageWithParams(Mat distorted, Mat *undistorted, Mat k, Mat d, Mat knew, Size size); +CvStatus *Fisheye_UndistortImageWithParams( + Mat distorted, Mat *undistorted, Mat k, Mat d, Mat knew, Size size +); CvStatus *Fisheye_UndistortPoints(Mat distorted, Mat undistorted, Mat k, Mat d, Mat R, Mat P); -CvStatus *Fisheye_EstimateNewCameraMatrixForUndistortRectify(Mat k, Mat d, Size imgSize, Mat r, Mat p, - double balance, Size newSize, double fovScale); +CvStatus *Fisheye_EstimateNewCameraMatrixForUndistortRectify( + Mat k, Mat d, Size imgSize, Mat r, Mat p, double balance, Size newSize, double fovScale +); -CvStatus *InitUndistortRectifyMap(Mat cameraMatrix, Mat distCoeffs, Mat r, Mat newCameraMatrix, Size size, - int m1type, Mat *map1, Mat *map2); -CvStatus *GetOptimalNewCameraMatrixWithParams(Mat cameraMatrix, Mat distCoeffs, Size size, double alpha, - Size newImgSize, Rect *validPixROI, bool centerPrincipalPoint, - Mat *rval); -CvStatus *CalibrateCamera(VecVecPoint3f objectPoints, VecVecPoint2f imagePoints, Size imageSize, - Mat cameraMatrix, Mat distCoeffs, Mat rvecs, Mat tvecs, int flag, - TermCriteria criteria, double *rval); +CvStatus *InitUndistortRectifyMap( + Mat cameraMatrix, + Mat distCoeffs, + Mat r, + Mat newCameraMatrix, + Size size, + int m1type, + Mat *map1, + Mat *map2 +); +CvStatus *GetOptimalNewCameraMatrixWithParams( + Mat cameraMatrix, + Mat distCoeffs, + Size size, + double alpha, + Size newImgSize, + Rect *validPixROI, + bool centerPrincipalPoint, + Mat *rval +); +CvStatus *CalibrateCamera( + VecVecPoint3f objectPoints, + VecVecPoint2f imagePoints, + Size imageSize, + Mat cameraMatrix, + Mat distCoeffs, + Mat rvecs, + Mat tvecs, + int flag, + TermCriteria criteria, + double *rval +); CvStatus *Undistort(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs, Mat newCameraMatrix); -CvStatus *UndistortPoints(Mat distorted, Mat undistorted, Mat k, Mat d, Mat r, Mat p, TermCriteria criteria); +CvStatus * +UndistortPoints(Mat distorted, Mat undistorted, Mat k, Mat d, Mat r, Mat p, TermCriteria criteria); CvStatus *FindChessboardCorners(Mat image, Size patternSize, Mat corners, int flags, bool *rval); CvStatus *FindChessboardCornersSB(Mat image, Size patternSize, Mat corners, int flags, bool *rval); -CvStatus *FindChessboardCornersSBWithMeta(Mat image, Size patternSize, Mat corners, int flags, Mat meta, - bool *rval); +CvStatus *FindChessboardCornersSBWithMeta( + Mat image, Size patternSize, Mat corners, int flags, Mat meta, bool *rval +); CvStatus *DrawChessboardCorners(Mat image, Size patternSize, Mat corners, bool patternWasFound); CvStatus *EstimateAffinePartial2D(VecPoint2f from, VecPoint2f to, Mat *rval); -CvStatus *EstimateAffinePartial2DWithParams(VecPoint2f from, VecPoint2f to, Mat inliers, int method, - double ransacReprojThreshold, size_t maxIters, double confidence, - size_t refineIters, Mat *rval); +CvStatus *EstimateAffinePartial2DWithParams( + VecPoint2f from, + VecPoint2f to, + Mat inliers, + int method, + double ransacReprojThreshold, + size_t maxIters, + double confidence, + size_t refineIters, + Mat *rval +); CvStatus *EstimateAffine2D(VecPoint2f from, VecPoint2f to, Mat *rval); -CvStatus *EstimateAffine2DWithParams(VecPoint2f from, VecPoint2f to, Mat inliers, int method, - double ransacReprojThreshold, size_t maxIters, double confidence, - size_t refineIters, Mat *rval); +CvStatus *EstimateAffine2DWithParams( + VecPoint2f from, + VecPoint2f to, + Mat inliers, + int method, + double ransacReprojThreshold, + size_t maxIters, + double confidence, + size_t refineIters, + Mat *rval +); +CvStatus *FindHomography( + Mat src, + Mat dst, + int method, + double ransacReprojThreshold, + Mat mask, + const int maxIters, + const double confidence, + Mat *rval +); #ifdef __cplusplus } #endif diff --git a/src/calib3d/calib3d_async.cpp b/src/calib3d/calib3d_async.cpp index 2c454908..ba4486ad 100644 --- a/src/calib3d/calib3d_async.cpp +++ b/src/calib3d/calib3d_async.cpp @@ -268,3 +268,21 @@ CvStatus *undistortPoints_Async( callback(new Mat{new cv::Mat(dst)}); END_WRAP } + +CvStatus *FindHomography_Async( + Mat src, + Mat dst, + int method, + double ransacReprojThreshold, + const int maxIters, + const double confidence, + CvCallback_2 callback +) { + BEGIN_WRAP + cv::Mat mask; + cv::Mat out = cv::findHomography( + *src.ptr, *dst.ptr, method, ransacReprojThreshold, mask, maxIters, confidence + ); + callback(new Mat{new cv::Mat(out)}, new Mat{new cv::Mat(mask)}); + END_WRAP +} diff --git a/src/calib3d/calib3d_async.h b/src/calib3d/calib3d_async.h index ab50a895..1fcffb1d 100644 --- a/src/calib3d/calib3d_async.h +++ b/src/calib3d/calib3d_async.h @@ -211,6 +211,16 @@ CvStatus *undistortPoints_Async( Mat distorted, Mat k, Mat d, Mat r, Mat p, TermCriteria criteria, CVD_OUT CvCallback_1 callback ); +CvStatus *FindHomography_Async( + Mat src, + Mat dst, + int method, + double ransacReprojThreshold, + const int maxIters, + const double confidence, + CvCallback_2 callback +); + #ifdef __cplusplus } #endif diff --git a/src/imgproc/imgproc.cpp b/src/imgproc/imgproc.cpp index 04bbcfa2..e5880b91 100644 --- a/src/imgproc/imgproc.cpp +++ b/src/imgproc/imgproc.cpp @@ -7,6 +7,7 @@ */ #include "imgproc.h" +#include "core/types.h" #include "core/vec.hpp" #include @@ -96,7 +97,7 @@ BoxFilter(Mat src, Mat dst, int ddepth, Size ps, Point anchor, bool normalize, i END_WRAP } CvStatus * -SqBoxFilter(Mat src, Mat dst, int ddepth, Size ps, Point anchor, bool normalize, int borderType) { +SqrBoxFilter(Mat src, Mat dst, int ddepth, Size ps, Point anchor, bool normalize, int borderType) { BEGIN_WRAP cv::sqrBoxFilter(*src.ptr, *dst.ptr, ddepth, cv::Size(ps.width, ps.height)); END_WRAP @@ -829,22 +830,7 @@ CvStatus *GetAffineTransform2f(VecPoint2f src, VecPoint2f dst, Mat *rval) { *rval = {new cv::Mat(cv::getAffineTransform(_src, _dst))}; END_WRAP } -CvStatus *FindHomography( - Mat src, - Mat dst, - int method, - double ransacReprojThreshold, - Mat mask, - const int maxIters, - const double confidence, - Mat *rval -) { - BEGIN_WRAP - *rval = {new cv::Mat(cv::findHomography( - *src.ptr, *dst.ptr, method, ransacReprojThreshold, *mask.ptr, maxIters, confidence - ))}; - END_WRAP -} + CvStatus *DrawContours(Mat src, VecVecPoint contours, int contourIdx, Scalar color, int thickness) { BEGIN_WRAP auto _contours = vecvecpoint_c2cpp(contours); @@ -1204,3 +1190,28 @@ CvStatus *Mat_AccumulatedWeightedWithMask(Mat src, Mat dst, double alpha, Mat ma cv::accumulateWeighted(*src.ptr, *dst.ptr, alpha, *mask.ptr); END_WRAP } + +CvStatus *FloodFill( + Mat src, + Mat mask, + Point seedPoint, + Scalar newVal, + Rect *rect, + Scalar loDiff, + Scalar upDiff, + int flags, + int *rval +) { + BEGIN_WRAP + auto _seedPoint = cv::Point(seedPoint.x, seedPoint.y); + auto _rect = cv::Rect(); + auto _newVal = cv::Scalar(newVal.val1, newVal.val2, newVal.val3, newVal.val4); + auto _loDiff = cv::Scalar(loDiff.val1, loDiff.val2, loDiff.val3, loDiff.val4); + auto _upDiff = cv::Scalar(upDiff.val1, upDiff.val2, upDiff.val3, upDiff.val4); + *rval = cv::floodFill(*src.ptr, *mask.ptr, _seedPoint, _newVal, &_rect, _loDiff, _upDiff, flags); + rect->x = _rect.x; + rect->y = _rect.y; + rect->width = _rect.width; + rect->height = _rect.height; + END_WRAP +} diff --git a/src/imgproc/imgproc.h b/src/imgproc/imgproc.h index 35f39185..0097278a 100644 --- a/src/imgproc/imgproc.h +++ b/src/imgproc/imgproc.h @@ -25,67 +25,78 @@ CVD_TYPEDEF(void, CLAHE); CVD_TYPEDEF(void, Subdiv2D); #endif -CvStatus *ArcLength(VecPoint curve, bool is_closed, CVD_OUT double *rval); -CvStatus *ApproxPolyDP(VecPoint curve, double epsilon, bool closed, CVD_OUT VecPoint *rval); -CvStatus *CvtColor(Mat src, CVD_OUT Mat dst, int code); -CvStatus *EqualizeHist(Mat src, CVD_OUT Mat dst); -CvStatus * -CalcHist(VecMat mats, VecI32 chans, Mat mask, CVD_OUT Mat hist, VecI32 sz, VecF32 rng, bool acc); -CvStatus *CalcBackProject( - VecMat mats, VecI32 chans, Mat hist, CVD_OUT Mat *backProject, VecF32 rng, double scale -); -CvStatus *CompareHist(Mat hist1, Mat hist2, int method, CVD_OUT double *rval); -CvStatus *ConvexHull(VecPoint points, CVD_OUT Mat hull, bool clockwise, bool returnPoints); -CvStatus *ConvexityDefects(VecPoint points, Mat hull, Mat result); +// SECTION - Image Filtering +// Applies the bilateral filter to an image. +// void cv::bilateralFilter (InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT) CvStatus *BilateralFilter(Mat src, Mat dst, int d, double sc, double ss); + +// Blurs an image using the normalized box filter. +// void cv::blur (InputArray src, OutputArray dst, Size ksize, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT) CvStatus *Blur(Mat src, Mat dst, Size ps); + +// Blurs an image using the box filter. +// void cv::boxFilter (InputArray src, OutputArray dst, int ddepth, Size ksize, Point anchor=Point(-1,-1), bool normalize=true, int borderType=BORDER_DEFAULT) CvStatus * BoxFilter(Mat src, Mat dst, int ddepth, Size ps, Point anchor, bool normalize, int borderType); -CvStatus * -SqBoxFilter(Mat src, Mat dst, int ddepth, Size ps, Point anchor, bool normalize, int borderType); + +// TODO +// Constructs the Gaussian pyramid for an image. +// void cv::buildPyramid (InputArray src, OutputArrayOfArrays dst, int maxlevel, int borderType=BORDER_DEFAULT) + +// Dilates an image by using a specific structuring element. +// void cv::dilate (InputArray src, OutputArray dst, InputArray kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue()) CvStatus *Dilate(Mat src, Mat dst, Mat kernel); CvStatus *DilateWithParams( Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue ); -CvStatus * -DistanceTransform(Mat src, Mat dst, Mat labels, int distanceType, int maskSize, int labelType); + +// Erodes an image by using a specific structuring element. +// void cv::erode (InputArray src, OutputArray dst, InputArray kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue()) CvStatus *Erode(Mat src, Mat dst, Mat kernel); CvStatus *ErodeWithParams( Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue ); -CvStatus *MatchTemplate(Mat image, Mat templ, Mat result, int method, Mat mask); -CvStatus *Moments(Mat src, bool binaryImage, Moment *rval); -CvStatus *PyrDown(Mat src, Mat dst, Size dstsize, int borderType); -CvStatus *PyrUp(Mat src, Mat dst, Size dstsize, int borderType); -CvStatus *BoundingRect(VecPoint pts, Rect *rval); -CvStatus *BoxPoints(RotatedRect rect, VecPoint2f *boxPts); -CvStatus *ContourArea(VecPoint pts, double *rval); -CvStatus *MinAreaRect(VecPoint pts, RotatedRect *rval); -CvStatus *FitEllipse(VecPoint pts, RotatedRect *rval); -CvStatus *MinEnclosingCircle(VecPoint pts, Point2f *center, float *radius); -CvStatus *FindContours(Mat src, Mat hierarchy, int mode, int method, VecVecPoint *rval); -CvStatus *PointPolygonTest(VecPoint pts, Point2f pt, bool measureDist, double *rval); + +// Convolves an image with the kernel. +// void cv::filter2D (InputArray src, OutputArray dst, int ddepth, InputArray kernel, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT) CvStatus * -ConnectedComponents(Mat src, Mat dst, int connectivity, int ltype, int ccltype, int *rval); -CvStatus *ConnectedComponentsWithStats( - Mat src, - Mat labels, - Mat stats, - Mat centroids, - int connectivity, - int ltype, - int ccltype, - int *rval -); +Filter2D(Mat src, Mat dst, int ddepth, Mat kernel, Point anchor, double delta, int borderType); +// Blurs an image using a Gaussian filter. +// void cv::GaussianBlur (InputArray src, OutputArray dst, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT, AlgorithmHint hint=cv::ALGO_HINT_DEFAULT) CvStatus *GaussianBlur(Mat src, Mat dst, Size ps, double sX, double sY, int bt); + +// TODO +// Returns filter coefficients for computing spatial image derivatives. +// void cv::getDerivKernels (OutputArray kx, OutputArray ky, int dx, int dy, int ksize, bool normalize=false, int ktype=CV_32F) + +// TODO +// Returns Gabor filter coefficients. +// Mat cv::getGaborKernel (Size ksize, double sigma, double theta, double lambd, double gamma, double psi=CV_PI *0.5, int ktype=CV_64F) + +// Returns Gaussian filter coefficients. +// Mat cv::getGaussianKernel (int ksize, double sigma, int ktype=CV_64F) CvStatus *GetGaussianKernel(int ksize, double sigma, int ktype, Mat *rval); + +// Returns a structuring element of the specified size and shape for morphological operations. +// Mat cv::getStructuringElement (int shape, Size ksize, Point anchor=Point(-1,-1)) +CvStatus *GetStructuringElement(int shape, Size ksize, Mat *rval); + +// Calculates the Laplacian of an image. +// void cv::Laplacian (InputArray src, OutputArray dst, int ddepth, int ksize=1, double scale=1, double delta=0, int borderType=BORDER_DEFAULT) CvStatus * Laplacian(Mat src, Mat dst, int dDepth, int kSize, double scale, double delta, int borderType); -CvStatus * -Scharr(Mat src, Mat dst, int dDepth, int dx, int dy, double scale, double delta, int borderType); -CvStatus *GetStructuringElement(int shape, Size ksize, Mat *rval); + +// Blurs an image using the median filter. +// void cv::medianBlur (InputArray src, OutputArray dst, int ksize) +CvStatus *MedianBlur(Mat src, Mat dst, int ksize); + +// returns "magic" border value for erosion and dilation. It is automatically transformed to Scalar::all(-DBL_MAX) for dilation. +// static Scalar cv::morphologyDefaultBorderValue () CvStatus *MorphologyDefaultBorderValue(Scalar *rval); + +// Performs advanced morphological transformations. +// void cv::morphologyEx (InputArray src, OutputArray dst, int op, InputArray kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue()) CvStatus *MorphologyEx(Mat src, Mat dst, int op, Mat kernel); CvStatus *MorphologyExWithParams( Mat src, @@ -97,87 +108,164 @@ CvStatus *MorphologyExWithParams( int borderType, Scalar borderValue ); -CvStatus *MedianBlur(Mat src, Mat dst, int ksize); -CvStatus *Canny(Mat src, Mat edges, double t1, double t2, int apertureSize, bool l2gradient); -CvStatus * -CornerSubPix(Mat img, VecPoint2f corners, Size winSize, Size zeroZone, TermCriteria criteria); -CvStatus *GoodFeaturesToTrack( - Mat img, - VecPoint2f *corners, - int maxCorners, - double quality, - double minDist, - Mat mask, - int blockSize, - bool useHarrisDetector, - double k -); -CvStatus *GoodFeaturesToTrackWithGradient( - Mat img, - VecPoint2f *corners, - int maxCorners, - double quality, - double minDist, - Mat mask, - int blockSize, - int gradientSize, - bool useHarrisDetector, - double k -); +// Blurs an image and downsamples it. +// void cv::pyrDown (InputArray src, OutputArray dst, const Size &dstsize=Size(), int borderType=BORDER_DEFAULT) +CvStatus *PyrDown(Mat src, Mat dst, Size dstsize, int borderType); + +// TODO +// Performs initial step of meanshift segmentation of an image. +// void cv::pyrMeanShiftFiltering (InputArray src, OutputArray dst, double sp, double sr, int maxLevel=1, TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 5, 1)) + +// Upsamples an image and then blurs it. +// void cv::pyrUp (InputArray src, OutputArray dst, const Size &dstsize=Size(), int borderType=BORDER_DEFAULT) +CvStatus *PyrUp(Mat src, Mat dst, Size dstsize, int borderType); + +// Calculates the first x- or y- image derivative using Scharr operator. +// void cv::Scharr (InputArray src, OutputArray dst, int ddepth, int dx, int dy, double scale=1, double delta=0, int borderType=BORDER_DEFAULT) CvStatus * -GrabCut(Mat img, Mat mask, Rect rect, Mat bgdModel, Mat fgdModel, int iterCount, int mode); -CvStatus *HoughCircles(Mat src, Mat circles, int method, double dp, double minDist); -CvStatus *HoughCirclesWithParams( +Scharr(Mat src, Mat dst, int dDepth, int dx, int dy, double scale, double delta, int borderType); + +// Applies a separable linear filter to an image. +// void cv::sepFilter2D (InputArray src, OutputArray dst, int ddepth, InputArray kernelX, InputArray kernelY, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT) +CvStatus *SepFilter2D( Mat src, - Mat circles, - int method, - double dp, - double minDist, - double param1, - double param2, - int minRadius, - int maxRadius + Mat dst, + int ddepth, + Mat kernelX, + Mat kernelY, + Point anchor, + double delta, + int borderType ); -CvStatus *HoughLines( + +// Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. +// void cv::Sobel (InputArray src, OutputArray dst, int ddepth, int dx, int dy, int ksize=3, double scale=1, double delta=0, int borderType=BORDER_DEFAULT) +CvStatus *Sobel( Mat src, - Mat lines, - double rho, - double theta, - int threshold, - double srn, - double stn, - double min_theta, - double max_theta + Mat dst, + int ddepth, + int dx, + int dy, + int ksize, + double scale, + double delta, + int borderType ); -CvStatus *HoughLinesP(Mat src, Mat lines, double rho, double theta, int threshold); -CvStatus *HoughLinesPWithParams( - Mat src, - Mat lines, - double rho, - double theta, - int threshold, - double minLineLength, - double maxLineGap + +// Calculates the first order image derivative in both x and y using a Sobel operator. +// void cv::spatialGradient (InputArray src, OutputArray dx, OutputArray dy, int ksize=3, int borderType=BORDER_DEFAULT) +CvStatus *SpatialGradient(Mat src, Mat dx, Mat dy, int ksize, int borderType); + +// Calculates the normalized sum of squares of the pixel values overlapping the filter. +// void cv::sqrBoxFilter (InputArray src, OutputArray dst, int ddepth, Size ksize, Point anchor=Point(-1, -1), bool normalize=true, int borderType=BORDER_DEFAULT) +CvStatus * +SqrBoxFilter(Mat src, Mat dst, int ddepth, Size ps, Point anchor, bool normalize, int borderType); + +// TODO +// Blurs an image using the stackBlur. +// void cv::stackBlur (InputArray src, OutputArray dst, Size ksize) + +// SECTION - Geometric Image Transformations + +// TODO +// Converts image transformation maps from one representation to another. +// void cv::convertMaps (InputArray map1, InputArray map2, OutputArray dstmap1, OutputArray dstmap2, int dstmap1type, bool nninterpolation=false) + +// Calculates an affine transform from three pairs of the corresponding points. +// Mat cv::getAffineTransform (const Point2f src[], const Point2f dst[]) +// Mat cv::getAffineTransform (InputArray src, InputArray dst) +CvStatus *GetAffineTransform(VecPoint src, VecPoint dst, Mat *rval); +CvStatus *GetAffineTransform2f(VecPoint2f src, VecPoint2f dst, Mat *rval); + + +// Calculates a perspective transform from four pairs of the corresponding points. +// Mat cv::getPerspectiveTransform (const Point2f src[], const Point2f dst[], int solveMethod=DECOMP_LU) +// Mat cv::getPerspectiveTransform (InputArray src, InputArray dst, int solveMethod=DECOMP_LU) +CvStatus *GetPerspectiveTransform(VecPoint src, VecPoint dst, Mat *rval, int solveMethod); +CvStatus *GetPerspectiveTransform2f(VecPoint2f src, VecPoint2f dst, Mat *rval, int solveMethod); + +// Retrieves a pixel rectangle from an image with sub-pixel accuracy. +// void cv::getRectSubPix (InputArray image, Size patchSize, Point2f center, OutputArray patch, int patchType=-1) +CvStatus *GetRectSubPix(Mat src, Size patchSize, Point2f center, Mat dst); + +// Calculates an affine matrix of 2D rotation. +// Mat cv::getRotationMatrix2D (Point2f center, double angle, double scale) +CvStatus *GetRotationMatrix2D(Point2f center, double angle, double scale, Mat *rval); + +// Inverts an affine transformation. +// void cv::invertAffineTransform (InputArray M, OutputArray iM) +CvStatus *InvertAffineTransform(Mat src, Mat dst); + +// Remaps an image to polar coordinates space. +// void cv::linearPolar (InputArray src, OutputArray dst, Point2f center, double maxRadius, int flags) +CvStatus *LinearPolar(Mat src, Mat dst, Point2f center, double maxRadius, int flags); + +// Remaps an image to semilog-polar coordinates space. +// void cv::logPolar (InputArray src, OutputArray dst, Point2f center, double M, int flags) +CvStatus *LogPolar(Mat src, Mat dst, Point2f center, double m, int flags); + +// Applies a generic geometrical transformation to an image. +// void cv::remap (InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode=BORDER_CONSTANT, const Scalar &borderValue=Scalar()) +CvStatus * +Remap(Mat src, Mat dst, Mat map1, Mat map2, int interpolation, int borderMode, Scalar borderValue); + +// Resizes an image. +// void cv::resize (InputArray src, OutputArray dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR) +CvStatus *Resize(Mat src, Mat dst, Size sz, double fx, double fy, int interp); + +// Applies an affine transformation to an image. +// void cv::warpAffine (InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar &borderValue=Scalar()) +CvStatus *WarpAffine(Mat src, Mat dst, Mat rot_mat, Size dsize); +CvStatus *WarpAffineWithParams( + Mat src, Mat dst, Mat rot_mat, Size dsize, int flags, int borderMode, Scalar borderValue ); -CvStatus *HoughLinesPointSet( - Mat points, - Mat lines, - int lines_max, - int threshold, - double min_rho, - double max_rho, - double rho_step, - double min_theta, - double max_theta, - double theta_step +// Applies a perspective transformation to an image. +// void cv::warpPerspective (InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar &borderValue=Scalar()) +CvStatus *WarpPerspective(Mat src, Mat dst, Mat m, Size dsize); +CvStatus *WarpPerspectiveWithParams( + Mat src, Mat dst, Mat rot_mat, Size dsize, int flags, int borderMode, Scalar borderValue ); -CvStatus *Integral(Mat src, Mat sum, Mat sqsum, Mat tilted, int sdepth, int sqdepth); -CvStatus *Threshold(Mat src, Mat dst, double thresh, double maxvalue, int typ, double *rval); + +// TODO +// Remaps an image to polar or semilog-polar coordinates space. +// void cv::warpPolar (InputArray src, OutputArray dst, Size dsize, Point2f center, double maxRadius, int flags) + +// SECTION - Miscellaneous Image Transformations +// Applies an adaptive threshold to an array. +// void cv::adaptiveThreshold (InputArray src, OutputArray dst, double maxValue, int adaptiveMethod, int thresholdType, int blockSize, double C) CvStatus *AdaptiveThreshold( Mat src, Mat dst, double maxValue, int adaptiveTyp, int typ, int blockSize, double c ); +// void cv::blendLinear (InputArray src1, InputArray src2, InputArray weights1, InputArray weights2, OutputArray dst) + +// void cv::distanceTransform (InputArray src, OutputArray dst, int distanceType, int maskSize, int dstType=CV_32F) + +// Calculates the distance to the closest zero pixel for each pixel of the source image. +// void cv::distanceTransform (InputArray src, OutputArray dst, OutputArray labels, int distanceType, int maskSize, int labelType=DIST_LABEL_CCOMP) +CvStatus * +DistanceTransform(Mat src, Mat dst, Mat labels, int distanceType, int maskSize, int labelType); + +// Fills a connected component with the given color. +// int cv::floodFill (InputOutputArray image, InputOutputArray mask, Point seedPoint, Scalar newVal, Rect *rect=0, Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), int flags=4) +// int cv::floodFill (InputOutputArray image, Point seedPoint, Scalar newVal, Rect *rect=0, Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), int flags=4) +CvStatus * FloodFill(Mat src, Mat mask, Point seedPoint, Scalar newVal, Rect *rect, Scalar loDiff, Scalar upDiff, int flags, int *rval); + +// Calculates the integral of an image. +// void cv::integral (InputArray src, OutputArray sum, int sdepth=-1) +// void cv::integral (InputArray src, OutputArray sum, OutputArray sqsum, int sdepth=-1, int sqdepth=-1) +// void cv::integral (InputArray src, OutputArray sum, OutputArray sqsum, OutputArray tilted, int sdepth=-1, int sqdepth=-1) +CvStatus *Integral(Mat src, Mat sum, Mat sqsum, Mat tilted, int sdepth, int sqdepth); + +// Applies a fixed-level threshold to each array element. +// double cv::threshold (InputArray src, OutputArray dst, double thresh, double maxval, int type) +CvStatus *Threshold(Mat src, Mat dst, double thresh, double maxvalue, int typ, double *rval); + +// SECTION - Drawing Functions + +// Draws an arrow segment pointing from the first point to the second one. +// void cv::arrowedLine (InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int line_type=8, int shift=0, double tipLength=0.1) CvStatus *ArrowedLine( Mat img, Point pt1, @@ -188,10 +276,42 @@ CvStatus *ArrowedLine( int shift, double tipLength ); + +// Draws a circle. +// void cv::circle (InputOutputArray img, Point center, int radius, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0) CvStatus *Circle(Mat img, Point center, int radius, Scalar color, int thickness); CvStatus *CircleWithParams( Mat img, Point center, int radius, Scalar color, int thickness, int lineType, int shift ); + +// Clips the line against the image rectangle. +// bool cv::clipLine (Rect imgRect, Point &pt1, Point &pt2) +// bool cv::clipLine (Size imgSize, Point &pt1, Point &pt2) +// bool cv::clipLine (Size2l imgSize, Point2l &pt1, Point2l &pt2) +CvStatus *ClipLine(Rect imgRect, Point pt1, Point pt2, bool *rval); + +// Draws contours outlines or filled contours. +// void cv::drawContours (InputOutputArray image, InputArrayOfArrays contours, int contourIdx, const Scalar &color, int thickness=1, int lineType=LINE_8, InputArray hierarchy=noArray(), int maxLevel=INT_MAX, Point offset=Point()) +CvStatus *DrawContours(Mat src, VecVecPoint contours, int contourIdx, Scalar color, int thickness); +CvStatus *DrawContoursWithParams( + Mat src, + VecVecPoint contours, + int contourIdx, + Scalar color, + int thickness, + int lineType, + Mat hierarchy, + int maxLevel, + Point offset +); + +// Draws a marker on a predefined position in an image. +// void cv::drawMarker (InputOutputArray img, Point position, const Scalar &color, int markerType=MARKER_CROSS, int markerSize=20, int thickness=1, int line_type=8) + + +// Draws a simple or thick elliptic arc or fills an ellipse sector. +// void cv::ellipse (InputOutputArray img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0) +// void cv::ellipse (InputOutputArray img, const RotatedRect &box, const Scalar &color, int thickness=1, int lineType=LINE_8) CvStatus *Ellipse( Mat img, Point center, @@ -214,18 +334,44 @@ CvStatus *EllipseWithParams( int lineType, int shift ); -CvStatus *Line(Mat img, Point pt1, Point pt2, Scalar color, int thickness, int lineType, int shift); -CvStatus *Rectangle(Mat img, Rect rect, Scalar color, int thickness); -CvStatus * -RectangleWithParams(Mat img, Rect rect, Scalar color, int thickness, int lineType, int shift); + +// Approximates an elliptic arc with a polyline. +// void cv::ellipse2Poly (Point center, Size axes, int angle, int arcStart, int arcEnd, int delta, std::vector< Point > &pts) +// void cv::ellipse2Poly (Point2d center, Size2d axes, int angle, int arcStart, int arcEnd, int delta, std::vector< Point2d > &pts) + + +// Fills a convex polygon. +// void cv::fillConvexPoly (InputOutputArray img, InputArray points, const Scalar &color, int lineType=LINE_8, int shift=0) +// void cv::fillConvexPoly (InputOutputArray img, const Point *pts, int npts, const Scalar &color, int lineType=LINE_8, int shift=0) + +// Fills the area bounded by one or more polygons. +// void cv::fillPoly (InputOutputArray img, const Point **pts, const int *npts, int ncontours, const Scalar &color, int lineType=LINE_8, int shift=0, Point offset=Point()) +// void cv::fillPoly (InputOutputArray img, InputArrayOfArrays pts, const Scalar &color, int lineType=LINE_8, int shift=0, Point offset=Point()) CvStatus *FillPoly(Mat img, VecVecPoint points, Scalar color); CvStatus *FillPolyWithParams( Mat img, VecVecPoint points, Scalar color, int lineType, int shift, Point offset ); -CvStatus *Polylines(Mat img, VecVecPoint points, bool isClosed, Scalar color, int thickness); + +// Calculates the font-specific size to use to achieve a given height in pixels. +// double cv::getFontScaleFromHeight (const int fontFace, const int pixelHeight, const int thickness=1) + +// Calculates the width and height of a text string. +// Size cv::getTextSize (const String &text, int fontFace, double fontScale, int thickness, int *baseLine) CvStatus *GetTextSizeWithBaseline( const char *text, int fontFace, double fontScale, int thickness, int *baseline, Size *rval ); + +// Draws a line segment connecting two points. +// void cv::line (InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0) +CvStatus *Line(Mat img, Point pt1, Point pt2, Scalar color, int thickness, int lineType, int shift); + +// Draws several polygonal curves. +// void cv::polylines (InputOutputArray img, const Point *const *pts, const int *npts, int ncontours, bool isClosed, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0) +// void cv::polylines (InputOutputArray img, InputArrayOfArrays pts, bool isClosed, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0) +CvStatus *Polylines(Mat img, VecVecPoint points, bool isClosed, Scalar color, int thickness); + +// Draws a text string. +// void cv::putText (InputOutputArray img, const String &text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=LINE_8, bool bottomLeftOrigin=false) CvStatus *PutText( Mat img, const char *text, @@ -246,89 +392,35 @@ CvStatus *PutTextWithParams( int lineType, bool bottomLeftOrigin ); -CvStatus *Resize(Mat src, Mat dst, Size sz, double fx, double fy, int interp); -CvStatus *GetRectSubPix(Mat src, Size patchSize, Point2f center, Mat dst); -CvStatus *GetRotationMatrix2D(Point2f center, double angle, double scale, Mat *rval); -CvStatus *WarpAffine(Mat src, Mat dst, Mat rot_mat, Size dsize); -CvStatus *WarpAffineWithParams( - Mat src, Mat dst, Mat rot_mat, Size dsize, int flags, int borderMode, Scalar borderValue -); -CvStatus *WarpPerspective(Mat src, Mat dst, Mat m, Size dsize); -CvStatus *WarpPerspectiveWithParams( - Mat src, Mat dst, Mat rot_mat, Size dsize, int flags, int borderMode, Scalar borderValue -); -CvStatus *Watershed(Mat image, Mat markers); -CvStatus *ApplyColorMap(Mat src, Mat dst, int colormap); -CvStatus *ApplyCustomColorMap(Mat src, Mat dst, Mat colormap); -CvStatus *GetPerspectiveTransform(VecPoint src, VecPoint dst, Mat *rval, int solveMethod); -CvStatus *GetPerspectiveTransform2f(VecPoint2f src, VecPoint2f dst, Mat *rval, int solveMethod); -CvStatus *GetAffineTransform(VecPoint src, VecPoint dst, Mat *rval); -CvStatus *GetAffineTransform2f(VecPoint2f src, VecPoint2f dst, Mat *rval); -CvStatus *FindHomography( - Mat src, - Mat dst, - int method, - double ransacReprojThreshold, - Mat mask, - const int maxIters, - const double confidence, - Mat *rval -); -CvStatus *DrawContours(Mat src, VecVecPoint contours, int contourIdx, Scalar color, int thickness); -CvStatus *DrawContoursWithParams( - Mat src, - VecVecPoint contours, - int contourIdx, - Scalar color, - int thickness, - int lineType, - Mat hierarchy, - int maxLevel, - Point offset -); -CvStatus *Sobel( - Mat src, - Mat dst, - int ddepth, - int dx, - int dy, - int ksize, - double scale, - double delta, - int borderType -); -CvStatus *SpatialGradient(Mat src, Mat dx, Mat dy, int ksize, int borderType); -CvStatus * -Remap(Mat src, Mat dst, Mat map1, Mat map2, int interpolation, int borderMode, Scalar borderValue); -CvStatus * -Filter2D(Mat src, Mat dst, int ddepth, Mat kernel, Point anchor, double delta, int borderType); -CvStatus *SepFilter2D( - Mat src, - Mat dst, - int ddepth, - Mat kernelX, - Mat kernelY, - Point anchor, - double delta, - int borderType -); -CvStatus *LogPolar(Mat src, Mat dst, Point2f center, double m, int flags); -CvStatus *FitLine(VecPoint pts, Mat line, int distType, double param, double reps, double aeps); -CvStatus *LinearPolar(Mat src, Mat dst, Point2f center, double maxRadius, int flags); + +// Draws a simple, thick, or filled up-right rectangle. +// void cv::rectangle (InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0) +// void cv::rectangle (InputOutputArray img, Rect rec, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0) +CvStatus *Rectangle(Mat img, Rect rect, Scalar color, int thickness); CvStatus * -MatchShapes(VecPoint contour1, VecPoint contour2, int method, double parameter, double *rval); -CvStatus *ClipLine(Rect imgRect, Point pt1, Point pt2, bool *rval); +RectangleWithParams(Mat img, Rect rect, Scalar color, int thickness, int lineType, int shift); -CvStatus *CLAHE_Create(CLAHE *rval); -CvStatus *CLAHE_CreateWithParams(double clipLimit, Size tileGridSize, CLAHE *rval); -void CLAHE_Close(CLAHEPtr c); -CvStatus *CLAHE_Apply(CLAHE c, Mat src, Mat dst); -CvStatus *CLAHE_CollectGarbage(CLAHE c); -CvStatus *CLAHE_GetClipLimit(CLAHE c, double *rval); -CvStatus *CLAHE_SetClipLimit(CLAHE c, double clipLimit); -CvStatus *CLAHE_GetTilesGridSize(CLAHE c, Size *rval); -CvStatus *CLAHE_SetTilesGridSize(CLAHE c, Size size); +// SECTION - Color Space Conversions +// Converts an image from one color space to another. +// void cv::cvtColor (InputArray src, OutputArray dst, int code, int dstCn=0, AlgorithmHint hint=cv::ALGO_HINT_DEFAULT) +CvStatus *CvtColor(Mat src, CVD_OUT Mat dst, int code); + +// Converts an image from one color space to another where the source image is stored in two planes. +// void cv::cvtColorTwoPlane (InputArray src1, InputArray src2, OutputArray dst, int code, AlgorithmHint hint=cv::ALGO_HINT_DEFAULT) +// main function for all demosaicing processes +// void cv::demosaicing (InputArray src, OutputArray dst, int code, int dstCn=0) + +// SECTION - ColorMaps in OpenCV +// Applies a user colormap on a given image. +// void cv::applyColorMap (InputArray src, OutputArray dst, InputArray userColor) +CvStatus *ApplyCustomColorMap(Mat src, Mat dst, Mat colormap); + +// Applies a GNU Octave/MATLAB equivalent colormap on a given image. +// void cv::applyColorMap (InputArray src, OutputArray dst, int colormap) +CvStatus *ApplyColorMap(Mat src, Mat dst, int colormap); + +// SECTION - Planar Subdivision CvStatus *Subdiv2D_NewEmpty(Subdiv2D *rval); CvStatus *Subdiv2D_NewWithRect(Rect rect, Subdiv2D *rval); void Subdiv2D_Close(Subdiv2DPtr self); @@ -351,19 +443,329 @@ CvStatus *Subdiv2D_NextEdge(Subdiv2D self, int edge, int *rval); CvStatus *Subdiv2D_RotateEdge(Subdiv2D self, int edge, int rotate, int *rval); CvStatus *Subdiv2D_SymEdge(Subdiv2D self, int edge, int *rval); -CvStatus *InvertAffineTransform(Mat src, Mat dst); -CvStatus *PhaseCorrelate(Mat src1, Mat src2, Mat window, double *response, Point2f *rval); +// SECTION - Histograms +// Calculates the back projection of a histogram. +// void cv::calcBackProject (const Mat *images, int nimages, const int *channels, const SparseMat &hist, OutputArray backProject, const float **ranges, double scale=1, bool uniform=true) +// void cv::calcBackProject (const Mat *images, int nimages, const int *channels, InputArray hist, OutputArray backProject, const float **ranges, double scale=1, bool uniform=true) +// void cv::calcBackProject (InputArrayOfArrays images, const std::vector< int > &channels, InputArray hist, OutputArray dst, const std::vector< float > &ranges, double scale) +CvStatus *CalcBackProject( + VecMat mats, VecI32 chans, Mat hist, CVD_OUT Mat *backProject, VecF32 rng, double scale +); + +// Calculates a histogram of a set of arrays. +// void cv::calcHist (const Mat *images, int nimages, const int *channels, InputArray mask, OutputArray hist, int dims, const int *histSize, const float **ranges, bool uniform=true, bool accumulate=false) +// void cv::calcHist (const Mat *images, int nimages, const int *channels, InputArray mask, SparseMat &hist, int dims, const int *histSize, const float **ranges, bool uniform=true, bool accumulate=false) +// void cv::calcHist (InputArrayOfArrays images, const std::vector< int > &channels, InputArray mask, OutputArray hist, const std::vector< int > &histSize, const std::vector< float > &ranges, bool accumulate=false) +CvStatus * +CalcHist(VecMat mats, VecI32 chans, Mat mask, CVD_OUT Mat hist, VecI32 sz, VecF32 rng, bool acc); + +// Compares two histograms. +// double cv::compareHist (const SparseMat &H1, const SparseMat &H2, int method) +// double cv::compareHist (InputArray H1, InputArray H2, int method) +CvStatus *CompareHist(Mat hist1, Mat hist2, int method, CVD_OUT double *rval); + +// Creates a smart pointer to a cv::CLAHE class and initializes it. +// Ptr< CLAHE > cv::createCLAHE (double clipLimit=40.0, Size tileGridSize=Size(8, 8)) + +CvStatus *CLAHE_Create(CLAHE *rval); +CvStatus *CLAHE_CreateWithParams(double clipLimit, Size tileGridSize, CLAHE *rval); +void CLAHE_Close(CLAHEPtr c); +CvStatus *CLAHE_Apply(CLAHE c, Mat src, Mat dst); +CvStatus *CLAHE_CollectGarbage(CLAHE c); +CvStatus *CLAHE_GetClipLimit(CLAHE c, double *rval); +CvStatus *CLAHE_SetClipLimit(CLAHE c, double clipLimit); +CvStatus *CLAHE_GetTilesGridSize(CLAHE c, Size *rval); +CvStatus *CLAHE_SetTilesGridSize(CLAHE c, Size size); + +// Computes the "minimal work" distance between two weighted point configurations. +// float cv::EMD (InputArray signature1, InputArray signature2, int distType, InputArray cost=noArray(), float *lowerBound=0, OutputArray flow=noArray()) + +// Equalizes the histogram of a grayscale image. +// void cv::equalizeHist (InputArray src, OutputArray dst) +CvStatus *EqualizeHist(Mat src, CVD_OUT Mat dst); + +// float cv::wrapperEMD (InputArray signature1, InputArray signature2, int distType, InputArray cost=noArray(), Ptr< float > lowerBound=Ptr< float >(), OutputArray flow=noArray()) + +// SECTION - Structural Analysis and Shape Descriptors +// Approximates a polygonal curve(s) with the specified precision. +// void cv::approxPolyDP (InputArray curve, OutputArray approxCurve, double epsilon, bool closed) +CvStatus *ApproxPolyDP(VecPoint curve, double epsilon, bool closed, CVD_OUT VecPoint *rval); + +// Approximates a polygon with a convex hull with a specified accuracy and number of sides. +// void cv::approxPolyN (InputArray curve, OutputArray approxCurve, int nsides, float epsilon_percentage=-1.0, bool ensure_convex=true) + +// Calculates a contour perimeter or a curve length. +// double cv::arcLength (InputArray curve, bool closed) +CvStatus *ArcLength(VecPoint curve, bool is_closed, CVD_OUT double *rval); + +// Calculates the up-right bounding rectangle of a point set or non-zero pixels of gray-scale image. +// Rect cv::boundingRect (InputArray array) +CvStatus *BoundingRect(VecPoint pts, Rect *rval); + +// Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle. +// void cv::boxPoints (RotatedRect box, OutputArray points) +CvStatus *BoxPoints(RotatedRect rect, VecPoint2f *boxPts); + +// computes the connected components labeled image of boolean image +// int cv::connectedComponents (InputArray image, OutputArray labels, int connectivity, int ltype, int ccltype) +// int cv::connectedComponents (InputArray image, OutputArray labels, int connectivity=8, int ltype=CV_32S) +CvStatus * +ConnectedComponents(Mat src, Mat dst, int connectivity, int ltype, int ccltype, int *rval); + +// computes the connected components labeled image of boolean image and also produces a statistics output for each label +// int cv::connectedComponentsWithStats (InputArray image, OutputArray labels, OutputArray stats, OutputArray centroids, int connectivity, int ltype, int ccltype) +// int cv::connectedComponentsWithStats (InputArray image, OutputArray labels, OutputArray stats, OutputArray centroids, int connectivity=8, int ltype=CV_32S) +CvStatus *ConnectedComponentsWithStats( + Mat src, + Mat labels, + Mat stats, + Mat centroids, + int connectivity, + int ltype, + int ccltype, + int *rval +); + +// Calculates a contour area. +// double cv::contourArea (InputArray contour, bool oriented=false) +CvStatus *ContourArea(VecPoint pts, double *rval); + +// Finds the convex hull of a point set. +// void cv::convexHull (InputArray points, OutputArray hull, bool clockwise=false, bool returnPoints=true) +CvStatus *ConvexHull(VecPoint points, CVD_OUT Mat hull, bool clockwise, bool returnPoints); + +// Finds the convexity defects of a contour. +// void cv::convexityDefects (InputArray contour, InputArray convexhull, OutputArray convexityDefects) +CvStatus *ConvexityDefects(VecPoint points, Mat hull, Mat result); + +// Creates a smart pointer to a cv::GeneralizedHoughBallard class and initializes it. +// Ptr< GeneralizedHoughBallard > cv::createGeneralizedHoughBallard () + +// Creates a smart pointer to a cv::GeneralizedHoughGuil class and initializes it. +// Ptr< GeneralizedHoughGuil > cv::createGeneralizedHoughGuil () + +// Finds contours in a binary image. +// void cv::findContours (InputArray image, OutputArrayOfArrays contours, int mode, int method, Point offset=Point()) +// void cv::findContours (InputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset=Point()) +CvStatus *FindContours(Mat src, Mat hierarchy, int mode, int method, VecVecPoint *rval); +// Find contours using link runs algorithm. +// void cv::findContoursLinkRuns (InputArray image, OutputArrayOfArrays contours) +// void cv::findContoursLinkRuns (InputArray image, OutputArrayOfArrays contours, OutputArray hierarchy) + +// Fits an ellipse around a set of 2D points. +// RotatedRect cv::fitEllipse (InputArray points) +CvStatus *FitEllipse(VecPoint pts, RotatedRect *rval); + +// Fits an ellipse around a set of 2D points. +// RotatedRect cv::fitEllipseAMS (InputArray points) + +// Fits an ellipse around a set of 2D points. +// RotatedRect cv::fitEllipseDirect (InputArray points) + +// Fits a line to a 2D or 3D point set. +// void cv::fitLine (InputArray points, OutputArray line, int distType, double param, double reps, double aeps) +CvStatus *FitLine(VecPoint pts, Mat line, int distType, double param, double reps, double aeps); + +// Calculates seven Hu invariants. +// void cv::HuMoments (const Moments &m, OutputArray hu) +// void cv::HuMoments (const Moments &moments, double hu[7]) + +// Finds intersection of two convex polygons. +// float cv::intersectConvexConvex (InputArray p1, InputArray p2, OutputArray p12, bool handleNested=true) + +// Tests a contour convexity. +// bool cv::isContourConvex (InputArray contour) + +// Compares two shapes. +// double cv::matchShapes (InputArray contour1, InputArray contour2, int method, double parameter) +CvStatus * +MatchShapes(VecPoint contour1, VecPoint contour2, int method, double parameter, double *rval); + +// Finds a rotated rectangle of the minimum area enclosing the input 2D point set. +// RotatedRect cv::minAreaRect (InputArray points) +CvStatus *MinAreaRect(VecPoint pts, RotatedRect *rval); + +// Finds a circle of the minimum area enclosing a 2D point set. +// void cv::minEnclosingCircle (InputArray points, Point2f ¢er, float &radius) +CvStatus *MinEnclosingCircle(VecPoint pts, Point2f *center, float *radius); + +// Finds a triangle of minimum area enclosing a 2D point set and returns its area. +// double cv::minEnclosingTriangle (InputArray points, OutputArray triangle) + +// Calculates all of the moments up to the third order of a polygon or rasterized shape. +// Moments cv::moments (InputArray array, bool binaryImage=false) +CvStatus *Moments(Mat src, bool binaryImage, Moment *rval); + +// Performs a point-in-contour test. +// double cv::pointPolygonTest (InputArray contour, Point2f pt, bool measureDist) +CvStatus *PointPolygonTest(VecPoint pts, Point2f pt, bool measureDist, double *rval); + +// Finds out if there is any intersection between two rotated rectangles. +// int cv::rotatedRectangleIntersection (const RotatedRect &rect1, const RotatedRect &rect2, OutputArray intersectingRegion) + +// SECTION - Motion Analysis and Object Tracking +// Adds an image to the accumulator image. +// void cv::accumulate (InputArray src, InputOutputArray dst, InputArray mask=noArray()) CvStatus *Mat_Accumulate(Mat src, Mat dst); CvStatus *Mat_AccumulateWithMask(Mat src, Mat dst, Mat mask); -CvStatus *Mat_AccumulateSquare(Mat src, Mat dst); -CvStatus *Mat_AccumulateSquareWithMask(Mat src, Mat dst, Mat mask); + +// Adds the per-element product of two input images to the accumulator image. +// void cv::accumulateProduct (InputArray src1, InputArray src2, InputOutputArray dst, InputArray mask=noArray()) CvStatus *Mat_AccumulateProduct(Mat src1, Mat src2, Mat dst); CvStatus *Mat_AccumulateProductWithMask(Mat src1, Mat src2, Mat dst, Mat mask); + +// Adds the square of a source image to the accumulator image. +// void cv::accumulateSquare (InputArray src, InputOutputArray dst, InputArray mask=noArray()) +CvStatus *Mat_AccumulateSquare(Mat src, Mat dst); +CvStatus *Mat_AccumulateSquareWithMask(Mat src, Mat dst, Mat mask); + +// Updates a running average. +// void cv::accumulateWeighted (InputArray src, InputOutputArray dst, double alpha, InputArray mask=noArray()) CvStatus *Mat_AccumulatedWeighted(Mat src, Mat dst, double alpha); CvStatus *Mat_AccumulatedWeightedWithMask(Mat src, Mat dst, double alpha, Mat mask); + +// This function computes a Hanning window coefficients in two dimensions. +// void cv::createHanningWindow (OutputArray dst, Size winSize, int type) + +// Performs the per-element division of the first Fourier spectrum by the second Fourier spectrum. +// void cv::divSpectrums (InputArray a, InputArray b, OutputArray c, int flags, bool conjB=false) + +// The function is used to detect translational shifts that occur between two images. +// Point2d cv::phaseCorrelate (InputArray src1, InputArray src2, InputArray window=noArray(), double *response=0) +CvStatus *PhaseCorrelate(Mat src1, Mat src2, Mat window, double *response, Point2f *rval); + +// SECTION - Feature Detection +// Finds edges in an image using the Canny algorithm [48] . +// void cv::Canny (InputArray dx, InputArray dy, OutputArray edges, double threshold1, double threshold2, bool L2gradient=false) +// void cv::Canny (InputArray image, OutputArray edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false) +CvStatus *Canny(Mat src, Mat edges, double t1, double t2, int apertureSize, bool l2gradient); + +// Calculates eigenvalues and eigenvectors of image blocks for corner detection. +// void cv::cornerEigenValsAndVecs (InputArray src, OutputArray dst, int blockSize, int ksize, int borderType=BORDER_DEFAULT) + +// Harris corner detector. +// void cv::cornerHarris (InputArray src, OutputArray dst, int blockSize, int ksize, double k, int borderType=BORDER_DEFAULT) + +// Calculates the minimal eigenvalue of gradient matrices for corner detection. +// void cv::cornerMinEigenVal (InputArray src, OutputArray dst, int blockSize, int ksize=3, int borderType=BORDER_DEFAULT) + +// Refines the corner locations. +// void cv::cornerSubPix (InputArray image, InputOutputArray corners, Size winSize, Size zeroZone, TermCriteria criteria) +CvStatus * +CornerSubPix(Mat img, VecPoint2f corners, Size winSize, Size zeroZone, TermCriteria criteria); + +// Creates a smart pointer to a LineSegmentDetector object and initializes it. +// Ptr< LineSegmentDetector > cv::createLineSegmentDetector (int refine=LSD_REFINE_STD, double scale=0.8, double sigma_scale=0.6, double quant=2.0, double ang_th=22.5, double log_eps=0, double density_th=0.7, int n_bins=1024) + +// Determines strong corners on an image. +// Same as above, but returns also quality measure of the detected corners. +// void cv::goodFeaturesToTrack (InputArray image, OutputArray corners, int maxCorners, double qualityLevel, double minDistance, InputArray mask, int blockSize, int gradientSize, bool useHarrisDetector=false, double k=0.04) +// void cv::goodFeaturesToTrack (InputArray image, OutputArray corners, int maxCorners, double qualityLevel, double minDistance, InputArray mask, OutputArray cornersQuality, int blockSize=3, int gradientSize=3, bool useHarrisDetector=false, double k=0.04) +// void cv::goodFeaturesToTrack (InputArray image, OutputArray corners, int maxCorners, double qualityLevel, double minDistance, InputArray mask=noArray(), int blockSize=3, bool useHarrisDetector=false, double k=0.04) +CvStatus *GoodFeaturesToTrack( + Mat img, + VecPoint2f *corners, + int maxCorners, + double quality, + double minDist, + Mat mask, + int blockSize, + bool useHarrisDetector, + double k +); +CvStatus *GoodFeaturesToTrackWithGradient( + Mat img, + VecPoint2f *corners, + int maxCorners, + double quality, + double minDist, + Mat mask, + int blockSize, + int gradientSize, + bool useHarrisDetector, + double k +); + +// Finds circles in a grayscale image using the Hough transform. +// void cv::HoughCircles (InputArray image, OutputArray circles, int method, double dp, double minDist, double param1=100, double param2=100, int minRadius=0, int maxRadius=0) +CvStatus *HoughCircles(Mat src, Mat circles, int method, double dp, double minDist); +CvStatus *HoughCirclesWithParams( + Mat src, + Mat circles, + int method, + double dp, + double minDist, + double param1, + double param2, + int minRadius, + int maxRadius +); + +// Finds lines in a binary image using the standard Hough transform. +// void cv::HoughLines (InputArray image, OutputArray lines, double rho, double theta, int threshold, double srn=0, double stn=0, double min_theta=0, double max_theta=CV_PI) +CvStatus *HoughLines( + Mat src, + Mat lines, + double rho, + double theta, + int threshold, + double srn, + double stn, + double min_theta, + double max_theta +); + +// Finds line segments in a binary image using the probabilistic Hough transform. +// void cv::HoughLinesP (InputArray image, OutputArray lines, double rho, double theta, int threshold, double minLineLength=0, double maxLineGap=0) +CvStatus *HoughLinesP(Mat src, Mat lines, double rho, double theta, int threshold); +CvStatus *HoughLinesPWithParams( + Mat src, + Mat lines, + double rho, + double theta, + int threshold, + double minLineLength, + double maxLineGap +); + +// Finds lines in a set of points using the standard Hough transform. +// void cv::HoughLinesPointSet (InputArray point, OutputArray lines, int lines_max, int threshold, double min_rho, double max_rho, double rho_step, double min_theta, double max_theta, double theta_step) +CvStatus *HoughLinesPointSet( + Mat points, + Mat lines, + int lines_max, + int threshold, + double min_rho, + double max_rho, + double rho_step, + double min_theta, + double max_theta, + double theta_step +); + +// Calculates a feature map for corner detection. +// void cv::preCornerDetect (InputArray src, OutputArray dst, int ksize, int borderType=BORDER_DEFAULT) + +// SECTION - Object Detection +// Compares a template against overlapped image regions. +// void cv::matchTemplate (InputArray image, InputArray templ, OutputArray result, int method, InputArray mask=noArray()) +CvStatus *MatchTemplate(Mat image, Mat templ, Mat result, int method, Mat mask); + +// SECTION - Image Segmentation +// Runs the GrabCut algorithm. +// void cv::grabCut (InputArray img, InputOutputArray mask, Rect rect, InputOutputArray bgdModel, InputOutputArray fgdModel, int iterCount, int mode=GC_EVAL) +CvStatus * +GrabCut(Mat img, Mat mask, Rect rect, Mat bgdModel, Mat fgdModel, int iterCount, int mode); + +// Performs a marker-based image segmentation using the watershed algorithm. +// void cv::watershed (InputArray image, InputOutputArray markers) +CvStatus *Watershed(Mat image, Mat markers); + +// SECTION - Hardware Acceleration Layer + #ifdef __cplusplus } #endif -#endif //_OPENCV3_IMGPROC_H_ +#endif//_OPENCV3_IMGPROC_H_ diff --git a/src/imgproc/imgproc_async.cpp b/src/imgproc/imgproc_async.cpp index acda07ce..96e7fd4a 100644 --- a/src/imgproc/imgproc_async.cpp +++ b/src/imgproc/imgproc_async.cpp @@ -157,6 +157,28 @@ CvStatus *DistanceTransform_Async( END_WRAP } +CvStatus *FloodFill_Async( + Mat src, + Mat mask, + Point seedPoint, + Scalar newVal, + Scalar loDiff, + Scalar upDiff, + int flags, + CvCallback_2 callback +) { + BEGIN_WRAP + auto _seedPoint = cv::Point(seedPoint.x, seedPoint.y); + auto _rect = cv::Rect(); + auto _newVal = cv::Scalar(newVal.val1, newVal.val2, newVal.val3, newVal.val4); + auto _loDiff = cv::Scalar(loDiff.val1, loDiff.val2, loDiff.val3, loDiff.val4); + auto _upDiff = cv::Scalar(upDiff.val1, upDiff.val2, upDiff.val3, upDiff.val4); + int rval = + cv::floodFill(*src.ptr, *mask.ptr, _seedPoint, _newVal, &_rect, _loDiff, _upDiff, flags); + callback(new int(rval), new Rect{_rect.x, _rect.y, _rect.width, _rect.height}); + END_WRAP +} + CvStatus *EqualizeHist_Async(Mat src, CVD_OUT CvCallback_1 callback) { BEGIN_WRAP cv::Mat dst; @@ -1098,24 +1120,6 @@ CvStatus *GetAffineTransform2f_Async(VecPoint2f src, VecPoint2f dst, CvCallback_ END_WRAP } -CvStatus *FindHomography_Async( - Mat src, - Mat dst, - int method, - double ransacReprojThreshold, - const int maxIters, - const double confidence, - CvCallback_2 callback -) { - BEGIN_WRAP - cv::Mat mask; - cv::Mat out = cv::findHomography( - *src.ptr, *dst.ptr, method, ransacReprojThreshold, mask, maxIters, confidence - ); - callback(new Mat{new cv::Mat(out)}, new Mat{new cv::Mat(mask)}); - END_WRAP -} - CvStatus *DrawContours_Async( Mat src, VecVecPoint contours, diff --git a/src/imgproc/imgproc_async.h b/src/imgproc/imgproc_async.h index f2f8c793..b03e9803 100644 --- a/src/imgproc/imgproc_async.h +++ b/src/imgproc/imgproc_async.h @@ -44,6 +44,8 @@ CvStatus *DilateWithParams_Async( CvStatus *DistanceTransform_Async( Mat src, int distanceType, int maskSize, int labelType, CvCallback_2 callback ); +CvStatus *FloodFill_Async(Mat src, Mat mask, Point seedPoint, Scalar newVal, Scalar loDiff, Scalar upDiff, int flags, CvCallback_2 callback); + CvStatus *EqualizeHist_Async(Mat src, CVD_OUT CvCallback_1 callback); CvStatus *Erode_Async(Mat src, Mat kernel, CvCallback_1 callback); CvStatus *ErodeWithParams_Async( @@ -344,15 +346,7 @@ CvStatus *GetPerspectiveTransform2f_Async( ); CvStatus *GetAffineTransform_Async(VecPoint src, VecPoint dst, CvCallback_1 callback); CvStatus *GetAffineTransform2f_Async(VecPoint2f src, VecPoint2f dst, CvCallback_1 callback); -CvStatus *FindHomography_Async( - Mat src, - Mat dst, - int method, - double ransacReprojThreshold, - const int maxIters, - const double confidence, - CvCallback_2 callback -); + CvStatus *DrawContours_Async( Mat src, VecVecPoint contours, diff --git a/test/calib3d_test.dart b/test/calib3d_test.dart index ce709eca..3ed04520 100644 --- a/test/calib3d_test.dart +++ b/test/calib3d_test.dart @@ -403,4 +403,74 @@ void main() async { expect((m.rows, m.cols), (2, 3)); } }); + + // findHomography + test('cv.findHomography', () { + final src = cv.Mat.zeros(4, 1, cv.MatType.CV_64FC2); + final dst = cv.Mat.zeros(4, 1, cv.MatType.CV_64FC2); + final srcPts = [ + cv.Point2f(193, 932), + cv.Point2f(191, 378), + cv.Point2f(1497, 183), + cv.Point2f(1889, 681), + ]; + final dstPts = [ + cv.Point2f(51.51206544281359, -0.10425475260813055), + cv.Point2f(51.51211051314331, -0.10437947532732306), + cv.Point2f(51.512222354139325, -0.10437679311830816), + cv.Point2f(51.51214828037607, -0.1042212249954444), + ]; + for (var i = 0; i < srcPts.length; i++) { + src.set(i, 0, srcPts[i].x); + src.set(i, 1, srcPts[i].y); + } + for (var i = 0; i < dstPts.length; i++) { + dst.set(i, 0, dstPts[i].x); + dst.set(i, 1, dstPts[i].y); + } + + final mask = cv.Mat.empty(); + final m = cv.findHomography( + src, + dst, + method: cv.HOMOGRAPY_ALL_POINTS, + ransacReprojThreshold: 3, + mask: mask, + ); + expect(m.isEmpty, false); + }); + + // findHomography + test('cv.findHomographyAsync', () async { + final src = cv.Mat.zeros(4, 1, cv.MatType.CV_64FC2); + final dst = cv.Mat.zeros(4, 1, cv.MatType.CV_64FC2); + final srcPts = [ + cv.Point2f(193, 932), + cv.Point2f(191, 378), + cv.Point2f(1497, 183), + cv.Point2f(1889, 681), + ]; + final dstPts = [ + cv.Point2f(51.51206544281359, -0.10425475260813055), + cv.Point2f(51.51211051314331, -0.10437947532732306), + cv.Point2f(51.512222354139325, -0.10437679311830816), + cv.Point2f(51.51214828037607, -0.1042212249954444), + ]; + for (var i = 0; i < srcPts.length; i++) { + src.set(i, 0, srcPts[i].x); + src.set(i, 1, srcPts[i].y); + } + for (var i = 0; i < dstPts.length; i++) { + dst.set(i, 0, dstPts[i].x); + dst.set(i, 1, dstPts[i].y); + } + + final (m, _) = await cv.findHomographyAsync( + src, + dst, + method: cv.HOMOGRAPY_ALL_POINTS, + ransacReprojThreshold: 3, + ); + expect(m.isEmpty, false); + }); } diff --git a/test/imgproc/imgproc_async_test.dart b/test/imgproc/imgproc_async_test.dart index 16b7981e..13652de6 100644 --- a/test/imgproc/imgproc_async_test.dart +++ b/test/imgproc/imgproc_async_test.dart @@ -259,6 +259,31 @@ void main() async { expect(labels.isEmpty, false); }); + test('cv.floodFillAsync', () async { + final img = cv.Mat.zeros(256, 256, cv.MatType.CV_8UC3); + expect(img.isEmpty, false); + await cv.rectangleAsync(img, cv.Rect(0, 0, 255, 255), cv.Scalar.red, thickness: cv.FILLED); + await cv.rectangleAsync(img, cv.Rect(0, 0, 255, 255), cv.Scalar.black, thickness: 15); + await cv.rectangleAsync(img, cv.Rect(30, 40, 100, 100), cv.Scalar.blue, thickness: cv.FILLED); + await cv.rectangleAsync(img, cv.Rect(150, 160, 75, 75), cv.Scalar(0, 255, 255), thickness: cv.FILLED); + + final point = cv.Point(200, 100); + await cv.floodFillAsync(img, point, cv.Scalar(0, 255, 0)); + cv.imwrite("floodFillNoMask.png", img); + + var mask = cv.Mat.zeros(256, 256, cv.MatType.CV_8UC1); + mask.forEachPixel((row, col, pix) { + if (col <= 128) { + pix[0] = 255; + } + }); + mask = await cv.copyMakeBorderAsync(mask, 1, 1, 1, 1, cv.BORDER_REPLICATE); + cv.imwrite("mask.png", mask); + + await cv.floodFillAsync(img, point, cv.Scalar.white, mask: mask); + cv.imwrite("floodFillMask.png", img); + }); + test('cv.boundingRectAsync', () async { final img = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_GRAYSCALE); expect(img.isEmpty, false); @@ -724,40 +749,6 @@ void main() async { expect((m.rows, m.cols), (2, 3)); }); - // findHomography - test('cv.findHomographyAsync', () async { - final src = cv.Mat.zeros(4, 1, cv.MatType.CV_64FC2); - final dst = cv.Mat.zeros(4, 1, cv.MatType.CV_64FC2); - final srcPts = [ - cv.Point2f(193, 932), - cv.Point2f(191, 378), - cv.Point2f(1497, 183), - cv.Point2f(1889, 681), - ]; - final dstPts = [ - cv.Point2f(51.51206544281359, -0.10425475260813055), - cv.Point2f(51.51211051314331, -0.10437947532732306), - cv.Point2f(51.512222354139325, -0.10437679311830816), - cv.Point2f(51.51214828037607, -0.1042212249954444), - ]; - for (var i = 0; i < srcPts.length; i++) { - src.set(i, 0, srcPts[i].x); - src.set(i, 1, srcPts[i].y); - } - for (var i = 0; i < dstPts.length; i++) { - dst.set(i, 0, dstPts[i].x); - dst.set(i, 1, dstPts[i].y); - } - - final (m, _) = await cv.findHomographyAsync( - src, - dst, - method: cv.HOMOGRAPY_ALL_POINTS, - ransacReprojThreshold: 3, - ); - expect(m.isEmpty, false); - }); - // remap test('cv.remapAsync', () async { final src = await cv.imreadAsync("test/images/lenna.png", flags: cv.IMREAD_UNCHANGED); diff --git a/test/imgproc/imgproc_test.dart b/test/imgproc/imgproc_test.dart index e182cdbb..93a2e425 100644 --- a/test/imgproc/imgproc_test.dart +++ b/test/imgproc/imgproc_test.dart @@ -284,6 +284,32 @@ void main() async { expect(labels.isEmpty, false); }); + // http://amroamroamro.github.io/mexopencv/opencv/floodfill_demo.html + test('cv.floodFill', () { + final img = cv.Mat.zeros(256, 256, cv.MatType.CV_8UC3); + expect(img.isEmpty, false); + cv.rectangle(img, cv.Rect(0, 0, 255, 255), cv.Scalar.red, thickness: cv.FILLED); + cv.rectangle(img, cv.Rect(0, 0, 255, 255), cv.Scalar.black, thickness: 15); + cv.rectangle(img, cv.Rect(30, 40, 100, 100), cv.Scalar.blue, thickness: cv.FILLED); + cv.rectangle(img, cv.Rect(150, 160, 75, 75), cv.Scalar(0, 255, 255), thickness: cv.FILLED); + + final point = cv.Point(200, 100); + cv.floodFill(img, point, cv.Scalar(0, 255, 0)); + // cv.imwrite("floodFillNoMask.png", img); + + final mask = cv.Mat.zeros(256, 256, cv.MatType.CV_8UC1); + mask.forEachPixel((row, col, pix) { + if (col <= 128) { + pix[0] = 255; + } + }); + cv.copyMakeBorder(mask, 1, 1, 1, 1, cv.BORDER_REPLICATE, dst: mask); + // cv.imwrite("mask.png", mask); + + cv.floodFill(img, point, cv.Scalar.white, mask: mask); + // cv.imwrite("floodFillMask.png", img); + }); + test('cv.boundingRect', () { final img = cv.imread("test/images/lenna.png", flags: cv.IMREAD_GRAYSCALE); expect(img.isEmpty, false); @@ -756,42 +782,6 @@ void main() async { expect((m.rows, m.cols), (2, 3)); }); - // findHomography - test('cv.findHomography', () { - final src = cv.Mat.zeros(4, 1, cv.MatType.CV_64FC2); - final dst = cv.Mat.zeros(4, 1, cv.MatType.CV_64FC2); - final srcPts = [ - cv.Point2f(193, 932), - cv.Point2f(191, 378), - cv.Point2f(1497, 183), - cv.Point2f(1889, 681), - ]; - final dstPts = [ - cv.Point2f(51.51206544281359, -0.10425475260813055), - cv.Point2f(51.51211051314331, -0.10437947532732306), - cv.Point2f(51.512222354139325, -0.10437679311830816), - cv.Point2f(51.51214828037607, -0.1042212249954444), - ]; - for (var i = 0; i < srcPts.length; i++) { - src.set(i, 0, srcPts[i].x); - src.set(i, 1, srcPts[i].y); - } - for (var i = 0; i < dstPts.length; i++) { - dst.set(i, 0, dstPts[i].x); - dst.set(i, 1, dstPts[i].y); - } - - final mask = cv.Mat.empty(); - final m = cv.findHomography( - src, - dst, - method: cv.HOMOGRAPY_ALL_POINTS, - ransacReprojThreshold: 3, - mask: mask, - ); - expect(m.isEmpty, false); - }); - // remap test('cv.remap', () { final src = cv.imread("test/images/lenna.png", flags: cv.IMREAD_UNCHANGED);