First time here? Check out the FAQ!
There's an native function for this.
#import <opencv2/imgcodecs/ios.h> // t and m are UIImage* instances. // transparentImage and maskImage are destination Mat. // true/false is alpha condition. UIImageToMat(t, transparentImage, true); UIImageToMat(m, maskImage, true);