Libpng conflict on OpenCV?

亡梦爱人 提交于 2019-12-23 22:23:10

问题


I am trying to open up png files on my XCode 4.4 (Mountain Lion) with the following codes (works for jpg files)

Mat image = imread( "/Users/user_name/Desktop/result.png" );
imshow( "", image );
waitKey( 0 );

But OpenCV throws me this error:

libpng warning: Application built with libpng-1.4.12 but running with 1.5.4
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/OpenCV-2.4.2/modules/core/src/array.cpp, line 2482
libc++abi.dylib: terminate called throwing an exception

Seems like my png file was created using a newer libpng, while OpenCV is using older one. So how do I resolve this issue ?

Edit: more information

I'm using OSX Mountain Lion, with XCode 4.4, and using OpenCV 2.4.2 installed by using MacPorts


回答1:


No. It is not an issue with your png file. it does not matter what version it was created with. It will be compatible. The issue is in your libpng library.

Application built with libpng-1.4.12 - This means that your executable was linked to libpng 1.4.12.

but running with 1.5.4 - this means that during run time, your executable is picking up version 1.5.4 of the library( a dynamic library perhaps).

OpenCV 2.4.2 ships with libpng - 1.5.9 - there seems to be a mismatch here.

Anyway, to fix this, ensure that during linking, you link with the libpng built with OpenCV. If you are linking dynamically, ensure that your librarypath includes OpenCV's 3rd party lib path ahead of all others.



来源:https://stackoverflow.com/questions/11865389/libpng-conflict-on-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!