Skip to content

Commit 0e7732f

Browse files
committed
API change: Mat.fromScalar
1 parent a0fd236 commit 0e7732f

37 files changed

+286
-153
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space # "space""tab"
5+
indent_size = 2
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
max_line_length = 100

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ OpenCV Bindings for Dart Language.
55
<p align="center">
66
<a href="https://codecov.io/github/rainyl/opencv_dart" ><img src="https://codecov.io/github/rainyl/opencv_dart/graph/badge.svg?token=2H0WWT39SN"/></a>
77
<a href="https://github.com/rainyl/opencv_dart"><img src="https://img.shields.io/github/stars/rainyl/opencv_dart.svg?style=flat&logo=github&label=stars" alt="Star on Github"></a>
8+
<a href="https://pub.dev/packages/opencv_dart"><img src="https://img.shields.io/pub/v/opencv_dart.svg" alt="https://pub.dev/packages/opencv_dart"></a>
89
<a href="https://opensource.org/license/apache-2-0"><img src="https://img.shields.io/github/license/rainyl/opencv_dart" alt="License: Apache-2.0"></a>
910
</p>
1011

bin/setup_commands.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: avoid_print
2+
13
import 'dart:convert';
24
import 'dart:io';
35

lib/src/calib3d/calib3d.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class Fisheye {
5757
R ??= Mat.empty();
5858
P ??= Mat.empty();
5959
undistorted ??= Mat.empty();
60-
cvRun(() => CFFI.Fisheye_UndistortPoints(distorted.ref, undistorted!.ref, K.ref, D.ref, R!.ref, P!.ref));
60+
cvRun(() => CFFI.Fisheye_UndistortPoints(
61+
distorted.ref, undistorted!.ref, K.ref, D.ref, R!.ref, P!.ref));
6162
return undistorted;
6263
}
6364

@@ -211,7 +212,8 @@ Mat undistort(
211212
}) {
212213
dst ??= Mat.empty();
213214
newCameraMatrix ??= Mat.empty();
214-
cvRun(() => CFFI.Undistort(src.ref, dst!.ref, cameraMatrix.ref, distCoeffs.ref, newCameraMatrix!.ref));
215+
cvRun(() =>
216+
CFFI.Undistort(src.ref, dst!.ref, cameraMatrix.ref, distCoeffs.ref, newCameraMatrix!.ref));
215217
return dst;
216218
}
217219

@@ -337,8 +339,8 @@ Mat drawChessboardCorners(
337339
bool patternWasFound,
338340
) {
339341
return cvRunArena<Mat>((arena) {
340-
cvRun(() =>
341-
CFFI.DrawChessboardCorners(image.ref, patternSize.toSize(arena).ref, corners.ref, patternWasFound));
342+
cvRun(() => CFFI.DrawChessboardCorners(
343+
image.ref, patternSize.toSize(arena).ref, corners.ref, patternWasFound));
342344
return image;
343345
});
344346
}

