简体   繁体   English

在OS X Lion上安装OpenCV

[英]Install OpenCV on OS X Lion

I'm trying to install OpenCV for the paperclip-facecrop gem but I'm having problems installing the opencv gem. 我正在尝试为paperclip-facecrop gem安装OpenCV,但我在安装opencv gem时遇到问题。

I installed opencv with brew and I think the gem just needs to know the right path? 我用brew安装了opencv,我认为gem需要知道正确的路径?

Gemfile 的Gemfile

gem "paperclip", "~> 2.3"
gem "opencv", :git => "https://github.com/ser1zw/ruby-opencv"
gem "paperclip-facecrop"

.bash_profile .bash_profile中

    export PYTHONPATH="/usr/local/lib/python2.6/site-packages/:$PYTHONPATH"
    # OS X 10.7 Lion
    # Set the compiler to GCC (instead of default LLVM) for RVM
            # For Lion, Rubies should be built using gcc rather than llvm-gcc. Since
        # /usr/bin/gcc is now linked to /usr/bin/llvm-gcc-4.2, add the following to
        # your shell's start-up file: export CC=gcc-4.2
        # (The situation with LLVM and Ruby may improve. This is as of 07-23-2011.)
    export CC=gcc-4.2

Console 安慰

/Users/jonathanspooner/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
>> check require libraries...
checking for main() in -lopencv_calib3d... yes
checking for main() in -lopencv_contrib... yes
checking for main() in -lopencv_core... yes
checking for main() in -lopencv_features2d... yes
checking for main() in -lopencv_flann... yes
checking for main() in -lopencv_gpu... yes
checking for main() in -lopencv_highgui... yes
checking for main() in -lopencv_imgproc... yes
checking for main() in -lopencv_legacy... yes
checking for main() in -lopencv_ml... yes
checking for main() in -lopencv_objdetect... yes
checking for main() in -lopencv_video... yes
checking for main() in -lstdc++... yes
>> check require headers...
checking for opencv2/core/core_c.h... yes
checking for opencv2/core/core.hpp... yes
checking for opencv2/imgproc/imgproc_c.h... yes
checking for opencv2/imgproc/imgproc.hpp... yes
checking for opencv2/video/tracking.hpp... yes
checking for opencv2/features2d/features2d.hpp... yes
checking for opencv2/flann/flann.hpp... yes
checking for opencv2/calib3d/calib3d.hpp... yes
checking for opencv2/objdetect/objdetect.hpp... yes
checking for opencv2/legacy/compat.hpp... yes
checking for opencv2/legacy/legacy.hpp... yes
checking for opencv2/highgui/highgui_c.h... yes
checking for opencv2/highgui/highgui.hpp... yes
checking for stdarg.h... yes
>> ----- optional -----
>> check ffcall...
checking for main() in -lcallback... yes
checking for callback.h... yes
>> support OpenCV::GUI::Window#set_trackbar
creating Makefile

make
Makefile:172: warning: overriding commands for target `/Users/jonathanspooner/.rvm/gems/ruby-1.9.2-p290@woodhack/bundler/gems/ruby-opencv-1162590303e6/lib'
Makefile:168: warning: ignoring old commands for target `/Users/jonathanspooner/.rvm/gems/ruby-1.9.2-p290@woodhack/bundler/gems/ruby-opencv-1162590303e6/lib'
g++ -I. -I/Users/jonathanspooner/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin11.0.0 -I/Users/jonathanspooner/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/jonathanspooner/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I./ext/opencv -DHAVE_OPENCV2_CORE_CORE_C_H -DHAVE_OPENCV2_CORE_CORE_HPP -DHAVE_OPENCV2_IMGPROC_IMGPROC_C_H -DHAVE_OPENCV2_IMGPROC_IMGPROC_HPP -DHAVE_OPENCV2_VIDEO_TRACKING_HPP -DHAVE_OPENCV2_FEATURES2D_FEATURES2D_HPP -DHAVE_OPENCV2_FLANN_FLANN_HPP -DHAVE_OPENCV2_CALIB3D_CALIB3D_HPP -DHAVE_OPENCV2_OBJDETECT_OBJDETECT_HPP -DHAVE_OPENCV2_LEGACY_COMPAT_HPP -DHAVE_OPENCV2_LEGACY_LEGACY_HPP -DHAVE_OPENCV2_HIGHGUI_HIGHGUI_C_H -DHAVE_OPENCV2_HIGHGUI_HIGHGUI_HPP -DHAVE_STDARG_H -DHAVE_CALLBACK_H -I/usr/include -I/opt/local/include -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long  -fno-common -pipe -I./ext/opencv   -o cverror.o -c ./ext/opencv/cverror.cpp
./ext/opencv/cverror.cpp: In function ‘void mOpenCV::cCvError::define_ruby_class()’:
./ext/opencv/cverror.cpp:143: error: ‘CV_GpuCufftCallError’ was not declared in this scope
./ext/opencv/cverror.cpp: In function ‘void mOpenCV::cCvError::raise(cv::Exception)’:
./ext/opencv/cverror.cpp:157: warning: format not a string literal and no format arguments
make: *** [cverror.o] Error 1

You seem to use OpenCV 2.2 and the master branch of opencv gem, which is for OpenCV 2.3 or later. 您似乎使用OpenCV 2.2和opencv gem的主分支,这是OpenCV 2.3或更高版本。

Try the gem for OpenCV 2.2: https://github.com/ser1zw/ruby-opencv/tree/OpenCV_2.2 试试OpenCV 2.2的gem: https//github.com/ser1zw/ruby-opencv/tree/OpenCV_2.2

Also verify your Pythonpath. 还要验证您的Pythonpath。 OSX Lion uses Python 2.7 by default, which would be: OSX Lion默认使用Python 2.7,它将是:

export PYTHONPATH="/usr/local/lib/python2.7/site-packages/:$PYTHONPATH" export PYTHONPATH =“/ usr / local / lib / python2.7 / site-packages /:$ PYTHONPATH”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM