Commit 15173fc5 authored by Alexey Spizhevoy's avatar Alexey Spizhevoy

added wave correct support into opencv_stitching

parent 3928dd9d
......@@ -11,16 +11,20 @@ using namespace cv;
void printUsage()
{
cout << "Rotation model images stitcher.\n"
<< "Usage: opencv_stitching img1 img2 [...imgN]\n"
<< "\t[--matchconf <0.0-1.0>]\n"
cout << "Rotation model images stitcher.\n\n";
cout << "Usage: opencv_stitching img1 img2 [...imgN]\n"
<< "\t[--matchconf <float>]\n"
<< "\t[--ba (ray|focal_ray)]\n"
<< "\t[--ba_thresh <float>]\n"
//<< "\t[--wavecorrect (no|yes)]\n"
<< "\t[--wavecorrect (no|yes)]\n"
<< "\t[--warp (plane|cylindrical|spherical)]\n"
<< "\t[--seam (no|voronoi|graphcut)]\n"
<< "\t[--blend (no|feather|multiband)]\n"
<< "\t[--output <result_img>]\n";
<< "\t[--output <result_img>]\n\n";
cout << "--matchconf\n"
<< "\tGood values are in [0.2, 0.8] range usually.\n\n";
cout << "--ba_thresh\n"
<< "\tGood values are in [0.3, 1.0] range usually.\n";
}
int main(int argc, char* argv[])
......@@ -29,7 +33,7 @@ int main(int argc, char* argv[])
vector<Mat> images;
string result_name = "result.png";
int ba_space = BundleAdjuster::RAY_SPACE;
int ba_space = BundleAdjuster::FOCAL_RAY_SPACE;
float ba_thresh = 1.f;
bool wave_correct = false;
int warp_type = Warper::SPHERICAL;
......@@ -75,19 +79,19 @@ int main(int argc, char* argv[])
ba_thresh = static_cast<float>(atof(argv[i + 1]));
i++;
}
//else if (string(argv[i]) == "--wavecorrect")
//{
// if (string(argv[i + 1]) == "no")
// wave_correct = false;
// else if (string(argv[i + 1]) == "yes")
// wave_correct = true;
// else
// {
// cout << "Bad wave correct flag value\n";
// return -1;
// }
// i++;
//}
else if (string(argv[i]) == "--wavecorrect")
{
if (string(argv[i + 1]) == "no")
wave_correct = false;
else if (string(argv[i + 1]) == "yes")
wave_correct = true;
else
{
cout << "Bad wave correct flag value\n";
return -1;
}
i++;
}
else if (string(argv[i]) == "--warp")
{
if (string(argv[i + 1]) == "plane")
......
......@@ -685,7 +685,6 @@ void BundleAdjuster::calcJacobian()
//////////////////////////////////////////////////////////////////////////////
// TODO test on adobe/halfdome
void waveCorrect(vector<Mat> &rmats)
{
float data[9];
......@@ -710,10 +709,13 @@ void waveCorrect(vector<Mat> &rmats)
Mat avgz = Mat::zeros(3, 1, CV_32F);
for (size_t i = 0; i < rmats.size(); ++i)
avgz += rmats[i].col(2);
avgz.t().cross(r1).copyTo(r0);
r1.cross(avgz.t()).copyTo(r0);
normalize(r0, r0);
r0.cross(r1).copyTo(r2);
r1.cross(r0).copyTo(r2);
if (determinant(R) < 0)
R *= -1;
for (size_t i = 0; i < rmats.size(); ++i)
rmats[i] = R * rmats[i];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment