コード例 #1
0
ファイル: Index.cs プロジェクト: zanker99/emgucv
 /// <summary>
 /// Release the unmanaged memory associated with this Flann Index
 /// </summary>
 protected override void DisposeObject()
 {
     if (_ptr != IntPtr.Zero)
     {
         FlannInvoke.cveFlannIndexRelease(ref _ptr);
     }
 }
コード例 #2
0
ファイル: Index.cs プロジェクト: zanker99/emgucv
 /// <summary>
 /// Performs a radius nearest neighbor search for multiple query points
 /// </summary>
 /// <param name="queries">The query points, one per row</param>
 /// <param name="indices">Indices of the nearest neighbors found</param>
 /// <param name="squareDistances">The square of the Eculidean distance between the neighbours</param>
 /// <param name="radius">The search radius</param>
 /// <param name="maxResults">The maximum number of results</param>
 /// <param name="checks">The number of times the tree(s) in the index should be recursively traversed. A
 /// higher value for this parameter would give better search precision, but also take more
 /// time. If automatic configuration was used when the index was created, the number of
 /// checks required to achieve the specified precision was also computed, in which case
 /// this parameter is ignored </param>
 /// <param name="eps">The search epsilon</param>
 /// <param name="sorted">If set to true, the search result is sorted</param>
 /// <returns>The number of points in the search radius</returns>
 public int RadiusSearch(IInputArray queries, IOutputArray indices, IOutputArray squareDistances, double radius, int maxResults, int checks = 32, float eps = 0, bool sorted = true)
 {
     using (InputArray iaQueries = queries.GetInputArray())
         using (OutputArray oaIndicies = indices.GetOutputArray())
             using (OutputArray oaSquareDistances = squareDistances.GetOutputArray())
                 return(FlannInvoke.cveFlannIndexRadiusSearch(_ptr, iaQueries, oaIndicies, oaSquareDistances, radius, maxResults, checks, eps, sorted));
 }
コード例 #3
0
ファイル: Index.cs プロジェクト: zanker99/emgucv
        /*
         * /// <summary>
         * /// Create an auto-tuned flann index
         * /// </summary>
         * /// <param name="values">A row by row matrix of descriptors</param>
         * /// <param name="targetPrecision">Precision desired, use 0.9 if not sure</param>
         * /// <param name="buildWeight">build tree time weighting factor, use 0.01 if not sure</param>
         * /// <param name="memoryWeight">index memory weighting factor, use 0 if not sure</param>
         * /// <param name="sampleFraction">what fraction of the dataset to use for autotuning, use 0.1 if not sure</param>
         * public Index(IInputArray values, float targetPrecision, float buildWeight, float memoryWeight, float sampleFraction)
         * {
         * using (InputArray iaValues = values.GetInputArray())
         *    _ptr = CvFlannIndexCreateAutotuned(iaValues, targetPrecision, buildWeight, memoryWeight, sampleFraction);
         * }*/
        #endregion

        /// <summary>
        /// Perform k-nearest-neighbours (KNN) search
        /// </summary>
        /// <param name="queries">A row by row matrix of descriptors to be query for nearest neighbours</param>
        /// <param name="indices">The result of the indices of the k-nearest neighbours</param>
        /// <param name="squareDistances">The square of the Eculidean distance between the neighbours</param>
        /// <param name="knn">Number of nearest neighbors to search for</param>
        /// <param name="checks">The number of times the tree(s) in the index should be recursively traversed. A
        /// higher value for this parameter would give better search precision, but also take more
        /// time. If automatic configuration was used when the index was created, the number of
        /// checks required to achieve the specified precision was also computed, in which case
        /// this parameter is ignored </param>
        /// <param name="eps">The search epsilon</param>
        /// <param name="sorted">If set to true, the search result is sorted</param>
        public void KnnSearch(IInputArray queries, IOutputArray indices, IOutputArray squareDistances, int knn, int checks = 32, float eps = 0, bool sorted = true)
        {
            using (InputArray iaQueries = queries.GetInputArray())
                using (OutputArray oaIndices = indices.GetOutputArray())
                    using (OutputArray oaSquareDistances = squareDistances.GetOutputArray())
                        FlannInvoke.cveFlannIndexKnnSearch(_ptr, iaQueries, oaIndices, oaSquareDistances, knn, checks, eps, sorted);
        }
コード例 #4
0
 /// <summary>
 /// Release all the memory associated with this IndexParam
 /// </summary>
 protected override void DisposeObject()
 {
     if (IntPtr.Zero != _ptr)
     {
         FlannInvoke.cveKDTreeIndexParamsRelease(ref _ptr);
         _indexParamPtr = IntPtr.Zero;
     }
 }
