All Projects → safwankdb → petyr

safwankdb / petyr

Licence: other
Affine Tranformation and Homography library for Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to petyr

Torchsample
High-Level Training, Data Augmentation, and Utilities for Pytorch
Stars: ✭ 1,731 (+10718.75%)
Mutual labels:  affine
GeoArrays.jl
Simple geographical raster interaction built on top of ArchGDAL, GDAL and CoordinateTransformations
Stars: ✭ 42 (+162.5%)
Mutual labels:  affine
Computer-Vision
Cool Vision projects
Stars: ✭ 51 (+218.75%)
Mutual labels:  homography
multi-h
The C++ implementation of Multi-H algorithm, which is a multi-plane fitting technique. If you use this work for Academic purposes, please cite Barath, D. and Matas, J. and Hajder, L., Multi-H: Efficient Recovery of Tangent Planes in Stereo Images. 27th British Machine Vision Conference, 2016
Stars: ✭ 29 (+81.25%)
Mutual labels:  homography
multi-camera-pig-tracking
Official Implementation of "Tracking Grow-Finish Pigs Across Large Pens Using Multiple Cameras"
Stars: ✭ 25 (+56.25%)
Mutual labels:  homography
avp-bev-open
A pkg stiching around view images(4-6cameras) to generate bird's eye view.
Stars: ✭ 34 (+112.5%)
Mutual labels:  homography
Homography-Based-MOTDT
MOTDT with Homography Matrix for Multi-Object Tracking
Stars: ✭ 21 (+31.25%)
Mutual labels:  homography
homog2d
C++ 2D geometry library, handles points, lines, polylines, planar transformations (and other primitives), using homogeneous coordinates. Provided with complete manual and samples.
Stars: ✭ 70 (+337.5%)
Mutual labels:  homography
MTF
Modular Tracking Framework
Stars: ✭ 99 (+518.75%)
Mutual labels:  homography

petyr

Build Status codecov PyPI Downloads Downloads

Affine, Similarity Transformations and Homography for Python. Fast and chainable inplace operations. Produced matrix can be used with cv2.warpAffine and cv2.warpPerspective.

Installation

For stable release

pip3 install petyr

Or, build from source

pip3 install git+https://github.com/safwankdb/petyr

Usage

from petyr import Similarity, Affine, Homography

Affine, Similarity and Homography derive from the Transform2D base class which implements all the basic operations.

Applying Transformation

p = np.array([[0,0],[1,0],[1,1],[0,1]])

rotate_and_move = Affine().rotate(90).translate(2,1)
q = rotate_and_move * p

pt = Homography.from_elements([1,0,0,0,1,0,0.1,0.2,1])
r = pt * p

Finding Transformation

at = Affine.from_points(p, q)
pt = Homography.from_points(p, q)
st = Similarity.from_points(p, q)

Basic Operations

These operations modify the object in-place except for invert() which return a new object.

  • Translation
  • Scaling
  • Shearing
  • Rotation
  • Inversion
  • Reset
at = Affine()
at.translate(1, 3)
at.scale(1.05, 2)
at.rotate(45, degrees=True)
at.shear(10, 45)
at_inv = at.invert()

Same goes for Homography and Transform2D objects.

Chaining

Chaining Operations

Mutiple operations can be chained together.

at = Affine()
at.scale(2,2).rotate(90)
at.shear(10, 0).translate(-3, 4)

Chaining Transforms

Multiple transforms can be multiplied together. This is a non-commutative operation. The rightmost transform will be applied first.

a = Affine()
a.translate(2,3)
b = Homography()
b.scale(4,5)
c = a * b

Testing

To run the inbuilt unit tests,

git clone https://github.com/safwankdb/petyr
cd petyr
python3 -m unittest -v

Maintainers

TODO

  • Add Rigid transformations.
  • Implement petyr.Homography.
  • Add unit tests.
  • Vectorize from_points.
  • Add unit tests for Affine and Homography classes as well.
  • Add Similarity class for similarity transforms.
  • Update all tests for similarity transform
  • Update README with Similarity Transform
  • Generate complete documentation.
  • Move documentation to somwhere other than README.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].