🤖 AIによる機械翻訳(非公式) — これは OpenCV 5.0.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。

クラス ANNIndex


  • public class ANNIndex extends java.lang.Object
    *************************************************************************************\ 近似最近傍探索 (Approximate Nearest Neighbors) * \***************************************************************************************
    • コンストラクタの要約

      コンストラクタ
      Modifier Constructor Description
      protected ANNIndex​(long addr)  
    • メソッドの要約

      すべてのメソッド 静的メソッド インスタンスメソッド 具象メソッド
      Modifier and Type Method Description
      static ANNIndex __fromPtr__​(long addr)  
      void addItems​(Mat features)
      Add feature vectors to index.
      void build()
      Build the index.
      void build​(int trees)
      Build the index.
      static ANNIndex create​(int dim)
      Creates an instance of annoy index class with given parameters
      static ANNIndex create​(int dim, int distType)
      Creates an instance of annoy index class with given parameters
      int getItemNumber()
      Return the number of feature vectors in the index.
      long getNativeObjAddr()  
      int getTreeNumber()
      Return the number of trees in the index.
      void knnSearch​(Mat query, Mat indices, Mat dists, int knn)
      Performs a K-nearest neighbor search for given query vector(s) using the index.
      void knnSearch​(Mat query, Mat indices, Mat dists, int knn, int search_k)
      Performs a K-nearest neighbor search for given query vector(s) using the index.
      void load​(java.lang.String filename)
      Loads (mmaps) an index from disk.
      void load​(java.lang.String filename, boolean prefault)
      Loads (mmaps) an index from disk.
      void save​(java.lang.String filename)
      Save the index to disk and loads it.
      void save​(java.lang.String filename, boolean prefault)
      Save the index to disk and loads it.
      boolean setOnDiskBuild​(java.lang.String filename)
      Prepare to build the index in the specified file instead of RAM (execute before adding items, no need to save after build)
      void setSeed​(int seed)
      Initialize the random number generator with the given seed.
      • クラス java.lang.Object から継承したメソッド

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • コンストラクタの詳細

      • ANNIndex

        protected ANNIndex​(long addr)
    • メソッドの詳細

      • getNativeObjAddr

        public long getNativeObjAddr()
      • __fromPtr__

        public static ANNIndex __fromPtr__​(long addr)
      • addItems

        public void addItems​(Mat features)
        Add feature vectors to index.
        引数:
        features - インデックスに登録する特徴ベクトルを格納した行列。行列のサイズは num_features x feature_dimension。
      • build

        public void build​(int trees)
        Build the index.
        引数:
        trees - インデックス内の木の本数。指定しない場合、特徴ベクトルが消費するメモリの最大 2 倍までしか使わないように本数が自動的に決定される。
      • build

        public void build()
        Build the index. in a way that at most 2x as much memory as the features vectors take is used.
      • knnSearch

        public void knnSearch​(Mat query,
                              Mat indices,
                              Mat dists,
                              int knn,
                              int search_k)
        Performs a K-nearest neighbor search for given query vector(s) using the index.
        引数:
        query - クエリベクトル。
        indices - 見つかった K 近傍のインデックスを格納する行列。省略可能。
        dists - 見つかった K 近傍までの距離を格納する行列。省略可能。
        knn - 探索する最近傍の数。
        search_k - 調べるノード数の最大値。指定しない場合は trees x knn がデフォルトとなる。
      • knnSearch

        public void knnSearch​(Mat query,
                              Mat indices,
                              Mat dists,
                              int knn)
        Performs a K-nearest neighbor search for given query vector(s) using the index.
        引数:
        query - クエリベクトル。
        indices - 見つかった K 近傍のインデックスを格納する行列。省略可能。
        dists - 見つかった K 近傍までの距離を格納する行列。省略可能。
        knn - 探索する最近傍の数。
      • save

        public void save​(java.lang.String filename,
                         boolean prefault)
        Save the index to disk and loads it. After saving, no more vectors can be added.
        引数:
        filename - 保存するインデックスのファイル名。
        prefault - prefault を true に設定すると、ファイル全体をあらかじめメモリに読み込む (MAP_POPULATE 付きの mmap を使用)。デフォルトは false。
      • save

        public void save​(java.lang.String filename)
        Save the index to disk and loads it. After saving, no more vectors can be added.
        引数:
        filename - 保存するインデックスのファイル名。with MAP_POPULATE). Default is false.
      • load

        public void load​(java.lang.String filename,
                         boolean prefault)
        Loads (mmaps) an index from disk.
        引数:
        filename - 読み込むインデックスのファイル名。
        prefault - prefault を true に設定すると、ファイル全体をあらかじめメモリに読み込む (MAP_POPULATE 付きの mmap を使用)。デフォルトは false。
      • load

        public void load​(java.lang.String filename)
        Loads (mmaps) an index from disk.
        引数:
        filename - 読み込むインデックスのファイル名。with MAP_POPULATE). Default is false.
      • getTreeNumber

        public int getTreeNumber()
        Return the number of trees in the index.
        戻り値:
        自動生成
      • getItemNumber

        public int getItemNumber()
        Return the number of feature vectors in the index.
        戻り値:
        自動生成
      • setOnDiskBuild

        public boolean setOnDiskBuild​(java.lang.String filename)
        Prepare to build the index in the specified file instead of RAM (execute before adding items, no need to save after build)
        引数:
        filename - 構築するインデックスのファイル名。
        戻り値:
        自動生成
      • setSeed

        public void setSeed​(int seed)
        Initialize the random number generator with the given seed. Only necessary to pass this before adding the items. Will have no effect after calling build() or load().
        引数:
        seed - 乱数生成器に与えるシード。値は uint32_t の範囲内である必要がある。
      • create

        public static ANNIndex create​(int dim,
                                      int distType)
        Creates an instance of annoy index class with given parameters
        引数:
        dim - 特徴ベクトルの次元。
        distType - 2 つの特徴ベクトル間の距離を計算するための距離尺度。DIST_EUCLIDEAN, DIST_MANHATTAN, DIST_ANGULAR, DIST_HAMMING, DIST_DOTPRODUCT のいずれかを指定できる。
        戻り値:
        自動生成
      • create

        public static ANNIndex create​(int dim)
        Creates an instance of annoy index class with given parameters
        引数:
        dim - 特徴ベクトルの次元。DIST_MANHATTAN, DIST_ANGULAR, DIST_HAMMING, or DIST_DOTPRODUCT.
        戻り値:
        自動生成