Ask Your Question

Revision history [back]

I hope it will help you

#include "opencv2/stitching/detail/util.hpp"
#include "opencv2/stitching/detail/warpers.hpp"
#include "opencv2/stitching/warpers.hpp"

#include <iostream>
#include <fstream>
#include <algorithm>
#include <ctype.h>

using namespace cv;
using namespace std;

int main(int argc, char* argv[])
{

Mat im=imread("f:/lib/opencv/samples/data/lena.jpg",CV_LOAD_IMAGE_GRAYSCALE);
Mat dst,dstback;


Ptr<WarperCreator> warper_creator;
warper_creator = makePtr<CylindricalWarper>();
Mat k=(Mat_<float>(3,3) <<2, 0, 0,  0, 1, -0,   0,0,0.001);
Mat r=(Mat_<float>(3,3) << 1, 0, 0,    0,  1, 0,    0, 0,1);

Ptr<detail::RotationWarper> warper=warper_creator->create(static_cast<float>(1000));
warper->warp(im, k, r, INTER_LINEAR, BORDER_REFLECT, dst);
warper->warpBackward(dst, k, r, INTER_LINEAR, BORDER_REFLECT, im.size(),dstback);
imshow("src",im);
imshow("cylinder warp ",dst);
imshow("cylinder backward(warp)",dstback);
waitKey();
return 0;
}