Skip to content

Commit

Permalink
fix: Stitcher.composePanorama
Browse files Browse the repository at this point in the history
  • Loading branch information
rainyl committed May 13, 2024
1 parent c0655ce commit a0314a4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/src/stitching/stitching.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ class Stitcher extends CvStruct<cvg.PtrStitcher> {
(StitcherStatus, Mat pano) composePanorama({VecMat? images}) {
return using<(StitcherStatus, Mat)>((arena) {
final rptr = arena<ffi.Int>();
final rpano = arena<cvg.Mat>();
final rpano = Mat.empty();
images == null
? cvRun(() => cvg.Stitcher_ComposePanorama(stitcher, rpano.ref, rptr))
: cvRun(() => cvg.Stitcher_ComposePanorama_1(stitcher, images.ref, rpano.ref, rptr));
return (StitcherStatus.fromInt(rptr.value), Mat.fromCMat(rpano.ref));
return (StitcherStatus.fromInt(rptr.value), rpano);
});
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: opencv_dart
description: "OpenCV4 bindings for Dart language and Flutter, using dart:ffi. The most complete OpenCV bindings for Dart!"
version: 2.0.0-dev.4
version: 2.0.0-dev.5
homepage: https://github.com/rainyl/opencv_dart

environment:
Expand Down
22 changes: 22 additions & 0 deletions test/stitching_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,26 @@ void main() {

expect(stitcher.component.length, greaterThanOrEqualTo(0));
});

test('Issue 48', () {
final images = [
cv.imread("test/images/barcode1.png", flags: cv.IMREAD_COLOR),
cv.imread("test/images/barcode2.png", flags: cv.IMREAD_COLOR),
];

// Create Stitcher object
final cv.Stitcher stitcher = cv.Stitcher.create();

// Estimate transformations and stitch images
final cv.StitcherStatus status = stitcher.estimateTransform(images.cvd);
expect(status, cv.StitcherStatus.OK);

final result = stitcher.composePanorama();
expect(result.$1, cv.StitcherStatus.OK);
expect(result.$2.isEmpty, false);

final result1 = stitcher.composePanorama(images: images.cvd);
expect(result1.$1, cv.StitcherStatus.OK);
expect(result1.$2.isEmpty, false);
});
}

0 comments on commit a0314a4

Please sign in to comment.