I am trying to create a warped image where the border padding pixels are transparent. I know I can use the BORDER_CONSTANT = BORDER_TRANSPARENT. But this works by:
In addition, it provides the method BORDER_TRANSPARENT . This means that the corresponding pixels in the destination image will not be modified at all. openCV manual
So to make border pixels transparent, do I need to start with a transparent image. Like this example:
int cols; // filled
int rows; // filled
Mat myImage; // filled
Mat warpMatrix (3, 4, CV_32FC1); // filled
Mat myWarpedImage;
myWarpedImage.create((cols, rows, CV_8UC4, Scalar(0,0,0,0)); // set all pixels to black, alpha = 0
warpPerspective(myImage, myWarpedImage, warpMatrix, Size(cols, rows), WARP_INVERSE_MAP, BORDER_TRANSPARENT);
This doesn't seem to work. My warped image still has black background with no transparency (when I check it some photo editing software like GIMP).