Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing cvMat Objects in an Array - OpenCV - iPhone

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.

like image 297
GuybrushThreepwood Avatar asked May 06 '12 15:05

GuybrushThreepwood


1 Answers

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];
like image 54
SentineL Avatar answered Sep 26 '22 14:09

SentineL