if the image is UIImage we can view the image in the debug mode in xcode, but I can't for cv::mat images and it's normal, so is there anyway or any add-on tool we can add to xcode to show (or view) the image in the debug mode for cv::mat image?
Asked
Active
Viewed 1,631 times
5
-
Did you ever find a solution to this? cheers – Caspar Wylie Sep 18 '16 at 14:43
3 Answers
1
If you can use CLion instead Xcode you can utilize the OpenCV Image Viewer plugin, which displays matrices while debugging just on click.
https://plugins.jetbrains.com/plugin/14371-opencv-image-viewer
Disclaimer: I'm an author of this plugin

dragon7
- 1,057
- 9
- 23
0
You should create an ios project which installs opencv2.framework in it, and drag your cpp code to that project, make an new entry to run then you should be able to use the above convert code to view a mat as UIImage...
-
Welcome to StackOverflow! I would recommend you to write properly formatted sentences with no proper grammatical structure. – BusyProgrammer Feb 17 '17 at 02:42
-1
I don't know if I understood your question, but if you wanna simply display a cv::Mat preview, you can convert the cv::Mat to UIImage. I can show you how to do that in Objective-C:
-(UIImage *)UIImageFromCVMat:(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);
// Creating CGImage from cv::Mat
CGImageRef imageRef = CGImageCreate(cvMat.cols, //width
cvMat.rows, //height
8, //bits per component
8 * cvMat.elemSize(), //bits per pixel
cvMat.step[0], //bytesPerRow
colorSpace, //colorspace
kCGImageAlphaNone|kCGBitmapByteOrderDefault,// bitmap info
provider, //CGDataProviderRef
NULL, //decode
false, //should interpolate
kCGRenderingIntentDefault //intent
);
// Getting UIImage from CGImage
UIImage *finalImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
CGDataProviderRelease(provider);
CGColorSpaceRelease(colorSpace);
return finalImage;
}
If this is what you asked, there are a lot of similar question on StackOveflow:
-
-
-
Ah ok, I understood your question. You want to see the image in the debugger, using the quick look button of Xcode. – Adda_25 Nov 24 '15 at 10:50