我试图在旋转背景后将图像叠加在背景上但是因为我在旋转后使用了图像区域来放置叠加层,而叠加层所在的角落被遗漏了
pointer = rotatePointer(pointer, point2, point1, pointerNo)
rows, cols, channels = pointer.shape
x = int(point2[0])
y = int(point2[1])
roi = background[int(y - (rows/2)):int(y + (rows / 2)), int(x - (cols/2)):int(x + (cols/2)) ]
# Create a mask of pointer as well as it's inverse'
foreGrey = cv2.cvtColor(pointer,cv2.COLOR_BGR2GRAY)
ret, mask = cv2.threshold(foreGrey, 10, 255, cv2.THRESH_BINARY_INV)
inverseMask = cv2.bitwise_not(mask)
#Black out area of pointer in roi
backgroundBlackOut = cv2.bitwise_and(roi,roi,mask = inverseMask)
#Take the pointer without alpha channel
pointerForeground = cv2.bitwise_and(pointer,pointer, mask = mask)
cv2.imshow('Mask', pointerForeground)
#Put the pointer into the ROI
dst = cv2.add(backgroundBlackOut, pointerForeground)
background[int(y - (rows/2)):int(y + (rows / 2)), int(x - (cols/2)):int(x + (cols/2)) ] = dst
return background