使用python / opencv读取TIF文件时出现分段错误

时间:2016-03-14 22:26:53

标签: python-2.7 opencv segmentation-fault tiff libtiff

环境:

  • centos 6.7
  • opencv 2.4.12
  • python 2.7
  • GNU libc 2.12
  • gcc version 4.4.7 20120313(Red Hat 4.4.7-16)

uname输出:

Linux xxxx 2.6.32-573.18.1.el6.x86_64 #1 SMP xxx x86_64 x86_64 x86_64 GNU/Linux

清除2.4.12版本的下载并使用以下命令编译好:

export PYTHON_EXECUTABLE=/usr/bin/python2.7
export PYTHON_INCLUDE_PATH=/usr/include/python2.7/
export PYTHON_LIBRARY=/usr/lib64/libpython2.7.so
export PYTHON_NUMPY_INCLUDE_DIR=/home/centos/.local/lib/python2.7/site-packages/numpy/core/include/numpy
export PYTHON_PACKAGES_PATH=/home/centos/.local/lib/python2.7/site-packages
cmake  \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DBUILD_WITH_DEBUG_INFO=ON \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE  \
-DPYTHON_INCLUDE_PATH=$PYTHON_INCLUDE_PATH \
-DPYTHON_LIBRARY=$PYTHON_LIBRARY \
-DPYTHON_NUMPY_INCLUDE_DIR=$PYTHON_NUMPY_INCLUDE_DIR \
-DPYTHON_PACKAGES_PATH=$PYTHON_PACKAGES_PATH \
-DINSTALL_C_EXAMPLES=OFF \
-DINSTALL_PYTHON_EXAMPLES=OFF \
-DBUILD_EXAMPLES=OFF \
-DWITH_FFMPEG=OFF ..

运行make

的输出代码段
--   Media I/O: 
--     ZLib:                        /usr/lib64/libz.so (ver 1.2.3)
--     JPEG:                        /usr/lib64/libjpeg.so (ver )
--     PNG:                         /usr/lib64/libpng.so (ver 1.2.49)
--     TIFF:                        /usr/lib64/libtiff.so (ver 42 - 3.9.4)
--     JPEG 2000:                   /usr/lib64/libjasper.so (ver 1.900.1)
--     OpenEXR:                     /usr/lib64/libImath.so /usr/lib64/libIlmImf.so /usr/lib64/libIex.so /usr/lib64/libHalf.so /usr/lib64/libIlmThread.so (ver 1.6.1)
-- 

然而。这很好:

>$ python2.7 -c "import cv2; cv2.imread('test.png')"

但这不是:

  

$ python2.7 -c“import cv2; cv2.imread('test.tif')”

OpenCV Error: Assertion failed (udata < (uchar*)ptr && ((uchar*)ptr -
udata) <= (ptrdiff_t)(sizeof(void*)+16)) in fastFree, file
/fleuron-data/opencv-2.4.12/modules/core/src/alloc.cpp, line 78
terminate called after throwing an instance of 'cv::Exception'
  what():  /fleuron-data/opencv-2.4.12/modules/core/src/alloc.cpp:78:
error: (-215) udata < (uchar*)ptr && ((uchar*)ptr - udata) <=
(ptrdiff_t)(sizeof(void*)+16) in function fastFree

Aborted

让我输了..

1 个答案:

答案 0 :(得分:0)

原来是opencv中的一个错误:https://github.com/Itseez/opencv/pull/5357