Ask Your Question

Convert image to cylindrical shape.

asked 2016-04-08 01:20:12 -0500

Ankit C gravatar image

updated 2016-04-08 01:31:54 -0500


I will try to convert my image to cylindrical shape,I am using objective c,

Here I am using below code, but getting same image without curved,

 cv::Mat cylindricalimg (Mat img)
   //with img object i got the original image
   cv::Mat dst;
   cv::Mat 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(img, k, r, INTER_LINEAR, BORDER_REFLECT, dst);
   warper->warpBackward(dst, k, r, INTER_LINEAR, BORDER_REFLECT, img.size(),dstback);

   return dstback;

Please let me know where I have done mistake?

Thanks, In advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-04-08 02:22:58 -0500

You have to return the dst image, not the dstback image, which is the image unwrapped (ie back to normal). In you case you don't have to use warpBackward in your function. Use the code from your previous question provided by @LBerger to display the all the images.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-04-08 01:20:12 -0500

Seen: 143 times

Last updated: Apr 08 '16