perspektiva 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Urie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: perspektiva
3
+ Version: 1.0.0
4
+ Summary: Interactive perspective correction tool using OpenCV
5
+ Author: Urie
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Urie
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Requires-Python: >=3.11
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: opencv-python==4.7.0.72
31
+ Requires-Dist: numpy==1.26.4
32
+ Dynamic: license-file
33
+
34
+ # perspektiva
35
+
36
+ Interactive perspective correction tool using OpenCV.
37
+
38
+ ## Installation
39
+
40
+ pip install perspektiva
41
+
42
+ ## Usage
43
+
44
+ perspektiva input.jpg output.jpg
45
+
46
+ Left mouse button — add point
47
+ Right mouse button — remove last point
48
+ ESC — cancel
49
+
50
+ ## Features
51
+
52
+ - Interactive corner selection
53
+ - Automatic corner ordering
54
+ - Perspective transform
55
+ - Saves corrected image
@@ -0,0 +1,22 @@
1
+ # perspektiva
2
+
3
+ Interactive perspective correction tool using OpenCV.
4
+
5
+ ## Installation
6
+
7
+ pip install perspektiva
8
+
9
+ ## Usage
10
+
11
+ perspektiva input.jpg output.jpg
12
+
13
+ Left mouse button — add point
14
+ Right mouse button — remove last point
15
+ ESC — cancel
16
+
17
+ ## Features
18
+
19
+ - Interactive corner selection
20
+ - Automatic corner ordering
21
+ - Perspective transform
22
+ - Saves corrected image
@@ -0,0 +1 @@
1
+ __all__ = ["main"]
@@ -0,0 +1,78 @@
1
+ import cv2
2
+ import numpy as np
3
+ import sys
4
+ import os
5
+
6
+ points = []
7
+
8
+ def mouse_handler(event, x, y, flags, param):
9
+ global points, img_copy
10
+
11
+ if event == cv2.EVENT_LBUTTONDOWN:
12
+ if len(points) < 4:
13
+ points.append((x, y))
14
+ cv2.circle(img_copy, (x, y), 6, (0, 0, 255), -1)
15
+
16
+ elif event == cv2.EVENT_RBUTTONDOWN:
17
+ if points:
18
+ points.pop()
19
+ img_copy[:] = img.copy()
20
+ for px, py in points:
21
+ cv2.circle(img_copy, (px, py), 6, (0, 0, 255), -1)
22
+
23
+ def main():
24
+ if len(sys.argv) < 2:
25
+ print("Usage: perspektiva <input_image> [output_image]")
26
+ sys.exit(1)
27
+
28
+ input_path = sys.argv[1]
29
+ output_path = sys.argv[2] if len(sys.argv) > 2 else "output.jpg"
30
+
31
+ if not os.path.exists(input_path):
32
+ print(f"File not found: {input_path}")
33
+ sys.exit(1)
34
+
35
+ global img, img_copy
36
+ img = cv2.imread(input_path)
37
+ img_copy = img.copy()
38
+
39
+ cv2.namedWindow("Select 4 corners", cv2.WINDOW_NORMAL)
40
+ cv2.setMouseCallback("Select 4 corners", mouse_handler)
41
+
42
+ while True:
43
+ cv2.imshow("Select 4 corners", img_copy)
44
+ key = cv2.waitKey(20) & 0xFF
45
+
46
+ if len(points) == 4:
47
+ break
48
+ if key == 27:
49
+ print("Cancelled")
50
+ sys.exit(0)
51
+
52
+ pts = np.array(points, dtype=np.float32)
53
+ s = pts.sum(axis=1)
54
+ diff = np.diff(pts, axis=1).ravel()
55
+
56
+ ordered = np.zeros((4, 2), dtype=np.float32)
57
+ ordered[0] = pts[np.argmin(s)]
58
+ ordered[2] = pts[np.argmax(s)]
59
+ ordered[1] = pts[np.argmin(diff)]
60
+ ordered[3] = pts[np.argmax(diff)]
61
+
62
+ size = 1000
63
+ dst = np.float32([
64
+ [0, 0],
65
+ [size - 1, 0],
66
+ [size - 1, size - 1],
67
+ [0, size - 1]
68
+ ])
69
+
70
+ M = cv2.getPerspectiveTransform(ordered, dst)
71
+ warped = cv2.warpPerspective(img, M, (size, size))
72
+
73
+ cv2.imwrite(output_path, warped)
74
+ print(f"Saved: {output_path}")
75
+
76
+ cv2.imshow("Result", warped)
77
+ cv2.waitKey(0)
78
+ cv2.destroyAllWindows()
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: perspektiva
3
+ Version: 1.0.0
4
+ Summary: Interactive perspective correction tool using OpenCV
5
+ Author: Urie
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Urie
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Requires-Python: >=3.11
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: opencv-python==4.7.0.72
31
+ Requires-Dist: numpy==1.26.4
32
+ Dynamic: license-file
33
+
34
+ # perspektiva
35
+
36
+ Interactive perspective correction tool using OpenCV.
37
+
38
+ ## Installation
39
+
40
+ pip install perspektiva
41
+
42
+ ## Usage
43
+
44
+ perspektiva input.jpg output.jpg
45
+
46
+ Left mouse button — add point
47
+ Right mouse button — remove last point
48
+ ESC — cancel
49
+
50
+ ## Features
51
+
52
+ - Interactive corner selection
53
+ - Automatic corner ordering
54
+ - Perspective transform
55
+ - Saves corrected image
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ perspektiva/__init__.py
5
+ perspektiva/app.py
6
+ perspektiva.egg-info/PKG-INFO
7
+ perspektiva.egg-info/SOURCES.txt
8
+ perspektiva.egg-info/dependency_links.txt
9
+ perspektiva.egg-info/entry_points.txt
10
+ perspektiva.egg-info/requires.txt
11
+ perspektiva.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ perspektiva = perspektiva.app:main
@@ -0,0 +1,2 @@
1
+ opencv-python==4.7.0.72
2
+ numpy==1.26.4
@@ -0,0 +1 @@
1
+ perspektiva
@@ -0,0 +1,23 @@
1
+ [project]
2
+ name = "perspektiva"
3
+ version = "1.0.0"
4
+ description = "Interactive perspective correction tool using OpenCV"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = {file = "LICENSE"}
8
+
9
+ authors = [
10
+ {name = "Urie"}
11
+ ]
12
+
13
+ dependencies = [
14
+ "opencv-python==4.7.0.72",
15
+ "numpy==1.26.4",
16
+ ]
17
+
18
+ [project.scripts]
19
+ perspektiva = "perspektiva.app:main"
20
+
21
+ [build-system]
22
+ requires = ["setuptools>=61"]
23
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+