无法制作OpenCV

时间:2011-09-14 00:27:29

标签: macos opencv makefile osx-snow-leopard

我从OpenCV网站下载了OpenCV 2.3.1并将其解压缩到/usr/share/src。我在该文件夹中运行sudo cmake .以生成make文件,然后运行“sudo make”我收到以下错误:

  

[20%]构建CXX对象   模块/ highgui / CMakeFiles / opencv_highgui.dir / SRC / loadsave.o

     

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:298:   错误:'InputArray'尚未声明

     

/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:   错误:请求'_img'中的成员'getMat',这是非类的   输入'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:   错误:'tempfile'未在此范围内声明

     

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:At   全球范围:

     

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:392:   错误:'cv :: Mat cv :: imdecode'重新声明为不同类型的符号

     

/opt/local/include/opencv2/highgui/highgui.hpp:107:错误:上一个   声明'cv :: Mat cv :: imdecode(const cv :: Mat&,int)'

     

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:392:   错误:未在此范围内声明'InputArray'

     

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:392:   错误:'int'之前的预期primary-expression

     

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:399:   错误:'InputArray'尚未声明

     

/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:   错误:请求'_image'中的成员'getMat',这是非类的   输入'int'

     

/usr/share/src/OpenCV-2.3.1/modules/highgui/src/loadsave.cpp:427:   错误:'tempfile'未在此范围内声明

     

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

     

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

这是为什么?我该如何解决?感谢

完整错误如下:

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

2 个答案:

答案 0 :(得分:3)

尝试the Wiki第2部分中使用CMake构建下的说明:

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

答案 1 :(得分:2)

您可能与之前安装的MacPorts存在冲突。 运行:

port installed opencv

如果找到另一个版本的opencv,请使用:

sudo port deactivate opencv

然后再次运行make。

注意:它会根据您以前的opencv端口安装制动任何东西。因此,您需要再次激活旧版或调整依赖项以使用2.3.1。