OpenCV imwrite 2.2导致异常,并显示消息"OpenCV错误:未指定的错误(找不到指定扩展名的编写器)".在Windows 7上 [英] OpenCV imwrite 2.2 causes exception with message "OpenCV Error: Unspecified error (could not find a writer for the specified extension)" on Windows 7

查看:370
本文介绍了OpenCV imwrite 2.2导致异常,并显示消息"OpenCV错误:未指定的错误(找不到指定扩展名的编写器)".在Windows 7上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Unix上的OpenCV 2.2应用程序(可运行)移植到64位Windows 7上,并且在调用cv :: imwrite时收到以下异常

I'm porting an OpenCV 2.2 app from Unix (that works) onto Windows 7 64-bit and I receive the following exception when cv::imwrite is called

"OpenCV错误:未知函数文件highgui \ src \ loadsave.cpp中出现未指定的错误(找不到指定扩展名的编写器)"

"OpenCV Error: Unspecified error (could not find a writer for the specified extension) in unknown function, file highgui\src\loadsave.cpp"

原始的unix应用程序可以在我的Mac和Linux机器上正常工作.

The original unix app works fine on my Mac and Linux boxes.

有人知道我可能缺少哪些库或编译器配置来使它在Windows上工作吗?

Does anyone know what library or compiler config I could be missing that makes this work on Windows?

更新:

为了使OpenCV运行,我做了以下事情:

I did the following things to get OpenCV running:

  • 从Windows的OpenCV站点下载了v2.2的二进制文件.我之所以使用2.2,是因为原始应用使用了2.2,并且我不想在此阶段使我的构建复杂化.
  • 我正在尝试写入.png文件.我查看了OpenCV代码,并注意到编码器需要外部库(例如Png或jpegs),因此我尝试写入.ppm,.bmp,这似乎不需要deps,但我得到了相同的错误.
  • 我的用法示例是cv :: imwrite("out.png",cv_scaled);其中cv_scaled的类型为cv :: Mat,格式为CV_32FC1
  • 请记住,相同的代码在Unix中可以正常工作

.bmp或.ppm不起作用的事实引起了更多问题:

The fact .bmp or .ppm doesn't work this raises more questions:

  • 为什么这些非常简单的格式不起作用?
  • 是否可以通过编程方式查看已安装的编码器列表?

再次感谢您的帮助,以帮助我调试此问题.

Thanks again for your kind assistance in helping me debug this problem.

推荐答案

您当前安装的OpenCV不支持您尝试在磁盘上创建的文件格式.

Your current installation of OpenCV doesn't support the file format you are trying to create on disk.

检查文件扩展名是否正确.如果是这样,则必须重新编译OpenCV并添加对此格式的支持,并可能安装缺少的库.

Check if the extension of the file is right. If it is, you'll have to recompile OpenCV and add support to this format and possibly install the libraries you are missing.

仅此而已,而无需更多信息.

That's all that can be said without more information.

由于我也无法构建使用OpenCV的C ++接口(在VS2005上为v2.3)的应用程序,因此我最终使用了以下解决方法:在必要时将C ++类型转换为C类型.

As I have also failed building an application that uses the C++ interface of OpenCV (v2.3 on VS2005) I ended up using the following workaround: convert the C++ types to the C types when necessary.

要从IplImage*转换为cv::Mat很简单:

IplImage* ipl_img = cvLoadImage("test.jpg", CV_LOAD_IMAGE_UNCHANGED);
Mat mat_img(ipl_img);

imshow("window", mat_img);

cv::MatIplImage*的转换不是很明显,但是也很简单,诀窍是使用IplImage而不是IplImage*:

The conversion cv::Mat to IplImage* is not so obvious, but it's also simple, and the trick is to use a IplImage instead of a IplImage*:

IplImage ipl_from_mat((IplImage)mat_img);

cvNamedWindow("window", CV_WINDOW_AUTOSIZE);
// and then pass the memory address of the variable when you need it as IplImage*
cvShowImage("window", &ipl_from_mat); 

这篇关于OpenCV imwrite 2.2导致异常,并显示消息"OpenCV错误:未指定的错误(找不到指定扩展名的编写器)".在Windows 7上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