diff --git a/fourcell/notes/affine_error.txt b/fourcell/notes/affine_error.txt new file mode 100644 index 0000000..f0f4a1e --- /dev/null +++ b/fourcell/notes/affine_error.txt @@ -0,0 +1,16 @@ +PLATFORM: Mac +PYTHON: Python 3.10.8 +OPENCV: 4.7.0 + +affine_poc.py works + +affine_poc2.py does not work + > background appears black + > happens with multiple jpegs + + +PLATFORM: Linux +PYTHON: Python 3.10.6 +OPENCV: 4.5.4 + +Produces the same images \ No newline at end of file diff --git a/fourcell/notes/affine_poc2.py b/fourcell/notes/affine_poc2.py index ad293c1..3ab29b9 100644 --- a/fourcell/notes/affine_poc2.py +++ b/fourcell/notes/affine_poc2.py @@ -1,11 +1,13 @@ import cv2 import numpy as np +import os + +username = os.getlogin() #outer template -outer = cv2.imread("../../../../Desktop/running/shot1-scans/image-2-normal.png") +outer = cv2.imread(f"/home/{username}/Desktop/running/shot1-scans/image-2-normal.png") #inner image - -inner = cv2.imread("../../../../Desktop/frame.jpg") +inner = cv2.imread(f"/home/{username}/Desktop/frame.jpg") rows, cols, ch = outer.shape ir, ic, ich = inner.shape @@ -27,4 +29,5 @@ 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 diff --git a/fourcell/notes/affine_poc3.py b/fourcell/notes/affine_poc3.py new file mode 100644 index 0000000..e790ed2 --- /dev/null +++ b/fourcell/notes/affine_poc3.py @@ -0,0 +1,32 @@ +import cv2 +import numpy as np +import os + +username = os.getlogin() + +#outer template +outer = cv2.imread(f"/home/{username}/Desktop/running/shot1-scans/image-2-normal.png") +#inner image +inner = cv2.imread(f"/home/{username}/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-dst.png", dst) \ No newline at end of file