Skip to content

Commit 8813680

Browse files
authored
Merge pull request #49 from rainyl/issue48
fix: Stitcher.composePanorama
2 parents 1060539 + 022c8e3 commit 8813680

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.3+1
2+
3+
- fix: Stitcher.composePanorama
4+
15
## 1.0.3
26

37
- New API: Mat::ptr -> Mat.ptrAt

lib/src/stitching/stitching.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ class Stitcher extends CvStruct<cvg.PtrStitcher> {
153153
(StitcherStatus, Mat pano) composePanorama({VecMat? images}) {
154154
return using<(StitcherStatus, Mat)>((arena) {
155155
final rptr = arena<ffi.Int>();
156-
final rpano = arena<cvg.Mat>();
156+
final rpano = Mat.empty();
157157
images == null
158158
? cvRun(() => CFFI.Stitcher_ComposePanorama(stitcher, rpano.ref, rptr))
159159
: cvRun(() => CFFI.Stitcher_ComposePanorama_1(stitcher, images.ref, rpano.ref, rptr));
160-
return (StitcherStatus.fromInt(rptr.value), Mat.fromCMat(rpano.ref));
160+
return (StitcherStatus.fromInt(rptr.value), rpano);
161161
});
162162
}
163163

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: opencv_dart
22
description: "OpenCV4 bindings for Dart language and Flutter, using dart:ffi. The most complete OpenCV bindings for Dart!"
3-
version: 1.0.3
3+
version: 1.0.3+1
44
binary_version: 1.0.3
55
homepage: https://github.com/rainyl/opencv_dart
66

test/stitching_test.dart

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void main() {
1212
final (status, pano) = stitcher.stitch(images.cvd);
1313
expect(status, cv.StitcherStatus.OK);
1414
expect(pano.isEmpty, false);
15-
cv.imwrite('test/images_out/stitcher_test.jpg', pano);
15+
// cv.imwrite('test/images_out/stitcher_test.jpg', pano);
1616
});
1717

1818
test('cv.Stitcher with mask', () {
@@ -29,7 +29,7 @@ void main() {
2929
final (status, pano) = stitcher.stitch(images.cvd, masks: masks.cvd);
3030
expect(status, cv.StitcherStatus.OK);
3131
expect(pano.isEmpty, false);
32-
cv.imwrite('test/images_out/stitcher_test_mask.jpg', pano);
32+
// cv.imwrite('test/images_out/stitcher_test_mask.jpg', pano);
3333
});
3434

3535
test('cv.Stitcher getter/setter', () {
@@ -57,4 +57,26 @@ void main() {
5757

5858
expect(stitcher.component.length, greaterThanOrEqualTo(0));
5959
});
60+
61+
test('Issue 48', () {
62+
final images = [
63+
cv.imread("test/images/barcode1.png", flags: cv.IMREAD_COLOR),
64+
cv.imread("test/images/barcode2.png", flags: cv.IMREAD_COLOR),
65+
];
66+
67+
// Create Stitcher object
68+
final cv.Stitcher stitcher = cv.Stitcher.create();
69+
70+
// Estimate transformations and stitch images
71+
final cv.StitcherStatus status = stitcher.estimateTransform(images.cvd);
72+
expect(status, cv.StitcherStatus.OK);
73+
74+
final result = stitcher.composePanorama();
75+
expect(result.$1, cv.StitcherStatus.OK);
76+
expect(result.$2.isEmpty, false);
77+
78+
final result1 = stitcher.composePanorama(images: images.cvd);
79+
expect(result1.$1, cv.StitcherStatus.OK);
80+
expect(result1.$2.isEmpty, false);
81+
});
6082
}

0 commit comments

Comments
 (0)