I have a c++ opencv function that gets the gray scale of an image and stores it into an array.
+(cv::Mat) makeGray:(UIImage *) image {
// Transform UIImage to cv::Mat
cv::Mat imageMat;
UIImageToMat(image, imageMat);
//Transform image to grayscale
cv::Mat grayMat;
cv::cvtColor(imageMat, grayMat, CV_BGR2GRAY);
return grayMat;
}
Whenever I try storing this in a variable using swift
swift function:
@IBAction func convertImage(_ sender: UIButton) {
let grayMat = OpenCVWrapper.makeGray(photoImageView.image)
}
The entire program just freezes without throwing out an error.
The swift function works great when I return an UIImage:
+(UIImage *) makeGray:(UIImage *) image {
// Transform UIImage to cv::Mat
cv::Mat imageMat;
UIImageToMat(image, imageMat);
//Transform image to grayscale
cv::Mat grayMat;
cv::cvtColor(imageMat, grayMat, CV_BGR2GRAY);
return MatToUIImage(grayMat);
}
But I'm looking to return a 3darray and not an Image.