Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between different warp methods in OpenCV

Tags:

c++

opencv

By using OpenCV to stitch an image, I found out that there are several warp methods provided to perform this operation:

if (warp_type == "plane") warper_creator = new cv::PlaneWarper();
else if (warp_type == "cylindrical") warper_creator = new cv::CylindricalWarper();
else if (warp_type == "spherical") warper_creator = new cv::SphericalWarper();
else if (warp_type == "fisheye") warper_creator = new cv::FisheyeWarper();
else if (warp_type == "stereographic") warper_creator = new cv::StereographicWarper();
else if (warp_type == "compressedPlaneA2B1") warper_creator = new cv::CompressedRectilinearWarper(2, 1);
else if (warp_type == "compressedPlaneA1.5B1") warper_creator = new cv::CompressedRectilinearWarper(1.5, 1);
else if (warp_type == "compressedPlanePortraitA2B1") warper_creator = new cv::CompressedRectilinearPortraitWarper(2, 1);
else if (warp_type == "compressedPlanePortraitA1.5B1") warper_creator = new cv::CompressedRectilinearPortraitWarper(1.5, 1);
else if (warp_type == "paniniA2B1") warper_creator = new cv::PaniniWarper(2, 1);
else if (warp_type == "paniniA1.5B1") warper_creator = new cv::PaniniWarper(1.5, 1);
else if (warp_type == "paniniPortraitA2B1") warper_creator = new cv::PaniniPortraitWarper(2, 1);
else if (warp_type == "paniniPortraitA1.5B1") warper_creator = new cv::PaniniPortraitWarper(1.5, 1);
else if (warp_type == "mercator") warper_creator = new cv::MercatorWarper();
else if (warp_type == "transverseMercator") warper_creator = new cv::TransverseMercatorWarper();

The code above is taken from the stitching_detailed.cpp project in the official OpenCV samples.

I tried all of them to stitch a set of nine images: they produce slightly different outputs (about distortion or perspective) with also different processing time.

Please, could someone explain me in detail these differences?

like image 880
Iching Chang Avatar asked Aug 12 '14 12:08

Iching Chang


People also ask

What is warp perspective in OpenCV?

OpenCV program in python to demonstrate warpPerspective() function to read the given image and align the given image and then fit the size of the aligned image to the size of the original image using warpPerspective() function: #importing the module cv2 and numpy.

How do you warp one triangle to another triangle?

We now know that to warp a triangle to another triangle we will need to use the affine transform. In OpenCV, warpAffine allows you to apply an affine transform to an image, but not a triangular region inside the image.


1 Answers

Imagine placing stickers on some object. Your source images are the stickers, and the warping methods denote what object and how are you going to cover. In case of PlaneWarper it is obviously a plane. For CylindricalWarper and SphericalWarper it is cylinder and sphere, respectively. Other warpers handle other common projections, like Mercator and stereographic. If you don't know what they are - it's a good sign that you don't need to use them. http://en.wikipedia.org/wiki/Map_projection has a pretty decent amount of information to get you started.

The main differences between these warpers are the mathematical formulas that are used to map source image pixels onto the resulting panorama. Depending on your task, you should choose appropriate warper. If you are stitching a panorama you should probably use CylindricalWarper or SphericalWarper. Consider http://www.panoguide.com/howto/panoramas/types.jsp for more details.

like image 75
alexisrozhkov Avatar answered Oct 08 '22 00:10

alexisrozhkov