LoginSignup
1
1

More than 5 years have passed since last update.

[メモ] OpenCVサンプル: find_obj.py

Posted at
  • --feature=brisk Spectacle.n19370.png

https://qiita.com/mt08/items/e8e8e728cf106ac83218#comment-dbe1ad502bf526744ab5
での確認で、このサンプルを試しました。

環境

手順

  1. ラズパイ等の準備 ... (省略)
  2. サンプルで使用する画像データ取得

    pi@raspberrypi:~ $ # Sample Data
    pi@raspberrypi:~ $ wget -q https://github.com/opencv/opencv/raw/master/samples/data/box.png
    pi@raspberrypi:~ $ wget -q https://github.com/opencv/opencv/raw/master/samples/data/box_in_scene.png
    
  3. --feature=briskにて

    pi@raspberrypi:~ $ python3 /usr/local/share/OpenCV/samples/python/find_obj.py --feature=brisk box.png box_in_scene.png
    
    Feature-based image matching sample.
    
    Note, that you will need the https://github.com/opencv/opencv_contrib repo for SIFT and SURF
    
    USAGE
      find_obj.py [--feature=<sift|surf|orb|akaze|brisk>[-flann]] [ <image1> <image2> ]
    
      --feature  - Feature to use. Can be sift, surf, orb or brisk. Append '-flann'
                   to feature name to use Flann-based matcher instead bruteforce.
    
      Press left mouse button on a feature point to see its matching point.
    
    using brisk
    img1 - 1662 features, img2 - 2786 features
    matching...
    50 / 52  inliers/matched
    Done
    pi@raspberrypi:~ $
    

    Spectacle.n19370.png

その他

  1. --feature=sirf--feature=surf

    ここで配布しているラズパイ向けパッケージでは、ビルドに含まれていないのでエラーとなります。

    (-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'

    ぐーぐる先生翻訳:

    (-213:機能/機能は実装されていません) このアルゴリズムは特許取得済みで、この構成では除外されています。 OPENCV_ENABLE_NONFREE CMakeオプションを設定し、関数 'create'でライブラリを再構築します

    実行例
    pi@raspberrypi:~ $ python3 /usr/local/share/OpenCV/samples/python/find_obj.py --feature=sift box.png box_in_scene.png
    
    Feature-based image matching sample.
    
    Note, that you will need the https://github.com/opencv/opencv_contrib repo for SIFT and SURF
    
    USAGE
      find_obj.py [--feature=<sift|surf|orb|akaze|brisk>[-flann]] [ <image1> <image2> ]
    
      --feature  - Feature to use. Can be sift, surf, orb or brisk. Append '-flann'
                   to feature name to use Flann-based matcher instead bruteforce.
    
      Press left mouse button on a feature point to see its matching point.
    
    Traceback (most recent call last):
      File "/usr/local/share/OpenCV/samples/python/find_obj.py", line 195, in <module>
        main()
      File "/usr/local/share/OpenCV/samples/python/find_obj.py", line 154, in main
        detector, matcher = init_feature(feature_name)
      File "/usr/local/share/OpenCV/samples/python/find_obj.py", line 32, in init_feature
        detector = cv.xfeatures2d.SIFT_create()
    cv2.error: OpenCV(3.4.6) /home/pi/opencv_contrib-3.4.6/modules/xfeatures2d/src/sift.cpp:1205: 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'
    
    pi@raspberrypi:~ $ 
    
  2. OPENCV_ENABLE_NONFREEは今度ためしてみようかと思いますが、公に配布はどうなんでしょう?

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1