Ask Your Question

Aussie susan's profile - activity

2017-07-10 02:19:29 -0600 answered a question iOS OpenCV image tearing

Sorry but I've not been able to respond to my own question until about now. It turns out that the code I posted above was form a function and so the variables were placed on the stack but (I suspect) the data was in the heap. When the function exited, it destroyed the Mat variables and released the heap data. However the iOS image code (running in another thread) still retained a pointer. The bottom part of the image memory was being over-written in the heap (when it was reallocated to something else). Anyway, I've reworked the code to keep references as necessary and the problem has gone away. Susan

2017-07-04 00:13:17 -0600 asked a question iOS OpenCV image tearing

Novice user here with Xcode (developing an iOS app using the simulator at the moment) and OpenCV 3, and I'm trying to extract a section of a larger image. However when I try to display this subimage the top part is fine but the bottom part tears. image description.

The code I'm using (Objective-C++) is:

cv::Rect roiRect( imageRect.origin.x, imageRect.origin.y, imageRect.size.width, imageRect.size.height);
Mat bgrImage = [self cvMatFromUIImage:image];
Mat subImage = bgrImage( roiRect);
[self.imageView setImage:[ self UIImageFromCVMat:subImage]];

The UIImage to/from OpenCV Mat conversion functions (that appear in a number of web sites) appear to be working elsewhere. The 'imageRect' is a CGRect structure that specifies the area of interest in the main image in the OpenCV Image coordinate values.

Any ideas as to what is causing this would be appreciated.

Susan