質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
OpenCV

OpenCV(オープンソースコンピュータービジョン)は、1999年にインテルが開発・公開したオープンソースのコンピュータビジョン向けのクロスプラットフォームライブラリです。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Q&A

解決済

2回答

1239閲覧

home-brewを使用してopencv3のcontribをインストールしたい

9zou

総合スコア14

OpenCV

OpenCV(オープンソースコンピュータービジョン)は、1999年にインテルが開発・公開したオープンソースのコンピュータビジョン向けのクロスプラットフォームライブラリです。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

0グッド

0クリップ

投稿2019/10/02 05:31

opencvのsift特徴量を求めるライブラリを使用したいので、contribをインストールしようとしたら、homebrew自体がインストールオプションをなくしていたので、opencv3全体をインストールしたものの、SIFTがまだありません。。。
同じような状況に陥った方、対処法を知っている方、いらっしゃいましたら是非ご教授ください。
宜しくお願い致します。

python

1import numpy 2import cv2 3 4sift = cv2.SIFT() 5 6 7↓Error↓ 8Traceback (most recent call last): 9 File "test.py", line 166, in <module> 10 sift = cv2.SIFT() 11AttributeError: module 'cv2.cv2' has no attribute 'SIFT'

console

1$ brew install opencv3 --with-contrib 2Usage: brew install [options] formula 3 4Install formula. Additional options specific to formula may be appended to 5the command. 6 7Unless HOMEBREW_NO_INSTALL_CLEANUP is set, brew cleanup will then be run for 8the installed formulae or, every 30 days, for all formulae. 9 10 -d, --debug If brewing fails, open an interactive 11 debugging session with access to IRB or a 12 shell inside the temporary build directory. 13 --env If std is passed, use the standard build 14 environment instead of superenv. If super 15 is passed, use superenv even if the formula 16 specifies the standard build environment. 17 --ignore-dependencies An unsupported Homebrew development flag to 18 skip installing any dependencies of any 19 kind. If the dependencies are not already 20 present, the formula will have issues. If 21 you're not developing Homebrew, consider 22 adjusting your PATH rather than using this 23 flag. 24 --only-dependencies Install the dependencies with specified 25 options but do not install the formula 26 itself. 27 --cc Attempt to compile using the specified 28 compiler, which should be the name of the 29 compiler's executable, e.g. gcc-7 for GCC 30 7. In order to use LLVM's clang, specify 31 llvm_clang. To use the Apple-provided 32 clang, specify clang. This option will 33 only accept compilers that are provided by 34 Homebrew or bundled with macOS. Please do 35 not file issues if you encounter errors 36 while using this option. 37 -s, --build-from-source Compile formula from source even if a 38 bottle is provided. Dependencies will still 39 be installed from bottles if they are 40 available. 41 --force-bottle Install from a bottle if it exists for the 42 current or newest version of macOS, even if 43 it would not normally be used for 44 installation. 45 --include-test Install testing dependencies required to 46 run brew test formula. 47 --devel If formula defines it, install the 48 development version. 49 --HEAD If formula defines it, install the HEAD 50 version, aka. master, trunk, unstable. 51 --fetch-HEAD Fetch the upstream repository to detect if 52 the HEAD installation of the formula is 53 outdated. Otherwise, the repository's HEAD 54 will only be checked for updates when a new 55 stable or development version has been 56 released. 57 --keep-tmp Retain the temporary files created during 58 installation. 59 --build-bottle Prepare the formula for eventual bottling 60 during installation, skipping any 61 post-install steps. 62 --bottle-arch Optimise bottles for the specified 63 architecture rather than the oldest 64 architecture supported by the version of 65 macOS the bottles are built on. 66 -f, --force Install without checking for previously 67 installed keg-only or non-migrated 68 versions. 69 -v, --verbose Print the verification and postinstall 70 steps. 71 --display-times Print install times for each formula at the 72 end of the run. 73 -i, --interactive Download and patch formula, then open a 74 shell. This allows the user to run 75 ./configure --help and otherwise 76 determine how to turn the software package 77 into a Homebrew package. 78 -g, --git Create a Git repository, useful for 79 creating patches to the software. 80 -h, --help Show this message. 81Error: invalid option: --with-contrib

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

tiitoi

2019/10/02 07:08

OpenCV 3からAPI が sift = cv2.xfeatures2d.SIFT_create() に変更されたようです。
9zou

2019/10/02 14:28

返信有難うございます。 それも試して、同じエラーが出たので、もう一度消して入れ直してみようと思います!
9zou

2019/10/03 00:46

入れ直して、試してみたところ、以下のようなエラーが出ました。 この場合、実行する際に、以下のOPENCV_ENABLE_NONFREEオプションを付ければ良いのでしょうか? cv2.error: OpenCV(4.1.1) /Users/travis/build/skvark/opencv-python/opencv_contrib/modules/xfeatures2d/src/sift.cpp:1207: error: (-213:The function/feature is not implemented) This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'create'
tiitoi

2019/10/03 02:15

自分は Mac 環境はないため、brew でどうなるかはわからなかったのですが、pip で入れた場合も同じようになります。原因については長くなるので回答に記載しました。 ソースビルドすれば使えるようになるわけですが、cmake 等の知識が必要になるため、AKAZE など今インストールしてある OpenCV でも使える特徴量を使用されてはどうでしょうか
guest

回答2

0

回答有難うございます!!
特許関連のことだったんですね。。。
linux環境は最近したばっかりだったので、ちょっとCMakeについても知りたくなったので、AKAZE使いつつ、SIFTも使えるようにしていきたいと思います。。。!
ありがとうございました!!

投稿2019/10/03 03:39

9zou

総合スコア14

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

ベストアンサー

error: This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'create'

翻訳

エラー: このアルゴリズムは特許が取得されているため、このビルド構成には含まれていません。
CMake で OPENCV_ENABLE_NONFREE を有効にして、ライブラリをビルドし直してください。

どういうことかというと、SIFT や SURF は特許が取得されているアルゴリズムのため、デフォルトで配布されているバイナリには含まれていません。
どうしても使いたい場合は、ソースコードを Github から取得し、cmake のオプションで OPENCV_ENABLE_NONFREE=true にしてビルドする必要があります。

ソースビルドはそれなりに面倒なので、AKAZE や ORB など SIFT より新しい世代の特徴量を使用してはどうでしょうか?
こちらは特許フリーなので、brew でインストールしたバイナリにも含まれていると思います。

OpenCV 3とPython 3で特徴量マッチング(A-KAZE, KNN) - Qiita

投稿2019/10/03 02:13

tiitoi

総合スコア21956

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

9zou

2019/10/03 03:40

回答有難うございます!! 特許関連のことだったんですね。。。 linux環境は最近したばっかりだったので、ちょっとCMakeについても知りたくなったので、AKAZE使いつつ、SIFTも使えるようにしていきたいと思います。。。! ありがとうございました!!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問