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 1060539 commit 53a3a31
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 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(() => CFFI.Stitcher_ComposePanorama(stitcher, rpano.ref, rptr))
: cvRun(() => CFFI.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
26 changes: 24 additions & 2 deletions test/stitching_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main() {
final (status, pano) = stitcher.stitch(images.cvd);
expect(status, cv.StitcherStatus.OK);
expect(pano.isEmpty, false);
cv.imwrite('test/images_out/stitcher_test.jpg', pano);
// cv.imwrite('test/images_out/stitcher_test.jpg', pano);
});

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

test('cv.Stitcher getter/setter', () {
Expand Down 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 53a3a31

Please sign in to comment.