Ask Your Question

Revision history [back]

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