我正在尝试使用imreadOpenCV2.2中的函数.
我的代码非常简单.
cv::Mat host= imread("1.bmp", CV_LOAD_IMAGE_GRAYSCALE);
Run Code Online (Sandbox Code Playgroud)
之后,主机矩阵被零指针填充,即图像未加载.
如果我使用cvLoadImage那么一切正常.
该文件存在,我没有混合发布和调试库.为什么imread不起作用?
Jon*_*tez 23
用opencv 2.4.8转载.
如果您在Debug中运行,请检查您是否也在使用调试库,它解决了我们的问题.:使用版本库时,OpenCV imread(filename)在调试模式下失败.
我可以确认,在OpenCV 2.2中有一些imread问题.但问题只发生在Windows 32位系统上.在Linux和Mac上它工作.我不知道为什么它不起作用,但我们有一个小的解决方法.
我们用以下宏修复了这个问题,也许你可以尝试一下,然后使用"ourImread".
#ifdef WIN32
#define ourImread(filename, isColor) cvLoadImage(filename.c_str(), isColor)
#else
#define ourImread(filename, isColor) imread(filename, isColor)
#endif
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题
cv::Mat image= cv::imread("immagine12.jpg"); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
cv::waitKey(5000);
return -1;
}
cv::namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image );
//non so perchè ma senza il waitKey e lasciando solo il system pause non carica l'immagine...
cv::waitKey(5000);
system("pause");
Run Code Online (Sandbox Code Playgroud)
但我修好了,当我插入cv::waitKey(5000);
我不知道为什么,但system pause它无法加载图像,它加载图像后继续暂停!
| 归档时间: |
|
| 查看次数: |
87284 次 |
| 最近记录: |