Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Provide shape like cylindrical image to UIImage with OpenCV?

Hello,

I want to give shape like cyndrical image to my UIImage. I am using objective c and opencv library.

With stitcher class we are able to provide shape for the images with below code,

 cv::Mat stitch (vector<Mat>& images)
 {
   imgs = images;
   Mat pano;
   Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
   Stitcher.setWarper( new cv::CylindricalWarper);

   Stitcher::Status status = stitcher.stitch(imgs, pano);

    if (status != Stitcher::OK)
    {
    cout << "Can't stitch images, error code = " << int(status) << endl;
        //return 0;
    }
    return pano;
 }

sticher works with more than one image. It's not work with one image.

opencv provide cylindrical method link, But how we can use this method for warping Image? If any one provide some source or code or give some idea, How i can use this, It's help me a lot.

Thank in advance.

Provide shape like cylindrical image to UIImage with OpenCV?

Hello,

I want to give shape like cyndrical image to my UIImage. I am using objective c and opencv library.

With stitcher class we are able to provide shape for the images with below code,

 cv::Mat stitch (vector<Mat>& images)
 {
   imgs = images;
   Mat pano;
   Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
   Stitcher.setWarper( new cv::CylindricalWarper);

   Stitcher::Status status = stitcher.stitch(imgs, pano);

    if (status != Stitcher::OK)
    {
    cout << "Can't stitch images, error code = " << int(status) << endl;
        //return 0;
    }
    return pano;
 }

sticher works with more than one image. It's not work with one image.

opencv provide cylindrical method link, But how we can use this method for warping Image? If any one provide some source or code or give some idea, How i can use this, It's help me a lot.

Thank in advance.

As per the @LBerger Answer, Here i have updated code,

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

 cv::Mat cylindricalimg (Mat img)
 {
   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?

Provide shape like cylindrical image to UIImage with OpenCV?

Hello,

I want to give shape like cyndrical image to my UIImage. I am using objective c and opencv library.

With stitcher class we are able to provide shape for the images with below code,

 cv::Mat stitch (vector<Mat>& images)
 {
   imgs = images;
   Mat pano;
   Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
   Stitcher.setWarper( new cv::CylindricalWarper);

   Stitcher::Status status = stitcher.stitch(imgs, pano);

    if (status != Stitcher::OK)
    {
    cout << "Can't stitch images, error code = " << int(status) << endl;
        //return 0;
    }
    return pano;
 }

sticher works with more than one image. It's not work with one image.

opencv provide cylindrical method link, But how we can use this method for warping Image? If any one provide some source or code or give some idea, How i can use this, It's help me a lot.

Thank in advance.

As per the @LBerger Answer, Here i have updated code,

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?