2011-09-14 144 views
2

我從OpenCV網站下載OpenCV 2.3.1並將其解壓到/usr/share/src。我該文件夾生成make文件中跑sudo cmake .,然後跑去「sudo make」我發現了以下錯誤:無法打開OpenCV

[ 20%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/loadsave.o

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:298: error: ‘InputArray’ has not been declared

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp: In function ‘bool cv::imwrite(const std::string&, int, const std::vector >&)’:

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:301: error: request for member ‘getMat’ in ‘_img’, which is of non-class type ‘int’

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp: In function ‘void* cv::imdecode_(const cv::Mat&, int, int, cv::Mat*)’:

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:312: error: ‘tempfile’ was not declared in this scope

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp: At global scope:

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:392: error: ‘cv::Mat cv::imdecode’ redeclared as different kind of symbol

/opt/local/include/opencv2/highgui/highgui.hpp:107: error: previous declaration of ‘cv::Mat cv::imdecode(const cv::Mat&, int)’

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:392: error: ‘InputArray’ was not declared in this scope

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:392: error: expected primary-expression before ‘int’

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:399: error: ‘InputArray’ has not been declared

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp: In function ‘bool cv::imencode(const std::string&, int, std::vector >&, const std::vector >&)’:

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:402: error: request for member ‘getMat’ in ‘_image’, which is of non-class type ‘int’

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:427: error: ‘tempfile’ was not declared in this scope

make[2]: * [modules/highgui/CMakeFiles/opencv_highgui.dir/src/loadsave.o] Error 1

make[1]: * [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error

這是爲什麼?我該如何解決它?由於

完整的錯誤如下:

make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/window.o] Error 1 
make[2]: *** Waiting for unfinished jobs.... 
In file included from /usr/share/src/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg.cpp:45: 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvCapture_FFMPEG::grabFrame()’: 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:638: warning: ‘avcodec_decode_video’ is deprecated (declared at /opt/local/include/libavcodec/avcodec.h:3454) 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:640: warning: ‘avcodec_decode_video’ is deprecated (declared at /opt/local/include/libavcodec/avcodec.h:3454) 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvVideoWriter_FFMPEG::open(const char*, int, double, int, int, bool)’: 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1339: warning: ‘guess_format’ is deprecated (declared at /opt/local/include/libavformat/avformat.h:789) 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1339: warning: ‘guess_format’ is deprecated (declared at /opt/local/include/libavformat/avformat.h:789) 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1367: warning: ‘av_alloc_format_context’ is deprecated (declared at /opt/local/include/libavformat/avformat.h:947) 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1367: warning: ‘av_alloc_format_context’ is deprecated (declared at /opt/local/include/libavformat/avformat.h:947) 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:298: error: ‘InputArray’ has not been declared 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp: In function ‘bool cv::imwrite(const std::string&, int, const std::vector<int, std::allocator<int> >&)’: 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:301: error: request for member ‘getMat’ in ‘_img’, which is of non-class type ‘int’ 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp: In function ‘void* cv::imdecode_(const cv::Mat&, int, int, cv::Mat*)’: 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:312: error: ‘tempfile’ was not declared in this scope 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp: At global scope: 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:392: error: ‘cv::Mat cv::imdecode’ redeclared as different kind of symbol 
/opt/local/include/opencv2/highgui/highgui.hpp:107: error: previous declaration of ‘cv::Mat cv::imdecode(const cv::Mat&, int)’ 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:392: error: ‘InputArray’ was not declared in this scope 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:392: error: expected primary-expression before ‘int’ 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:399: error: ‘InputArray’ has not been declared 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp: In function ‘bool cv::imencode(const std::string&, int, std::vector<unsigned char, std::allocator<unsigned char> >&, const std::vector<int, std::allocator<int> >&)’: 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:402: error: request for member ‘getMat’ in ‘_image’, which is of non-class type ‘int’ 
/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:427: error: ‘tempfile’ was not declared in this scope 
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/loadsave.o] Error 1 
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2 

回答

3

嘗試指導下使用CMake的構建在第2節的the Wiki

mkdir build 
cd build 
cmake -G "Unix Makefiles" .. 
make -j8 
sudo make install 
+1

這給出了與「make -j8」相同的錯誤 – Power

+0

可能需要刪除'/ usr/share/src/OpenCV-2.3.1'並在構建之前使用wiki的說明從tar包中解壓縮乾淨的源代碼。 –

+0

這也適用於我。當我使用fink安裝其他軟件時,我也看到它失敗。 (在這種情況下,我暫時將fink/sw目錄移到了其他目錄中,所以當我正在執行cmake/make時,它不會在各種路徑中找到) – wrjohns

2

你可能有更早的衝突安裝MacPorts。 運行:

port installed opencv 

如果該發現的OpenCV的另一個版本則使用:

sudo port deactivate opencv 

然後再次運行make。

注意:它會制動任何取決於您以前的opencv端口安裝。因此,您需要再次激活舊的或調整依賴關係才能使用2.3.1。

相關問題