Ask Your Question
0

Convert image to cylindrical shape.

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

Ankit C gravatar image

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

Hi,

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
2

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

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

Stats

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

Seen: 322 times

Last updated: Apr 08 '16