Skip to content

Providing padded versions of OpenCV's warpAffine and warpPerspective in C++

License

Notifications You must be signed in to change notification settings

alkasm/padded-transformations-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

padded-transformations

Providing a padded version of OpenCV's warpAffine() and warpPerspective() functions.

Example image

A completed Python implementation is also available here.

functions

Read my Stack Overflow answer which inspired this repository.

When OpenCV warps an image, any pixels that get warped outside of the bounds of dsize are excluded from the resulting warped image. While giving a larger dsize can help retain pixels that get mapped to larger pixel locations, you cannot recover the pixel values that get mapped to negative pixel locations.

The solution requires three steps:

  1. Calculate the warped pixel locations manually
  2. Add translation to the transformation by however much is necessary in pixels to send all pixels values to positive numbers
  3. Pad the destination image to account for the shift and add padding to the edge of the warp

Both warpAffinePadded() and warpPerspectivePadded() complete this task using minimal overhead and no user input aside from the same information that would be needed for OpenCV's warpAffine() and warpPerspective().

contribute

Please feel free to submit any suggestions you have or bugs you find via a GitHub issue.

test dataset

The images and ground truth homographies provided in test/ are from Oxford's Visual Geometry Group.

About

Providing padded versions of OpenCV's warpAffine and warpPerspective in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published