I have two images as shown above taken from two cameras. How do I stitch these two images together?
I have already tried to use stitch
fucntion in opencv, but it can`t work correctly,meanwhile I searched many code about this question,none of it is useful,Is it impossible to solve this problem?
can I use Homography
to detect the angle of image?
here is some matrices
rotate
[[-3.97172305e-03 1.00056894e+00 3.46248616e+02]
[-1.00148205e+00 3.86723139e-04 5.52950036e+02]
[-6.76659141e-06 2.59126405e-06 1.00000000e+00]]
no rotate and no scale
[[1.00280729e+00 1.05580875e-03 3.45778070e+02]
[4.85699357e-04 1.00302391e+00 3.19346158e+01]
[3.37627987e-06 1.84587364e-06 1.00000000e+00]]
rotate a little
[[ 8.58991949e-01 -2.28707257e-01 5.99451739e+02]
[ 1.68801416e-01 9.90307162e-01 -1.35877403e+02]
[-1.25664777e-04 4.38606347e-05 1.00000000e+00]]
Show us your code
Tutorial about stitching is here
Mat img1 = imread("left-4.jpg");
Mat img2 = imread("right-4-2.jpg");
if (img1.empty() || img2.empty())
{
cout << "Can't read image" << endl;
return -1;
}
imgs.push_back(img1);
imgs.push_back(img2);
time_t seconds1;
seconds1 = time(NULL);
Ptr<Stitcher> stitcher = Stitcher::create(Stitcher::PANORAMA);
stitcher->setFeaturesMatcher(makePtr<detail::BestOf2NearestMatcher>(false, 0.3f));
Mat pano;
try
{
Stitcher::Status status = stitcher->stitch(imgs, pano);
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << int(status) << endl;
return -1;
}
}
catch (const std::exception& ex)
{
cout << "Can't stitch images, error code = " << ex.what()<< endl;
}
Mat img1 = imread("left-4.jpg");
Mat img2 = imread("right-4-2.jpg");
if (img1.empty() || img2.empty())
{
cout << "Can't read image" << endl;
return -1;
}
imgs.push_back(img1);
imgs.push_back(img2);
time_t seconds1;
seconds1 = time(NULL);
Ptr<Stitcher> stitcher = Stitcher::create(Stitcher::PANORAMA);
stitcher->setFeaturesMatcher(makePtr<detail::BestOf2NearestMatcher>(false, 0.3f));
Mat pano;
try
{
Stitcher::Status status = stitcher->stitch(imgs, pano);
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << int(status) << endl;
return -1;
}
}
catch (const std::exception& ex)
{
cout << "Can't stitch images, error code = " << ex.what()<< endl;
}
You can use stitching_detailed.py code given in tutorial High level stitching API Stitcher class
I have tried to use --d3
argument,but still get bad picture.