コード例 #5
0
 /// <summary>
 /// Release all the memory associated with this IndexParam
 /// </summary>
 protected override void DisposeObject()
 {
     if (IntPtr.Zero != _ptr)
     {
         FlannInvoke.cveHierarchicalClusteringIndexParamsRelease(ref _ptr);
         _indexParamPtr = IntPtr.Zero;
     }
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HierarchicalClusteringIndexParams"/>.
 /// </summary>
 /// <param name="branching">branching</param>
 /// <param name="centersInit">Center initialization method</param>
 /// <param name="trees">Trees</param>
 /// <param name="leafSize">Leaf Size</param>
 public HierarchicalClusteringIndexParams(
     int branching = 32,
     Flann.CenterInitType centersInit = CenterInitType.Random,
     int trees    = 4,
     int leafSize = 100)
 {
     _ptr = FlannInvoke.cveHierarchicalClusteringIndexParamsCreate(ref _indexParamPtr, branching, centersInit, trees, leafSize);
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LshIndexParams"/> class.
 /// </summary>
 /// <param name="tableNumber">The number of hash tables to use (between 10 and 30 usually).</param>
 /// <param name="keySize">The size of the hash key in bits (between 10 and 20 usually).</param>
 /// <param name="multiProbeLevel">The number of bits to shift to check for neighboring buckets (0 is regular LSH, 2 is recommended).</param>
 public LshIndexParams(int tableNumber, int keySize, int multiProbeLevel)
 {
     _ptr = FlannInvoke.cveLshIndexParamsCreate(ref _indexParamPtr, tableNumber, keySize, multiProbeLevel);
 }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KdTreeIndexParams"/> class.
 /// </summary>
 /// <param name="trees">The number of parallel kd-trees to use. Good values are in the range [1..16]</param>
 public KdTreeIndexParams(int trees = 4)
 {
     _ptr = FlannInvoke.cveKDTreeIndexParamsCreate(ref _indexParamPtr, trees);
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchParams"/> class.
 /// </summary>
 /// <param name="checks">how many leafs to visit when searching for neighbors (-1 for unlimited)</param>
 /// <param name="eps">Search for eps-approximate neighbors </param>
 /// <param name="sorted">Only for radius search, require neighbors sorted by distance </param>
 public SearchParams(int checks = 32, float eps = 0, bool sorted = true)
 {
     _ptr = FlannInvoke.cveSearchParamsCreate(ref _indexParamPtr, checks, eps, sorted);
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinearIndexParams"/> class.
 /// </summary>
 public LinearIndexParams()
 {
     _ptr = FlannInvoke.cveLinearIndexParamsCreate(ref _indexParamPtr);
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AutotunedIndexParams"/> class.
 /// </summary>
 /// <param name="targetPrecision"> Is a number between 0 and 1 specifying the percentage of the approximate nearest-neighbor searches that return the exact nearest-neighbor. Using a higher value for this parameter gives more accurate results, but the search takes longer. The optimum value usually depends on the application.</param>
 /// <param name="buildWeight">Specifies the importance of the index build time reported to the nearest-neighbor search time. In some applications it’s acceptable for the index build step to take a long time if the subsequent searches in the index can be performed very fast. In other applications it’s required that the index be build as fast as possible even if that leads to slightly longer search times.</param>
 /// <param name="memoryWeight">Is used to specify the trade off between time (index build time and search time) and memory used by the index. A value less than 1 gives more importance to the time spent and a value greater than 1 gives more importance to the memory usage.</param>
 /// <param name="sampleFraction">Is a number between 0 and 1 indicating what fraction of the dataset to use in the automatic parameter configuration algorithm. Running the algorithm on the full dataset gives the most accurate results, but for very large datasets can take longer than desired. In such case using just a fraction of the data helps speeding up this algorithm while still giving good approximations of the optimum parameters.</param>
 public AutotunedIndexParams(float targetPrecision = 0.8f, float buildWeight = 0.01f, float memoryWeight = 0, float sampleFraction = 0.1f)
 {
     _ptr = FlannInvoke.cveAutotunedIndexParamsCreate(ref _indexParamPtr, targetPrecision, buildWeight, memoryWeight, sampleFraction);
 }
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompositeIndexParams"/> class.
 /// </summary>
 /// <param name="trees">The number of parallel kd-trees to use. Good values are in the range [1..16]</param>
 /// <param name="branching">The branching factor to use for the hierarchical k-means tree</param>
 /// <param name="iterations"> The maximum number of iterations to use in the k-means clustering stage when building the k-means tree. A value of -1 used here means that the k-means clustering should be iterated until convergence</param>
 /// <param name="centersInit">The algorithm to use for selecting the initial centers when performing a k-means clustering step. The possible values are CENTERS_RANDOM (picks the initial cluster centers randomly), CENTERS_GONZALES (picks the initial centers using Gonzales’ algorithm) and CENTERS_KMEANSPP (picks the initial centers using the algorithm suggested in arthur_kmeanspp_2007 )</param>
 /// <param name="cbIndex">This parameter (cluster boundary index) influences the way exploration is performed in the hierarchical kmeans tree. When cb_index is zero the next kmeans domain to be explored is chosen to be the one with the closest center. A value greater then zero also takes into account the size of the domain.</param>
 public CompositeIndexParams(int trees = 4, int branching = 32, int iterations = 11, Flann.CenterInitType centersInit = CenterInitType.Random, float cbIndex = 0.2f)
 {
     _ptr = FlannInvoke.cveCompositeIndexParamsCreate(ref _indexParamPtr, trees, branching, iterations, centersInit, cbIndex);
 }
コード例 #13
0
ファイル: Index.cs プロジェクト: zanker99/emgucv
 /// <summary>
 /// Create a flann index
 /// </summary>
 /// <param name="values">A row by row matrix of descriptors</param>
 /// <param name="ip">The index parameter</param>
 /// <param name="distType">The distance type</param>
 public Index(IInputArray values, IIndexParams ip, DistType distType = DistType.L2)
 {
     using (InputArray iaValues = values.GetInputArray())
         _ptr = FlannInvoke.cveFlannIndexCreate(iaValues, ip.IndexParamPtr, distType);
 }