I have the following code running in iOS, using for convert UIImage To MAT. After that,
rotate the image by OpenCV and convert it back to UIImage. But after use in iOS 17,
this code is bug (return nil image from function MatToUIImage)
Here is my code:
cv::Mat src;
UIImageToMat(image, src);
cv::Mat rotation;
switch (flip) {
case VERTICAL:
cv::flip(src, rotation, 0);
break;
case HORIZONTAL:
cv::flip(src, rotation, 1);
break;
case RIGHT:
cv::flip(src.t(), rotation, 0);
break;
case LEFT:
cv::flip(src.t(), rotation, 0);
break;
case INVERTED:
cv::flip(src, rotation, -1);
break;
default:
break;
}
src.release();
image = MatToUIImage(rotation);
rotation.release();
return image;
This happens when using previously converted images from MAT.
Example: UIImage to Mat β Mat to UIImage β Use this UIImage to another function β UIImage to Mat β Rotate MAT β Mat to UIImage β BUG
If use UIImage to MAT β Rotate MAT β Mat to UIImage β Work normally
Before that, in iOS 16 lower. Everything working normally, just happen in iOS 17.
Has anyone encountered this situation? Please give me some opinion. Thanks