I usually convert over the original image with no problem. You can create another destination mat image if you wish to preserve the original one. So it's based on case to case basis.
Would rather comment than reply, but my answer would be too long.
Try this methods:
1) High chance is due to you not declaring the channel. For instance CV_8U3
, etc..
2) If step one doesn't work, the other high possibility: Try using CV_BGR2RGB
instead of cv::COLOR_BGR2RGB
(Version compatibility problem)
3) Have you tried removing the pointer? &
If the three methods still doesn't work, please do comment on the exact error message you are receiving on this answer. I will try help you out. Cheers.
EDIT(To answer your comments):
When I was talking about channels, I meant CV_8U3, CV_8U
, etc. You don't have to try it anymore though, cause the error is due to the IOS's aggressive kernel thread which sets all to kill all the processes on low memory. This means when background process are running, they are more likely to be "killed" to allocate memory for the current/running/foreground process.
More information about that kernel:http://newosxbook.com/articles/MemoryPressure.html
I am not an expertise when it comes to IOS, but things I think you can try:
1)Use global Variable, for instance, make Mat Image global rather than local
2)A slightly bad programming convention to some: skip the function and just dump the code from the function to the main/or program which was trying to call the function. This ensures that the IOS doesn't need to switch process, hence killing either of them.
3) Define app profile(UIBackgroundMode) in kernel, thereby taming Jetsam, the aggressive kernel killer a little.
4) release images from RAM (remove the reference to them) when there is no more need to the images