iphone - Crash when converting cv::Mat to UIImage opencv 2.4 -


i'm attempting convert uiimage cv::mat , uiimage , insert uiimage uiimageview.

this code i'm using convert:

uiimage * imagefrommat(const cv::mat& cvmat){ nsdata *data = [nsdata datawithbytes:cvmat.data length:cvmat.elemsize() * cvmat.total()];  cgcolorspaceref colorspace;  if (cvmat.elemsize() == 1) {     colorspace = cgcolorspacecreatedevicegray(); } else {     colorspace = cgcolorspacecreatedevicergb(); }  cgdataproviderref provider = cgdataprovidercreatewithcfdata((__bridge cfdataref)data);  cgimageref imageref = cgimagecreate(cvmat.cols,                                                                     cvmat.rows,                                                                      8,                                                                                8 * cvmat.elemsize(),                                                               cvmat.step[0],                                                                     colorspace,                                                                        kcgimagealphanone | kcgbitmapbyteorderdefault,                                        provider,                                                                             null,                                                                              false,                                                                              kcgrenderingintentdefault);                    uiimage *image = [[[uiimage alloc] initwithcgimage:imageref] autorelease]; cgimagerelease(imageref); cgdataproviderrelease(provider); cgcolorspacerelease(colorspace);  return image;  } 

it converts fine insert uiimageview, crash, i'm assuming problem lies there.

i've noticed if retain original image(the 1 before converting cv::mat) crash doesn't happen, leak.

any thoughts on problem be?

turns out on releasing cgimageref.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -