Ask Your Question

Qbaloz's profile - activity

2017-08-29 17:07:34 -0600 received badge  Student (source)
2015-09-21 14:02:30 -0600 asked a question Try to measure times of image stitching using OpenCV Stitcher. Different times when restarting/not restarting program. Issue with memory?

I made little application to stitch few images using OpenCV. It's mainly to measure times of stitching.

Here is a function to load photos using path in txt file:

void ReadPhotos(string sourceIN){

string sourcePhoto;
ifstream FileIN(sourceIN);

if (FileIN.is_open())
{
    while (getline(FileIN, sourcePhoto)){

        photos[photo_number] = imread(sourcePhoto, 1);
        photo_number++;
    }
}
else{
    cout << "Can't find file" << endl;
}

cout << "Number of photos: " << photo_number << endl;

//Size size(480, 270);

for (int i = 0; i < photo_number; i++){
    //resize(photos[i], photos[i], size);
    ImagesVector.push_back(photos[i]);
}
}

Here is MakePanorama function. I implemented here simple timer to measure time of stitching images. I need to know how long it takes to stitch 2,3,4.. images. It contains all openCV Stitcher Class functions:

void MakePanorama(vector< Mat > ImagesVector, string filename){

tp1 = std::chrono::high_resolution_clock::now();
Stitcher stitcher = Stitcher::createDefault(true);

stitcher.setWarper(new SphericalWarper()); // Rodzaj panoramy http://docs.opencv.org/master/d7/d1c/classcv_1_1WarperCreator.html
stitcher.setFeaturesFinder(new detail::SurfFeaturesFinder(900, 3, 4, 3, 4));
//stitcher.setFeaturesFinder(new detail::OrbFeaturesFinder(Size(3, 1), 1500, 1.3f, 5));
stitcher.setRegistrationResol(0.9);
stitcher.setSeamEstimationResol(0.9);
stitcher.setCompositingResol(1); // Rozdzielczosc zdjecia wyjsciowego
stitcher.setPanoConfidenceThresh(0.9);
stitcher.setWaveCorrection(true); // Korekcja obrazu - pionowa lub pozioma
stitcher.setWaveCorrectKind(detail::WAVE_CORRECT_HORIZ); // Korekcja obrazu - pionowa lub pozioma
stitcher.setFeaturesMatcher(new detail::BestOf2NearestMatcher(true, 0.3f));
stitcher.setBundleAdjuster(new detail::BundleAdjusterRay());
Stitcher::Status status = Stitcher::ERR_NEED_MORE_IMGS;
try{
    status = stitcher.stitch(ImagesVector, image);
}
catch (cv::Exception e){}

tp2 = std::chrono::high_resolution_clock::now();

cout << "Czas skladania panoramy: " << chrono::duration_cast<chrono::seconds>(tp2 - tp1).count() << " s" << endl;


imwrite(filename, image);

ImagesVector.clear();
ImagesVector.empty();
image.release();
image.empty();

photo_number = 0;

}

And here is main:

int main()
{
cout << "Starting program!" << endl;


ReadPhotos("paths2.txt");
MakePanorama(ImagesVector, "22.jpg");

ReadPhotos("paths3.txt");
MakePanorama(ImagesVector, "33.jpg");

ReadPhotos("paths4.txt");
MakePanorama(ImagesVector, "44.jpg");


system("pause");
waitKey(0);
return 0;
}

And here is weird thing. When I call ReadPhotos() and MakePanorama() only once in one single run of program it stitches 2 images in 3 seconds, 3 images in 8 seconds and 4 images in 16 seconds.

When I call ReadPhotos() and MakePanorama() 3 times with 2, 3 and 4 photos to stitch in single run of program it takes 3 seconds, 30 seconds and 130 seconds.

So I can see that reruning program gives a lot better times. Why is that? Im cleaning ImageVector. What else should I do?

Thanks for help:)

2015-06-28 10:58:58 -0600 received badge  Enthusiast
2015-06-26 09:05:49 -0600 asked a question Parameters of OpenCV ImageStitching. Trying to understand them.

I make GUI program to stitch images and create panoramas. I try to understand all parameters given by OpenCV stitching module but I can't find information about all of them.

I have problem with this:

  1. setRegistrationResol
  2. setSeamEstimationResol
  3. setPanoConfidenceThresh

From BundleAdjustment function:

  1. BundleAdjusterRay
  2. BundleAdjusterReproj

And from Features Matcher:

  1. num_matches_thresh1
  2. num_matches_thresh2

From first group, by changing values, I see on output image that parameters change quality of output image. But I can't find any accurate information about this parameters.

From second BundleAdjustment group. I see that it has something with camera parameters but like previous one, no specific information.

Third group about Features Matcher. I have problem with understand this 2 parameters.

For all people who would like to send me link to OpenCV documentation. I know with some of this parameters there is some information. But mainly it's just 1 sentence or no information. I would like to find some more information about it. Is there any book/site I should visit?

Thanks for any help :)

2015-05-15 06:26:26 -0600 commented question Function works in OpenCV 2.4.11, not working in 3.0.

Stitcher stitcher = Stitcher::createDefault(true); Ptr<warpercreator> warper(new SphericalWarper()); stitcher.setWarper(warper);

2015-05-14 11:19:56 -0600 asked a question Function works in OpenCV 2.4.11, not working in 3.0.

Hello,

I'm using stitcher class. I have working project in QT using openCV 3.0 and working project in Visual Studio using OpenCV 2.4.11.

Code is the same and as I can see stitcher class looks the same in 3.0 and 2.4.11.

In Visual Studio I use:

Stitcher stitcher = Stitcher::createDefault(true);
stitcher.setWarper(new SphericalWarper());

In QT I use the same and I get error:

 no matching function for call to 'cv::Stitcher::setWarper(cv::SphericalWarper*)'
 stitcher.setWarper(new SphericalWarper());

When I try to stitch images in QT without setting any parameters it's working.

As I can see here OpenCV Docs it should be working. Anyone has any idea why it's not working?

Thanks for any help.

2015-04-30 11:18:53 -0600 asked a question Stitching works only when images given in correct order.

Hello,

I have a weird problem. I try to make panorama using stitching class. I use for this 12 photos. Code is very simple. I load images into ImagesVector and then stitch them.

ReadPhotos();

for (int i = 0; i < photo_number; i++){
    ImagesVector.push_back(photos[i]);
}

Stitcher stitcher = Stitcher::createDefault(true);
stitcher.stitch(ImagesVector, image);

imwrite("panorama.jpg", image);

waitKey(0);
return 0;

I made 12 photos from one point. One photo covers 50% of previous one. When I load images to vector in order from 1 to 12 it stitches only few images, so my output panorama is not full 360 degrees. I found out that when I change order and load images to vector diffrenetly it's working. So first I load images from 4 to 12, and then I load 1 to 3 and this order gives me 360 degrees panorama.

Have anyone any idea why order in vector has matter? I thought that this class compares all single images to other images, so order should not have any influence.

I have another small question. There are stitching and stitching_detailed class. What are differences?