I'm trying to change the perspective of a fake glasses image with OpenCV, but the transparent parts and opacity get lost. Resulting image has no transparencies. I want to change the perspective in order to stamp the resulting image over another image.
Can I do this with OpenCV?
#!/usr/bin/python
import numpy as np
import cv2
glasses = cv2.imread('fake_glasses.png')
RES_SIZE = (500,640)
pts1 = np.float32([[ 0, 0], [599, 0],
[ 0,208], [599,208]])
pts2 = np.float32([[ 94,231], [354,181],
[115,316], [375,281]])
M = cv2.getPerspectiveTransform(pts1,pts2)
rotated = cv2.warpPerspective(glasses, M, RES_SIZE)
cv2.imwrite("rotated_glasses.png", rotated)