petyr
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
Maitainers
TODO
- Implement
petyr.Homography. - Add unit tests.
- Vectorize
from_points. - Add unit tests for
AffineandHomographyclasses as well. - Add
Similarityclass for similarity transforms. - Update all tests for similarity transform
- Update README with Similarity Transform
- Generate complete documentation.
- Move documentation to somwhere other than README.
Metadata
Release files for petyr 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| petyr-0.0.8.tar.gz | 5.6 kB | Without provenance | Details for petyr-0.0.8.tar.gz |
Release files / petyr-0.0.8.tar.gz
| Download URL | petyr-0.0.8.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16e0ff30ad94303d9f868cc4d6bc3d4829dbf2c7a1af796f7e520077d14b9fcf
|
|
BLAKE2b-256 checksum How to use checksums |
72e8bbec4b6eaca0b33a7d3a03666f24781460e629ba0c6180bd4b6cf62d7f63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9
|
Security for petyr 0.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.