From 1f572295f6676f2838c767b9355592354a3f2867 Mon Sep 17 00:00:00 2001 From: mmattmcw Date: Fri, 10 Feb 2023 15:36:51 -0500 Subject: [PATCH] Trying a contrived version of the affine_poc that demonstrates the issue --- fourcell/notes/affine_poc2.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 fourcell/notes/affine_poc2.py diff --git a/fourcell/notes/affine_poc2.py b/fourcell/notes/affine_poc2.py new file mode 100644 index 0000000..faa2afd --- /dev/null +++ b/fourcell/notes/affine_poc2.py @@ -0,0 +1,29 @@ +import cv2 +import numpy as np + +#outer template +outer = cv2.imread("../../../../Desktop/running/shot1-scans/image-2-normal.png") +#inner image +inner = cv2.imread("../../../../Desktop/frame.jpg") + +rows, cols, ch = outer.shape +ir, ic, ich = inner.shape + +print(f'{cols}x{rows}') +print(f'{ic}x{ir}') + +# destination ponts on outer image +pts1 = np.float32([[1445, 11429], [1445, 6832], [5009, 11429]]) + +# corresponding points on inner image +pts2 = np.float32([[0, 0], [ic, 0], [0, ir]]) + +# transform inner to points on outer +M = cv2.getAffineTransform(pts2, pts1) + +# apply +dst = cv2.warpAffine(inner, M, (cols, rows), borderMode=cv2.BORDER_TRANSPARENT) + +final = outer.copy() +final[0:rows, 0:cols] = dst +cv2.imwrite("affine_poc2.png", final) \ No newline at end of file