Skip to content

Commit 938effd

Browse files
committed
add test for vecpoint3i
1 parent f060a8a commit 938effd

File tree

12 files changed

+131
-107
lines changed

12 files changed

+131
-107
lines changed

lib/src/core/error_code.dart

Lines changed: 58 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// coverage:ignore-file
2-
// ignore_for_file: non_constant_identifier_names
2+
// ignore_for_file: non_constant_identifier_names, constant_identifier_names
33

44
/* Error status codes
55
Original codes were from OpenCVSharp
@@ -10,168 +10,156 @@
1010
Ported to Dart By: @Rainyl
1111
LICENSE: Apache-2.0
1212
*/
13-
14-
import 'base.dart';
15-
16-
class ErrorCode with ComparableMixin {
13+
extension type const ErrorCode(int code) {
1714
/// @brief everithing is ok CV_StsOk
18-
static final ErrorCode StsOk = ErrorCode(0);
15+
static const StsOk = ErrorCode(0);
1916

2017
/// @brief pseudo error for back trace CV_StsBackTrace
21-
static final ErrorCode StsBackTrace = ErrorCode(-1);
18+
static const StsBackTrace = ErrorCode(-1);
2219

2320
/// @brief unknown /unspecified error CV_StsError
24-
static final ErrorCode StsError = ErrorCode(-2);
21+
static const StsError = ErrorCode(-2);
2522

2623
/// @brief internal error (bad state) CV_StsInternal
27-
static final ErrorCode StsInternal = ErrorCode(-3);
24+
static const StsInternal = ErrorCode(-3);
2825

2926
/// @brief insufficient memory CV_StsNoMem
30-
static final ErrorCode StsNoMem = ErrorCode(-4);
27+
static const StsNoMem = ErrorCode(-4);
3128

3229
/// @brief function arg/param is bad CV_StsBadArg
33-
static final ErrorCode StsBadArg = ErrorCode(-5);
30+
static const StsBadArg = ErrorCode(-5);
3431

3532
/// @brief unsupported function CV_StsBadFunc
36-
static final ErrorCode StsBadFunc = ErrorCode(-6);
33+
static const StsBadFunc = ErrorCode(-6);
3734

3835
/// @brief iter. didn't converge CV_StsNoConv
39-
static final ErrorCode StsNoConv = ErrorCode(-7);
36+
static const StsNoConv = ErrorCode(-7);
4037

4138
/// @brief tracing CV_StsAutoTrace
42-
static final ErrorCode StsAutoTrace = ErrorCode(-8);
39+
static const StsAutoTrace = ErrorCode(-8);
4340

4441
/// @brief image header is NULL CV_HeaderIsNull
45-
static final ErrorCode HeaderIsNull = ErrorCode(-9);
42+
static const HeaderIsNull = ErrorCode(-9);
4643

4744
/// @brief image size is invalid CV_BadImageSize
48-
static final ErrorCode BadImageSize = ErrorCode(-10);
45+
static const BadImageSize = ErrorCode(-10);
4946

5047
/// @brief offset is invalid CV_BadOffset
51-
static final ErrorCode BadOffset = ErrorCode(-11);
48+
static const BadOffset = ErrorCode(-11);
5249

5350
/// @brief CV_BadOffset
54-
static final ErrorCode BadDataPtr = ErrorCode(-12);
51+
static const BadDataPtr = ErrorCode(-12);
5552

5653
/// @brief CV_BadStep
57-
static final ErrorCode BadStep = ErrorCode(-13);
54+
static const BadStep = ErrorCode(-13);
5855

5956
/// @brief CV_BadModelOrChSeq
60-
static final ErrorCode BadModelOrChSeq = ErrorCode(-14);
57+
static const BadModelOrChSeq = ErrorCode(-14);
6158

6259
/// @brief CV_BadNumChannels
63-
static final ErrorCode BadNumChannels = ErrorCode(-15);
60+
static const BadNumChannels = ErrorCode(-15);
6461

6562
/// @brief CV_BadNumChannel1U
66-
static final ErrorCode BadNumChannel1U = ErrorCode(-16);
63+
static const BadNumChannel1U = ErrorCode(-16);
6764

6865
/// @brief CV_BadDepth
69-
static final ErrorCode BadDepth = ErrorCode(-17);
66+
static const BadDepth = ErrorCode(-17);
7067

7168
/// @brief CV_BadAlphaChannel
72-
static final ErrorCode BadAlphaChannel = ErrorCode(-18);
69+
static const BadAlphaChannel = ErrorCode(-18);
7370

7471
/// @brief CV_BadOrder
75-
static final ErrorCode BadOrder = ErrorCode(-19);
72+
static const BadOrder = ErrorCode(-19);
7673

7774
/// @brief CV_BadOrigin
78-
static final ErrorCode BadOrigin = ErrorCode(-20);
75+
static const BadOrigin = ErrorCode(-20);
7976

8077
/// @brief CV_BadAlign
81-
static final ErrorCode BadAlign = ErrorCode(-21);
78+
static const BadAlign = ErrorCode(-21);
8279

8380
/// @brief CV_BadCallBack
84-
static final ErrorCode BadCallBack = ErrorCode(-22);
81+
static const BadCallBack = ErrorCode(-22);
8582

8683
/// @brief CV_BadTileSize
87-
static final ErrorCode BadTileSize = ErrorCode(-23);
84+
static const BadTileSize = ErrorCode(-23);
8885

8986
/// @brief CV_BadCOI
90-
static final ErrorCode BadCOI = ErrorCode(-24);
87+
static const BadCOI = ErrorCode(-24);
9188

9289
/// @brief CV_BadROISize
93-
static final ErrorCode BadROISize = ErrorCode(-25);
90+
static const BadROISize = ErrorCode(-25);
9491

9592
/// @brief CV_MaskIsTiled
96-
static final ErrorCode MaskIsTiled = ErrorCode(-26);
93+
static const MaskIsTiled = ErrorCode(-26);
9794

9895
/// @brief null pointer CV_StsNullPtr
99-
static final ErrorCode StsNullPtr = ErrorCode(-27);
96+
static const StsNullPtr = ErrorCode(-27);
10097

10198
/// @brief incorrect vector length CV_StsVecLengthErr
102-
static final ErrorCode StsVecLengthErr = ErrorCode(-28);
99+
static const StsVecLengthErr = ErrorCode(-28);
103100

104101
/// @brief incorr. filter structure content CV_StsFilterStructContentErr
105-
static final ErrorCode StsFilterStructContentErr = ErrorCode(-29);
102+
static const StsFilterStructContentErr = ErrorCode(-29);
106103

107104
/// @brief incorr. transform kernel content CV_StsKernelStructContentErr
108-
static final ErrorCode StsKernelStructContentErr = ErrorCode(-30);
105+
static const StsKernelStructContentErr = ErrorCode(-30);
109106

110107
/// @brief incorrect filter ofset value CV_StsFilterOffsetErr
111-
static final ErrorCode StsFilterOffsetErr = ErrorCode(-31);
108+
static const StsFilterOffsetErr = ErrorCode(-31);
112109

113110
/*extra for CV */
114111

115112
/// @brief the input/output structure size is incorrect CV_StsBadSize
116-
static final ErrorCode StsBadSize = ErrorCode(-201);
113+
static const StsBadSize = ErrorCode(-201);
117114

118115
/// @brief division by zero CV_StsDivByZero
119-
static final ErrorCode StsDivByZero = ErrorCode(-202);
116+
static const StsDivByZero = ErrorCode(-202);
120117

121118
/// @brief in-place operation is not supported CV_StsInplaceNotSupported
122-
static final ErrorCode StsInplaceNotSupported = ErrorCode(-203);
119+
static const StsInplaceNotSupported = ErrorCode(-203);
123120

124121
/// @brief request can't be completed CV_StsObjectNotFound
125-
static final ErrorCode StsObjectNotFound = ErrorCode(-204);
122+
static const StsObjectNotFound = ErrorCode(-204);
126123

127124
/// @brief formats of input/output arrays differ CV_StsUnmatchedFormats
128-
static final ErrorCode StsUnmatchedFormats = ErrorCode(-205);
125+
static const StsUnmatchedFormats = ErrorCode(-205);
129126

130127
/// @brief flag is wrong or not supported CV_StsBadFlag
131-
static final ErrorCode StsBadFlag = ErrorCode(-206);
128+
static const StsBadFlag = ErrorCode(-206);
132129

133130
/// @brief bad MyCvPoint CV_StsBadPoint
134-
static final ErrorCode StsBadPoint = ErrorCode(-207);
131+
static const StsBadPoint = ErrorCode(-207);
135132

136133
/// @brief bad format of mask (neither 8uC1 nor 8sC1) CV_StsBadMask
137-
static final ErrorCode StsBadMask = ErrorCode(-208);
134+
static const StsBadMask = ErrorCode(-208);
138135

139136
/// @brief sizes of input/output structures do not match CV_StsUnmatchedSizes
140-
static final ErrorCode StsUnmatchedSizes = ErrorCode(-209);
137+
static const StsUnmatchedSizes = ErrorCode(-209);
141138

142139
/// @brief the data format/type is not supported by the function CV_StsUnsupportedFormat
143-
static final ErrorCode StsUnsupportedFormat = ErrorCode(-210);
140+
static const StsUnsupportedFormat = ErrorCode(-210);
144141

145142
/// @brief some of parameters are out of range CV_StsOutOfRange
146-
static final ErrorCode StsOutOfRange = ErrorCode(-211);
143+
static const StsOutOfRange = ErrorCode(-211);
147144

148145
/// @brief invalid syntax/structure of the parsed file CV_StsParseError
149-
static final ErrorCode StsParseError = ErrorCode(-212);
146+
static const StsParseError = ErrorCode(-212);
150147

151148
/// @brief the requested function/feature is not implemented CV_StsNotImplemented
152-
static final ErrorCode StsNotImplemented = ErrorCode(-213);
149+
static const StsNotImplemented = ErrorCode(-213);
153150

154151
/// @brief an allocated block has been corrupted CV_StsBadMemBlock
155-
static final ErrorCode StsBadMemBlock = ErrorCode(-214);
152+
static const StsBadMemBlock = ErrorCode(-214);
156153

157154
/// @brief assertion failed
158-
static final ErrorCode StsAssert = ErrorCode(-215);
159-
160-
static final ErrorCode GpuNotSupported = ErrorCode(-216);
161-
static final ErrorCode GpuApiCallError = ErrorCode(-217);
162-
static final ErrorCode OpenGlNotSupported = ErrorCode(-218);
163-
static final ErrorCode OpenGlApiCallError = ErrorCode(-219);
164-
static final ErrorCode OpenCLApiCallError = ErrorCode(-220);
165-
static final ErrorCode OpenCLDoubleNotSupported = ErrorCode(-221);
166-
static final ErrorCode OpenCLInitError = ErrorCode(-222);
167-
static final ErrorCode OpenCLNoAMDBlasFft = ErrorCode(-223);
168-
169-
ErrorCode(this.code);
170-
final int code;
171-
172-
@override
173-
List<int> get props => [code];
174-
175-
@override
176-
String toString() => "$code";
155+
static const StsAssert = ErrorCode(-215);
156+
157+
static const GpuNotSupported = ErrorCode(-216);
158+
static const GpuApiCallError = ErrorCode(-217);
159+
static const OpenGlNotSupported = ErrorCode(-218);
160+
static const OpenGlApiCallError = ErrorCode(-219);
161+
static const OpenCLApiCallError = ErrorCode(-220);
162+
static const OpenCLDoubleNotSupported = ErrorCode(-221);
163+
static const OpenCLInitError = ErrorCode(-222);
164+
static const OpenCLNoAMDBlasFft = ErrorCode(-223);
177165
}

lib/src/core/exception.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// coverage:ignore-file
12
// ignore_for_file: avoid_print
23
import 'error_code.dart';
34

lib/src/core/mat.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class Mat extends CvStruct<cvg.Mat> {
8080
cvRun(() => CFFI.Mat_NewFromVecPoint2f(vec.ref, p));
8181
} else if (vec is VecPoint3f) {
8282
cvRun(() => CFFI.Mat_NewFromVecPoint3f(vec.ref, p));
83+
} else if (vec is VecPoint3i) {
84+
cvRun(() => CFFI.Mat_NewFromVecPoint3i(vec.ref, p));
8385
} else {
8486
throw UnsupportedError("Unsupported Vec type ${vec.runtimeType}");
8587
}

lib/src/core/mat_type.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// coverage:ignore-file
12
// ignore_for_file: constant_identifier_names, non_constant_identifier_names
23

34
library cv;

lib/src/core/point.dart

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -725,35 +725,15 @@ extension ListListPoint3fExtension on List<List<Point3f>> {
725725
}
726726

727727
extension PointRecordExtension on (int x, int y) {
728-
ffi.Pointer<cvg.Point> toPoint(Arena arena) {
729-
final point = arena<cvg.Point>()
730-
..ref.x = this.$1
731-
..ref.y = this.$2;
732-
return point;
733-
}
734-
735728
Point get asPoint => Point(this.$1, this.$2);
736729
}
737730

738731
extension Point2fRecordExtension on (double x, double y) {
739-
ffi.Pointer<cvg.Point2f> toPoint(Arena arena) {
740-
final point = arena<cvg.Point2f>()
741-
..ref.x = this.$1
742-
..ref.y = this.$2;
743-
return point;
744-
}
745-
746732
Point2f get asPoint2f => Point2f(this.$1, this.$2);
747733
}
748734

749735
extension Point3fRecordExtension on (double x, double y, double z) {
750-
ffi.Pointer<cvg.Point3f> toPoint(Arena arena) {
751-
final point = arena<cvg.Point3f>()
752-
..ref.x = this.$1
753-
..ref.y = this.$2
754-
..ref.z = this.$3;
755-
return point;
756-
}
736+
Point3f get asPoint3f => Point3f(this.$1, this.$2, this.$3);
757737
}
758738

759739
// completers

lib/src/core/scalar.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,7 @@ class Scalar extends CvStruct<cvg.Scalar> {
9292
}
9393

9494
extension RecordScalarExtension on (double val1, double val2, double val3, double val4) {
95-
ffi.Pointer<cvg.Scalar> toScalar(Arena arena) {
96-
final scalar = arena<cvg.Scalar>()
97-
..ref.val1 = this.$1
98-
..ref.val2 = this.$2
99-
..ref.val3 = this.$3
100-
..ref.val4 = this.$4;
101-
return scalar;
102-
}
95+
Scalar get asScalar => Scalar(this.$1, this.$2, this.$3, this.$4);
10396
}
10497

10598
// async completer

lib/src/opencv.g.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16767,6 +16767,23 @@ class CvNative {
1676716767
late final _Mat_NewFromVecPoint3f_Async = _Mat_NewFromVecPoint3f_AsyncPtr
1676816768
.asFunction<ffi.Pointer<CvStatus> Function(VecPoint3f, CvCallback_1)>();
1676916769

16770+
ffi.Pointer<CvStatus> Mat_NewFromVecPoint3i(
16771+
VecPoint3i vec,
16772+
ffi.Pointer<Mat> rval,
16773+
) {
16774+
return _Mat_NewFromVecPoint3i(
16775+
vec,
16776+
rval,
16777+
);
16778+
}
16779+
16780+
late final _Mat_NewFromVecPoint3iPtr = _lookup<
16781+
ffi.NativeFunction<
16782+
ffi.Pointer<CvStatus> Function(
16783+
VecPoint3i, ffi.Pointer<Mat>)>>('Mat_NewFromVecPoint3i');
16784+
late final _Mat_NewFromVecPoint3i = _Mat_NewFromVecPoint3iPtr.asFunction<
16785+
ffi.Pointer<CvStatus> Function(VecPoint3i, ffi.Pointer<Mat>)>();
16786+
1677016787
ffi.Pointer<CvStatus> Mat_NewFromVecPoint_Async(
1677116788
VecPoint vec,
1677216789
CvCallback_1 callback,

src/core/core.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ CvStatus *Mat_NewFromVecPoint3f(VecPoint3f vec, Mat *rval) {
142142
*rval = {new cv::Mat(*vec.ptr)};
143143
END_WRAP
144144
}
145+
146+
CvStatus *Mat_NewFromVecPoint3i(VecPoint3i vec, Mat *rval) {
147+
BEGIN_WRAP
148+
*rval = {new cv::Mat(*vec.ptr)};
149+
END_WRAP
150+
}
151+
145152
CvStatus *Mat_FromPtr(Mat m, int rows, int cols, int type, int prows, int pcols, Mat *rval) {
146153
BEGIN_WRAP
147154
*rval = {new cv::Mat(rows, cols, type, m.ptr->ptr(prows, pcols))};

src/core/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ CvStatus *Mat_NewFromBytes(int rows, int cols, int type, void *buf, Mat *rval);
4949
CvStatus *Mat_NewFromVecPoint(VecPoint vec, Mat *rval);
5050
CvStatus *Mat_NewFromVecPoint2f(VecPoint2f vec, Mat *rval);
5151
CvStatus *Mat_NewFromVecPoint3f(VecPoint3f vec, Mat *rval);
52+
CvStatus *Mat_NewFromVecPoint3i(VecPoint3i vec, Mat *rval);
5253
CvStatus *Mat_FromPtr(Mat m, int rows, int cols, int type, int prows, int pcols, Mat *rval);
5354
CvStatus *Mat_FromCMat(Mat m, Mat *rval);
5455
CvStatus *Mat_FromRange(Mat m, int rowStart, int rowEnd, int colStart, int colEnd, Mat *rval);

test/contrib/ximgproc_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void main() async {
8686
expect(dst.shape, src.shape);
8787
});
8888

89-
test('cv.StructuredEdgeDetection', () async {
89+
test('cv.StructuredEdgeDetection', tags: ["no-local-files"], () async {
9090
final src = cv.imread("test/images/circles.jpg");
9191
final rf = cv.RFFeatureGetter.empty();
9292
final detector =

0 commit comments

Comments
 (0)