Ask Your Question

eyeseefan's profile - activity

2020-10-04 07:21:34 -0500 received badge  Student (source)
2016-11-25 00:36:39 -0500 commented question Image Stitching: Unexpected black blobs/smear

I tried not using the mask, and it gave me the same result.

2016-11-24 19:27:09 -0500 asked a question Image Stitching: Unexpected black blobs/smear

I tried to stitch a few images using Opencv Stitcher class, following is my code:

vector<Mat> srcImgs;
int num_images = 9;
for (int i = 0; i < num_images; i++) {
    Mat pic = imread("img"+to_string(i)+".jpg");
    resize(pic, pic, Size(pic.size().width/2,pic.size().height/2));
    srcImgs.push_back(pic);
}

Stitcher stitcher = Stitcher::createDefault();

Mat matchMask(num_images,num_images,CV_8U,Scalar(0));
for (int i = 0; i < num_images-1; ++i)
{
    matchMask.at<char>(i,i+1) =1;
}

stitcher.setMatchingMask(matchMask.getUMat(ACCESS_READ));
stitcher.setWarper(makePtr<TransverseMercatorWarper>());
stitcher.setRegistrationResol(0.1);
stitcher.setSeamEstimationResol(0.1);

Mat result;
stitcher.stitch(srcImgs, result);
imwrite("result.png", result);

namedWindow("cvWindow");
imshow("cvWindow", result);
waitKey(0);

I use opencv 3.1 and run it on Mac. Everything works fine, except the resulting image has random regions of black blobs within the stitched photo(I am not talking about the black region around the stitched image, which is completely fine). The photos are not damaged and are well loaded with no black blobs. Every time I run the program, the resulting image has different black blobs, which is quite spooky. Sometimes the result is perfect. This is very weird. The following images demonstrate what I mean. The error should very probably come from either the OpenCV SDK or because of some weird reason for running it on Mac. I tried various codes(including the simplest one without any customisation of masking masks, warpers,etc.), but it still gives me the same problem.

First Time I run the program, the result is: image description

Second Time I run the same program, the result is(almost perfect, still black blobs in the centre picture if you see carefully): image description

Third Time I run the same program, the result is perfect here: image description

Fourth Time, wrong again:

image description

Fifth Time of the same program with the same exact codes and pictures, wrong: image description

This is just so weird. Can someone help me?