WORKS! with mask
This commit is contained in:
parent
cd31d07827
commit
370e76aaaa
|
@ -2,6 +2,12 @@ import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
def combine_images (bg, fg, mask) :
|
||||||
|
fk = cv2.bitwise_or(fg, fg, mask=mask)
|
||||||
|
mask = cv2.bitwise_not(mask)
|
||||||
|
bk = cv2.bitwise_or(bg, bg, mask=mask)
|
||||||
|
return cv2.bitwise_or(fk, bk)
|
||||||
|
|
||||||
username = os.getlogin()
|
username = os.getlogin()
|
||||||
|
|
||||||
#outer template
|
#outer template
|
||||||
|
@ -27,6 +33,12 @@ M = cv2.getAffineTransform(pts2, pts1)
|
||||||
# apply
|
# apply
|
||||||
dst = cv2.warpAffine(inner, M, (cols, rows), borderMode=cv2.BORDER_TRANSPARENT)
|
dst = cv2.warpAffine(inner, M, (cols, rows), borderMode=cv2.BORDER_TRANSPARENT)
|
||||||
|
|
||||||
final = outer.copy()
|
lower = np.array([0,0,0])
|
||||||
final[0:rows, 0:cols] = dst
|
upper= np.array([0,0,0])
|
||||||
cv2.imwrite("affine_poc2-dst.png", dst)
|
|
||||||
|
# Create a mask. Threshold the HSV image to get only yellow colors
|
||||||
|
mask = cv2.inRange(dst, lower, upper)
|
||||||
|
mask = cv2.bitwise_not(mask)
|
||||||
|
|
||||||
|
final = combine_images(outer, dst, mask)
|
||||||
|
cv2.imwrite("affine_poc3.png", final)
|
Loading…
Reference in New Issue