2013-01-16 55 views
0

我在OSX 10.7.5上運行OpenCV(2.4.3)的brew安裝。我已經嘗試了OpenEXR(1.7.0)的brew安裝並直接下載它們的源代碼和編譯1.7.1,因爲我讀過它的界面可能有一些變化。兩種版本的OpenEXR都會讓我在Preview中打開EXR文件。每次新安裝OpenEXR後,我都回去了,卸載了OpenCV並重新安裝了它。 OpenCV中被檢測到正確的OpenEXR:OpenCV 2.4.3在OSX 10.7上讀寫OpenEXR時拋出錯誤10.7

-- Media I/O: 
--  ZLib:      /usr/lib/libz.dylib (ver 1.2.5) 
--  JPEG:      /usr/local/lib/libjpeg.dylib (ver 80) 
--  PNG:       /usr/X11/lib/libpng.dylib (ver 1.5.4) 
--  TIFF:      /usr/local/lib/libtiff.dylib (ver 42 - 4.0.3) 
--  JPEG 2000:     /usr/local/lib/libjasper.dylib (ver 1.900.1) 
--  OpenEXR:      build (ver 1.7.1) 

當我嘗試讀取或通過CV2在Python寫EXR我得到

terminate called throwing an exceptionAbort trap:6 

這是完全的崩潰報告:

Exception Type: EXC_CRASH (SIGABRT) 
Exception Codes: 0x0000000000000000, 0x0000000000000000 

Application Specific Information: 
abort() called 
objc[52394]: garbage collection is OFF 
terminate called throwing an exception 

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 
0 libsystem_kernel.dylib   0x00007fff8e43a82a __kill + 10 
1 libsystem_c.dylib    0x00007fff8e012a9c abort + 177 
2 libc++abi.dylib     0x00007fff8d2607bc abort_message + 214 
3 libc++abi.dylib     0x00007fff8d25dfcf default_terminate() + 28 
4 libobjc.A.dylib     0x00007fff944501cd _objc_terminate + 114 
5 libc++abi.dylib     0x00007fff8d25e001 safe_handler_caller(void (*)()) + 11 
6 libc++abi.dylib     0x00007fff8d25e05c std::terminate() + 16 
7 libc++abi.dylib     0x00007fff8d25f152 __cxa_throw + 114 
8 libopencv_highgui.2.4.dylib  0x000000010dc49d44 Iex::throwErrnoExc(std::string const&, int) + 3492 
9 libopencv_highgui.2.4.dylib  0x000000010dc4a8fc Iex::throwErrnoExc(std::string const&) + 24 
10 libopencv_highgui.2.4.dylib  0x000000010dc4c5e7 IlmThread::Semaphore::Semaphore(unsigned int) + 67 
11 libopencv_highgui.2.4.dylib  0x000000010dc4b969 IlmThread::ThreadPool::Data::Data() + 27 
12 libopencv_highgui.2.4.dylib  0x000000010dc4be74 IlmThread::ThreadPool::ThreadPool(unsigned int) + 46 
13 libopencv_highgui.2.4.dylib  0x000000010dc4c260 IlmThread::ThreadPool::globalThreadPool() + 46 
14 libopencv_highgui.2.4.dylib  0x000000010dc696aa Imf::globalThreadCount() + 9 
15 libopencv_highgui.2.4.dylib  0x000000010dc3e38b cv::ExrDecoder::readHeader() + 35 
16 libopencv_highgui.2.4.dylib  0x000000010dc2f54a _ZN2cvL7imread_ERKSsiiPNS_3MatE + 249 
17 libopencv_highgui.2.4.dylib  0x000000010dc2f3d4 cv::imread(std::string const&, int) + 132 
18 cv2.so       0x000000010d4d28f4 _ZL15pyopencv_imreadP7_objectS0_S0_ + 332 
19 org.python.python    0x000000010d19ed77 PyEval_EvalFrameEx + 13861 
20 org.python.python    0x000000010d1a1cd8 PyEval_EvalCodeEx + 1996 
21 org.python.python    0x000000010d1a1d4d PyEval_EvalCode + 54 
22 org.python.python    0x000000010d1b908f 0x10d117000 + 663695 
23 org.python.python    0x000000010d1ba671 PyRun_InteractiveOneFlags + 517 
24 org.python.python    0x000000010d1ba79a PyRun_InteractiveLoopFlags + 214 
25 org.python.python    0x000000010d1ba7fc PyRun_AnyFileExFlags + 63 
26 org.python.python    0x000000010d1ca2af Py_Main + 2715 
27 org.python.python    0x000000010d10fe88 0x10d10f000 + 3720 

具體,這些錯誤的結果是:

import cv2 
cv2.imread("image.exr") 

有什麼建議嗎?

編輯:我也試圖從OpenCV網站2.4.3的源代碼的新編譯,並遇到完全相同的問題。

回答

3

我有一個非常類似的問題,並調試了庫,通過源挖掘並找到問題的原因。

這是由OpenEXR庫試圖使用SysV信號量引起的,當它們實際上不受支持時。 EXR的CMakeLists.txt中有一行代碼,用於查找是否存在semaphore.h以決定它是否應該在支持庫中使用它。

但是,達爾文僅將信號量作爲遺留,並且sem_init()將始終返回ENOSYS,這意味着它未實現。這會導致信號量構造函數在其構造函數中引發異常,當嘗試解析EXR頭時會觸發該異常。

解決方法是編輯文件ilmBaseConfig.h,改變信號燈行改爲:

#undef HAVE_POSIX_SEMAPHORES 

然後重新編譯和安裝。

EXR庫將使用自己的信號量實現,並且EXR加載將正常工作。

0

通過回滾到OpenCV 2.4.2來解決這個問題。看起來好像他們已經將OpenEXR 1.7.1與2.4.3發行版捆綁在一起,並且它不起作用。另外,2.4.3似乎無法檢測早期版本的OpenEXR。