Storing cvMat Objects in an Array - OpenCV - iPhone
c++, iphone, objective-c, opencv
Solution
whatever object you need to store in NSArray, you may do it like below:
cv::Mat tempMat = [testImage CVMat];
cv::Mat *pointer = (cv::Mat *)tempMat;
id object = [NSValue valueWithPointer:pointer];
NSArray *array = [[NSArray alloc] initWithObjects: object, nil];
Problem
I am working on an OpenCV app where I create a number of cvMat objects as follows : ``` UIImage *testImage = [UIImage imageNamed:@"Image.jpg"]; cv::Mat tempMat = [testImage CVMat]; cv::cvtColor(tempMat, grayImg, cv::COLOR_RGB2GRAY); ``` What I then want to do is store the result (here called grayImg) in a NSMutableArray. Can anyone suggest how I can achieve this ? Thank you.