mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Mypy fix rotation.py (#4319)
* fix type-hints arguments
* fix matrices & image-path
* Update build.yml
* Revert "Update build.yml"
This reverts commit c2d04aef65
.
* use pathlib
* feat: Add mypy configuration file (#4315)
* feat: Add mypy config file
* refactor: Remove mypy options from build workflow
* Remove linear_algebra
Co-authored-by: Christian Clauss <cclauss@me.com>
* rebase & update mypy.ini
* fix pre-commit errors
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
parent
c49fa088a0
commit
531d2d6d7e
|
@ -1,11 +1,13 @@
|
|||
from pathlib import Path
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
|
||||
def get_rotation(
|
||||
img: np.array, pt1: np.float32, pt2: np.float32, rows: int, cols: int
|
||||
) -> np.array:
|
||||
img: np.ndarray, pt1: np.ndarray, pt2: np.ndarray, rows: int, cols: int
|
||||
) -> np.ndarray:
|
||||
"""
|
||||
Get image rotation
|
||||
:param img: np.array
|
||||
|
@ -21,17 +23,19 @@ def get_rotation(
|
|||
|
||||
if __name__ == "__main__":
|
||||
# read original image
|
||||
image = cv2.imread("lena.jpg")
|
||||
image = cv2.imread(
|
||||
str(Path(__file__).resolve().parent.parent / "image_data" / "lena.jpg")
|
||||
)
|
||||
# turn image in gray scale value
|
||||
gray_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||
# get image shape
|
||||
img_rows, img_cols = gray_img.shape
|
||||
|
||||
# set different points to rotate image
|
||||
pts1 = np.float32([[50, 50], [200, 50], [50, 200]])
|
||||
pts2 = np.float32([[10, 100], [200, 50], [100, 250]])
|
||||
pts3 = np.float32([[50, 50], [150, 50], [120, 200]])
|
||||
pts4 = np.float32([[10, 100], [80, 50], [180, 250]])
|
||||
pts1 = np.array([[50, 50], [200, 50], [50, 200]], np.float32)
|
||||
pts2 = np.array([[10, 100], [200, 50], [100, 250]], np.float32)
|
||||
pts3 = np.array([[50, 50], [150, 50], [120, 200]], np.float32)
|
||||
pts4 = np.array([[10, 100], [80, 50], [180, 250]], np.float32)
|
||||
|
||||
# add all rotated images in a list
|
||||
images = [
|
||||
|
|
2
mypy.ini
2
mypy.ini
|
@ -2,4 +2,4 @@
|
|||
ignore_missing_imports = True
|
||||
|
||||
; FIXME: #4052 fix mypy errors in the exclude directories and remove them below
|
||||
exclude = (data_structures|digital_image_processing|dynamic_programming|graphs|maths|matrix|other|project_euler|scripts|searches|strings*)/$
|
||||
exclude = (data_structures|dynamic_programming|graphs|maths|matrix|other|project_euler|scripts|searches|strings*)/$
|
||||
|
|
Loading…
Reference in New Issue
Block a user