[英]Why the use of cvLoadImage of OpenCV always return NULL on IOS?
我写了一些代码在iPad上运行,我使用cvLoadImage()从Bundle Resources
读取图像,但它总是返回NULL
,我不知道为什么?
You can't load an image from your app bundle directly into OpenCV … Getting a proper cv::Mat involves two steps: 您无法将应用程序包中的图像直接加载到OpenCV中...获取正确的cv :: Mat涉及两个步骤:
1.) Load your image using UIImage 1.)使用UIImage加载图像
2.) Convert the UIImage to a cv::Mat 2.)将UIImage转换为cv :: Mat
Which looks like this: 看起来像这样:
cv::Mat img = [UIImageCVMatConverter cvMatFromUIImage:[UIImage imageNamed:@"my_image.png"]];
Grab the UIImageCVMatConverter class from this thread: OpenCV install in xcode 从这个线程中获取UIImageCVMatConverter类: 在xcode中安装OpenCV
Hope that helps! 希望有所帮助!
use directly 直接使用
[UIImage imageWithNamed:@"photo.png"];
if the image is in Bundle you can use directly. 如果图像在Bundle中,您可以直接使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.