lib/src/contrib/aruco.dart

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class ArucoDetector extends CvStruct<cvg.ArucoDetector> {
3737
///
3838
/// For further details, please see:
3939
/// https://docs.opencv.org/master/d9/d6a/group__aruco.html#ga3bc50d61fe4db7bce8d26d56b5a6428a
40-
(VecVecPoint2f corners, VecInt ids, VecVecPoint2f rejectedImgPoints) detectMarkers(InputArray image) {
40+
(VecVecPoint2f corners, VecInt ids, VecVecPoint2f rejectedImgPoints) detectMarkers(
41+
InputArray image) {
4142
return using<(VecVecPoint2f, VecInt, VecVecPoint2f)>((arena) {
4243
final pCorners = calloc<cvg.VecVecPoint2f>();
4344
final pRejected = calloc<cvg.VecVecPoint2f>();
@@ -55,8 +56,10 @@ class ArucoDetector extends CvStruct<cvg.ArucoDetector> {
5556
List<int> get props => [ptr.address];
5657
}
5758

58-
void arucoDrawDetectedMarkers(Mat img, VecVecPoint2f markerCorners, VecInt markerIds, Scalar borderColor) {
59-
cvRun(() => CFFI.ArucoDrawDetectedMarkers(img.ref, markerCorners.ref, markerIds.ref, borderColor.ref));
59+
void arucoDrawDetectedMarkers(
60+
Mat img, VecVecPoint2f markerCorners, VecInt markerIds, Scalar borderColor) {
61+
cvRun(() =>
62+
CFFI.ArucoDrawDetectedMarkers(img.ref, markerCorners.ref, markerIds.ref, borderColor.ref));
6063
}
6164

6265
void arucoGenerateImageMarker(
@@ -66,7 +69,8 @@ void arucoGenerateImageMarker(
6669
Mat img,
6770
int borderBits,
6871
) {
69-
cvRun(() => CFFI.ArucoGenerateImageMarker(dictionaryId.value, id, sidePixels, img.ref, borderBits));
72+
cvRun(
73+
() => CFFI.ArucoGenerateImageMarker(dictionaryId.value, id, sidePixels, img.ref, borderBits));
7074
}
7175

7276
class ArucoDetectorParameters extends CvStruct<cvg.ArucoDetectorParameters> {
@@ -82,7 +86,8 @@ class ArucoDetectorParameters extends CvStruct<cvg.ArucoDetectorParameters> {
8286

8387
@override
8488
cvg.ArucoDetectorParameters get ref => ptr.ref;
85-
static final finalizer = OcvFinalizer<cvg.ArucoDetectorParametersPtr>(CFFI.addresses.ArucoDetectorParameters_Close);
89+
static final finalizer =
90+
OcvFinalizer<cvg.ArucoDetectorParametersPtr>(CFFI.addresses.ArucoDetectorParameters_Close);
8691

8792
int get adaptiveThreshWinSizeMin {
8893
return cvRunArena<int>((arena) {
@@ -180,7 +185,8 @@ class ArucoDetectorParameters extends CvStruct<cvg.ArucoDetectorParameters> {
180185
});
181186
}
182187

183-
set minDistanceToBorder(int value) => CFFI.ArucoDetectorParameters_SetMinDistanceToBorder(ref, value);
188+
set minDistanceToBorder(int value) =>
189+
CFFI.ArucoDetectorParameters_SetMinDistanceToBorder(ref, value);
184190

185191
double get minMarkerDistanceRate {
186192
return cvRunArena<double>((arena) {
@@ -201,7 +207,8 @@ class ArucoDetectorParameters extends CvStruct<cvg.ArucoDetectorParameters> {
201207
});
202208
}
203209

204-
set cornerRefinementMethod(int value) => CFFI.ArucoDetectorParameters_SetCornerRefinementMethod(ref, value);
210+
set cornerRefinementMethod(int value) =>
211+
CFFI.ArucoDetectorParameters_SetCornerRefinementMethod(ref, value);
205212

206213
int get cornerRefinementWinSize {
207214
return cvRunArena<int>((arena) {
@@ -297,7 +304,8 @@ class ArucoDetectorParameters extends CvStruct<cvg.ArucoDetectorParameters> {
297304
});
298305
}
299306

300-
set errorCorrectionRate(double value) => CFFI.ArucoDetectorParameters_SetErrorCorrectionRate(ref, value);
307+
set errorCorrectionRate(double value) =>
308+
CFFI.ArucoDetectorParameters_SetErrorCorrectionRate(ref, value);
301309

302310
double get aprilTagQuadDecimate {
303311
return cvRunArena<double>((arena) {
@@ -307,7 +315,8 @@ class ArucoDetectorParameters extends CvStruct<cvg.ArucoDetectorParameters> {
307315
});
308316
}
309317

310-
set aprilTagQuadDecimate(double value) => CFFI.ArucoDetectorParameters_SetAprilTagQuadDecimate(ref, value);
318+
set aprilTagQuadDecimate(double value) =>
319+
CFFI.ArucoDetectorParameters_SetAprilTagQuadDecimate(ref, value);
311320

312321
double get aprilTagQuadSigma {
313322
return cvRunArena<double>((arena) {
@@ -317,7 +326,8 @@ class ArucoDetectorParameters extends CvStruct<cvg.ArucoDetectorParameters> {
317326
});
318327
}
319328

320-
set aprilTagQuadSigma(double value) => CFFI.ArucoDetectorParameters_SetAprilTagQuadSigma(ref, value);
329+
set aprilTagQuadSigma(double value) =>
330+
CFFI.ArucoDetectorParameters_SetAprilTagQuadSigma(ref, value);
321331

322332
int get aprilTagMinClusterPixels {
323333
return cvRunArena<int>((arena) {
@@ -338,7 +348,8 @@ class ArucoDetectorParameters extends CvStruct<cvg.ArucoDetectorParameters> {
338348
});
339349
}
340350

341-
set aprilTagMaxNmaxima(int value) => CFFI.ArucoDetectorParameters_SetAprilTagMaxNmaxima(ref, value);
351+
set aprilTagMaxNmaxima(int value) =>
352+
CFFI.ArucoDetectorParameters_SetAprilTagMaxNmaxima(ref, value);
342353

343354
double get aprilTagCriticalRad {
344355
return cvRunArena<double>((arena) {
@@ -348,7 +359,8 @@ class ArucoDetectorParameters extends CvStruct<cvg.ArucoDetectorParameters> {
348359
});
349360
}
350361

351-
set aprilTagCriticalRad(double value) => CFFI.ArucoDetectorParameters_SetAprilTagCriticalRad(ref, value);
362+
set aprilTagCriticalRad(double value) =>
363+
CFFI.ArucoDetectorParameters_SetAprilTagCriticalRad(ref, value);
352364

353365
double get aprilTagMaxLineFitMse {
354366
return cvRunArena<double>((arena) {

lib/src/contrib/aruco_dict.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ class ArucoDictionary extends CvStruct<cvg.ArucoDictionary> {
9393

9494
@override
9595
cvg.ArucoDictionary get ref => ptr.ref;
96-
static final finalizer = OcvFinalizer<cvg.ArucoDictionaryPtr>(CFFI.addresses.ArucoDictionary_Close);
96+
static final finalizer =
97+
OcvFinalizer<cvg.ArucoDictionaryPtr>(CFFI.addresses.ArucoDictionary_Close);
9798

9899
@override
99100
List<int> get props => [ptr.address];

lib/src/contrib/img_hash.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ const int BLOCK_MEAN_HASH_MODE_1 = 1;
7373

7474
/// BlockMeanHash is implementation of the BlockMeanHash algorithm.
7575
class BlockMeanHash extends CvStruct<cvg.BlockMeanHash> implements ImgHashBase {
76-
BlockMeanHash._(cvg.BlockMeanHashPtr ptr, [this._mode = BLOCK_MEAN_HASH_MODE_0]) : super.fromPointer(ptr) {
76+
BlockMeanHash._(cvg.BlockMeanHashPtr ptr, [this._mode = BLOCK_MEAN_HASH_MODE_0])
77+
: super.fromPointer(ptr) {
7778
finalizer.attach(this, ptr.cast());
7879
}
79-
static final finalizer = OcvFinalizer<ffi.Pointer<cvg.BlockMeanHash>>(CFFI.addresses.BlockMeanHash_Close);
80+
static final finalizer =
81+
OcvFinalizer<ffi.Pointer<cvg.BlockMeanHash>>(CFFI.addresses.BlockMeanHash_Close);
8082

8183
factory BlockMeanHash({int mode = BLOCK_MEAN_HASH_MODE_0}) {
8284
final p = calloc<cvg.BlockMeanHash>();
@@ -223,7 +225,8 @@ class NewRadialVarianceHash implements ImgHashBase {
223225
double compare(InputArray hashOne, InputArray hashTwo) {
224226
return using<double>((arena) {
225227
final p = arena<ffi.Double>();
226-
cvRun(() => CFFI.radialVarianceHashCompare(hashOne.ref, hashTwo.ref, sigma, numOfAngleLine, p));
228+
cvRun(
229+
() => CFFI.radialVarianceHashCompare(hashOne.ref, hashTwo.ref, sigma, numOfAngleLine, p));
227230
return p.value;
228231
});
229232
}

lib/src/core/core.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,8 @@ Mat insertChannel(InputArray src, InputOutputArray dst, int coi) {
672672
final rval = cvRunArena<double>((arena) {
673673
final p = arena<ffi.Double>();
674674
cvRun(
675-
() => CFFI.KMeans(
676-
data.ref, K, bestLabels.ref, criteria.toTermCriteria(arena).ref, attempts, flags, centers!.ref, p),
675+
() => CFFI.KMeans(data.ref, K, bestLabels.ref, criteria.toTermCriteria(arena).ref, attempts,
676+
flags, centers!.ref, p),
677677
);
678678
return p.value;
679679
});
@@ -697,8 +697,8 @@ Mat insertChannel(InputArray src, InputOutputArray dst, int coi) {
697697
final rval = cvRunArena<double>((arena) {
698698
final p = arena<ffi.Double>();
699699
cvRun(
700-
() => CFFI.KMeansPoints(
701-
pts.ref, K, bestLabels.ref, criteria.toTermCriteria(arena).ref, attempts, flags, centers!.ref, p),
700+
() => CFFI.KMeansPoints(pts.ref, K, bestLabels.ref, criteria.toTermCriteria(arena).ref,
701+
attempts, flags, centers!.ref, p),
702702
);
703703
return p.value;
704704
});
@@ -793,14 +793,20 @@ Mat min(InputArray src1, InputArray src2, {OutputArray? dst}) {
793793
///
794794
/// For further details, please see:
795795
/// https://docs.opencv.org/trunk/d2/de8/group__core__array.html#gab473bf2eb6d14ff97e89b355dac20707
796-
(double minVal, double maxVal, Point minLoc, Point maxLoc) minMaxLoc(InputArray src, {InputArray? mask}) {
796+
(double minVal, double maxVal, Point minLoc, Point maxLoc) minMaxLoc(InputArray src,
797+
{InputArray? mask}) {
797798
return using<(double, double, Point, Point)>((arena) {
798799
final minValP = arena<ffi.Double>();
799800
final maxValP = arena<ffi.Double>();
800801
final minLocP = arena<cvg.Point>();
801802
final maxLocP = arena<cvg.Point>();
802803
cvRun(() => CFFI.Mat_MinMaxLoc(src.ref, minValP, maxValP, minLocP, maxLocP));
803-
return (minValP.value, maxValP.value, Point.fromNative(minLocP.ref), Point.fromNative(maxLocP.ref));
804+
return (
805+
minValP.value,
806+
maxValP.value,
807+
Point.fromNative(minLocP.ref),
808+
Point.fromNative(maxLocP.ref)
809+
);
804810
});
805811
}
806812

lib/src/core/exception.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: avoid_print
2+
13
import 'dart:ffi' as ffi;
24
import 'dart:io';
35

lib/src/core/keypoint.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class KeyPoint extends CvStruct<cvg.KeyPoint> {
1212
KeyPoint._(ffi.Pointer<cvg.KeyPoint> ptr) : super.fromPointer(ptr) {
1313
finalizer.attach(this, ptr.cast());
1414
}
15-
factory KeyPoint(double x, double y, double size, double angle, double response, int octave, int classID) {
15+
factory KeyPoint(
16+
double x, double y, double size, double angle, double response, int octave, int classID) {
1617
final ptr = calloc<cvg.KeyPoint>()
1718
..ref.x = x
1819
..ref.y = y

0 commit comments

Comments
 (0)