예제 #1
0
        /// <summary>
        /// 1次元ヒストグラムの指定されたビンの値を返す (cvQueryHistValue_1D相当).
        /// 疎なヒストグラムの場合で,既にビンが存在している場合以外は,この関数が新しいビンを作成し,0にセットする.
        /// </summary>
        /// <param name="idx0">要素インデックスの,0を基準とした第1成分.</param>
        /// <returns>指定した要素の値</returns>
#else
        /// <summary>
        /// Queries value of histogram bin.
        /// </summary>
        /// <param name="idx0">1st index of the bin.</param>
        /// <returns></returns>
#endif
        public double QueryValue1D(Int32 idx0)
        {
            return(Cv.QueryHistValue_1D(this, idx0));
        }
예제 #2
0
        /// <summary>
        /// ヒストグラムのビンの最小値/最大値を求める (cvGetMinMaxHistValue相当).
        /// 同じ値の最大値や最小値が複数存在する場合,辞書順に並べたときに最も先頭になるインデックスが返される.
        /// </summary>
        /// <param name="minValue">ヒストグラムの最小値の出力</param>
        /// <param name="maxValue">ヒストグラムの最大値の出力</param>
#else
        /// <summary>
        /// Finds minimum and maximum histogram bins.
        /// </summary>
        /// <param name="minValue">The minimum value of the histogram.</param>
        /// <param name="maxValue">The maximum value of the histogram.</param>
#endif
        public void GetMinMaxValue(out float minValue, out float maxValue)
        {
            Cv.GetMinMaxHistValue(this, out minValue, out maxValue);
        }
예제 #3
0
        /// <summary>
        /// ヒストグラムの正規化を行う (cvNormalizeHist相当).
        /// ビンの値の合計が factor に等しくなるようにスケーリングする事で,ヒストグラムのビンを正規化する.
        /// </summary>
        /// <param name="factor">正規化係数</param>
#else
        /// <summary>
        /// Normalizes the histogram bins by scaling them, such that the sum of the bins becomes equal to factor.
        /// </summary>
        /// <param name="factor">Threshold level. </param>
#endif
        public void Normalize(double factor)
        {
            Cv.NormalizeHist(this, factor);
        }
예제 #4
0
        /// <summary>
        /// 1次元ヒストグラムの指定されたビンへのポインタを返す.
        /// 疎なヒストグラムの場合で,既にビンが存在している場合以外は,この関数が新しいビンを作成し,0にセットする.
        /// </summary>
        /// <param name="idx0">要素インデックスの,0を基準とした第1成分.</param>
        /// <returns>指定した要素のポインタ</returns>
#else
        /// <summary>
        /// Returns pointer to histogram bin.
        /// </summary>
        /// <param name="idx0">1st index of the bin.</param>
        /// <returns></returns>
#endif
        public IntPtr GetValue1D(int idx0)
        {
            return(Cv.GetHistValue_1D(this, idx0));
        }
예제 #5
0
        /// <summary>
        /// 3次元ヒストグラムの指定されたビンへのポインタを返す.
        /// 疎なヒストグラムの場合で,既にビンが存在している場合以外は,この関数が新しいビンを作成し,0にセットする.
        /// </summary>
        /// <param name="idx0">要素インデックスの,0を基準とした第1成分.</param>
        /// <param name="idx1">要素インデックスの,0を基準とした第2成分.</param>
        /// <param name="idx2">要素インデックスの,0を基準とした第3成分.</param>
        /// <returns>指定した要素のポインタ</returns>
#else
        /// <summary>
        /// Returns pointer to histogram bin.
        /// </summary>
        /// <param name="idx0">1st index of the bin.</param>
        /// <param name="idx1">2nd index of the bin.</param>
        /// <param name="idx2">3rd index of the bin.</param>
        /// <returns></returns>
#endif
        public IntPtr GetValue3D(int idx0, int idx1, int idx2)
        {
            return(Cv.GetHistValue_3D(this, idx0, idx1, idx2));
        }
예제 #6
0
        /// <summary>
        /// 一つのヒストグラムをもう一方のヒストグラムで割る (cvCalcProbDensity相当).
        /// </summary>
        /// <param name="hist1">一番目のヒストグラム(除数)</param>
        /// <param name="hist2">二番目のヒストグラム</param>
        /// <param name="dstHist">出力ヒストグラム</param>
#else
        /// <summary>
        /// Divides one histogram by another.
        /// </summary>
        /// <param name="hist1">first histogram (the divisor). </param>
        /// <param name="hist2">second histogram. </param>
        /// <param name="dstHist">destination histogram. </param>
#endif
        public static void CalcProbDensity(CvHistogram hist1, CvHistogram hist2, CvHistogram dstHist)
        {
            Cv.CalcProbDensity(hist1, hist2, dstHist);
        }
예제 #7
0
        /// <summary>
        /// ヒストグラムをクリアする (cvClearHist).
        /// 密なヒストグラムの場合,全てのヒストグラムのビンを0にセットする, また疎なヒストグラムの場合は,すべてのヒストグラムのビンを削除する.
        /// </summary>
#else
        /// <summary>
        /// Sets all histogram bins to 0 in case of dense histogram and removes all histogram bins in case of sparse array.
        /// </summary>
#endif
        public void Clear()
        {
            Cv.ClearHist(this);
        }
예제 #8
0
        /// <summary>
        /// ヒストグラムの閾値処理を行う (cvThreshHist相当).
        /// 指定した閾値以下のヒストグラムのビンをクリアする.
        /// </summary>
        /// <param name="threshold">閾値レベル</param>
#else
        /// <summary>
        /// Clears histogram bins that are below the specified threshold.
        /// </summary>
        /// <param name="threshold">Threshold level. </param>
#endif
        public void Thresh(double threshold)
        {
            Cv.ThreshHist(this, threshold);
        }
예제 #9
0
        /// <summary>
        /// 画像群のヒストグラムを計算する (cvCalcHist相当).
        /// ヒストグラムのビンを増加(インクリメント)するために用いられるタプルの各要素は, 対応する入力画像群の同じ場所から取り出される.
        /// </summary>
        /// <param name="image">入力画像群.全て同じサイズ・タイプ.</param>
#else
        /// <summary>
        /// Calculates the histogram of single-channel images.
        /// The elements of a tuple that is used to increment a histogram bin are taken at the same location from the corresponding input images.
        /// </summary>
        /// <param name="image">Source images, all are of the same size and type.</param>
#endif
        public void Calc(IplImage[] image)
        {
            Cv.CalcHist(image, this);
        }
예제 #10
0
        /// <summary>
        /// ヒストグラムのビンのレンジをセットする (cvSetHistBinRanges相当).
        /// </summary>
        /// <param name="ranges">ビンのレンジの配列</param>
#else
        /// <summary>
        /// Sets bounds of histogram bins
        /// </summary>
        /// <param name="ranges">Array of bin ranges arrays.</param>
#endif
        public void SetBinRanges(float[][] ranges)
        {
            Cv.SetHistBinRanges(this, ranges);
        }
예제 #11
0
        /// <summary>
        /// ヒストグラムのビンのレンジをセットする (cvSetHistBinRanges相当).
        /// </summary>
        /// <param name="ranges">ビンのレンジの配列</param>
        /// <param name="uniform">一様性フラグ</param>
#else
        /// <summary>
        /// Sets bounds of histogram bins
        /// </summary>
        /// <param name="ranges">Array of bin ranges arrays.</param>
        /// <param name="uniform">Uniformity flag.</param>
#endif
        public void SetBinRanges(float[][] ranges, bool uniform)
        {
            Cv.SetHistBinRanges(this, ranges, uniform);
        }
예제 #12
0
        /// <summary>
        /// n次元ヒストグラムの指定されたビンの値を返す (cvQueryHistValue_ND相当).
        /// 疎なヒストグラムの場合で,既にビンが存在している場合以外は,この関数が新しいビンを作成し,0にセットする.
        /// </summary>
        /// <param name="idx">要素インデックスの配列(可変長引数)</param>
        /// <returns>指定した要素の値</returns>
#else
        /// <summary>
        /// Queries value of histogram bin.
        /// </summary>
        /// <param name="idx">Array of indices.</param>
        /// <returns></returns>
#endif
        public double QueryValueND(params int[] idx)
        {
            return(Cv.QueryHistValue_nD(this, idx));
        }
예제 #13
0
        /// <summary>
        /// 3次元ヒストグラムの指定されたビンの値を返す (cvQueryHistValue_3D相当).
        /// 疎なヒストグラムの場合で,既にビンが存在している場合以外は,この関数が新しいビンを作成し,0にセットする.
        /// </summary>
        /// <param name="idx0">要素インデックスの,0を基準とした第1成分.</param>
        /// <param name="idx1">要素インデックスの,0を基準とした第2成分.</param>
        /// <param name="idx2">要素インデックスの,0を基準とした第3成分.</param>
        /// <returns>指定した要素の値</returns>
#else
        /// <summary>
        /// Queries value of histogram bin.
        /// </summary>
        /// <param name="idx0">1st index of the bin.</param>
        /// <param name="idx1">2nd index of the bin.</param>
        /// <param name="idx2">3rd index of the bin.</param>
        /// <returns></returns>
#endif
        public double QueryValue3D(Int32 idx0, Int32 idx1, Int32 idx2)
        {
            return(Cv.QueryHistValue_3D(this, idx0, idx1, idx2));
        }
예제 #14
0
        /// <summary>
        /// 2次元ヒストグラムの指定されたビンの値を返す (cvQueryHistValue_2D相当).
        /// 疎なヒストグラムの場合で,既にビンが存在している場合以外は,この関数が新しいビンを作成し,0にセットする.
        /// </summary>
        /// <param name="idx0">要素インデックスの,0を基準とした第1成分.</param>
        /// <param name="idx1">要素インデックスの,0を基準とした第2成分.</param>
        /// <returns>指定した要素の値</returns>
#else
        /// <summary>
        /// Queries value of histogram bin.
        /// </summary>
        /// <param name="idx0">1st index of the bin.</param>
        /// <param name="idx1">2nd index of the bin.</param>
        /// <returns></returns>
#endif
        public double QueryValue2D(Int32 idx0, Int32 idx1)
        {
            return(Cv.QueryHistValue_2D(this, idx0, idx1));
        }
예제 #15
0
        /// <summary>
        /// ヒストグラムの比較に基づき画像内部でのテンプレート位置を求める
        /// </summary>
        /// <param name="image">入力画像群( CvMat** 形式でも構わない).すべて同じサイズ.</param>
        /// <param name="dst">出力画像</param>
        /// <param name="patchSize">入力画像群上をスライドさせるテンプレートのサイズ</param>
        /// <param name="method">比較方法.値は関数 cvCompareHist に渡される(この関数に関する記述を参照)</param>
        /// <param name="factor">ヒストグラムの正規化係数.出力画像の正規化スケールに影響する.値に確信がない場合は,1にする.</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Locates a template within image by histogram comparison
        /// </summary>
        /// <param name="image">Source images (though you may pass CvMat** as well), all are of the same size and type </param>
        /// <param name="dst">Destination image. </param>
        /// <param name="patchSize">Size of patch slid though the source images. </param>
        /// <param name="method">Compasion method, passed to cvCompareHist (see description of that function). </param>
        /// <param name="factor">Normalization factor for histograms, will affect normalization scale of destination image, pass 1. if unsure. </param>
        /// <returns></returns>
#endif
        public void CalcBackProjectPatch(CvArr[] image, CvArr dst, CvSize patchSize, HistogramComparison method, float factor)
        {
            Cv.CalcArrBackProjectPatch(image, dst, patchSize, this, method, factor);
        }
예제 #16
0
        /// <summary>
        /// 画像群のヒストグラムを計算する (cvCalcHist相当).
        /// ヒストグラムのビンを増加(インクリメント)するために用いられるタプルの各要素は, 対応する入力画像群の同じ場所から取り出される.
        /// </summary>
        /// <param name="image">入力画像群.全て同じサイズ・タイプ.</param>
        /// <param name="accumulate">計算フラグ.セットされている場合は,ヒストグラムは処理前には最初にクリアされない. </param>
#else
        /// <summary>
        /// Calculates the histogram of single-channel images.
        /// The elements of a tuple that is used to increment a histogram bin are taken at the same location from the corresponding input images.
        /// </summary>
        /// <param name="image">Source images, all are of the same size and type.</param>
        /// <param name="accumulate">Accumulation flag. If it is set, the histogram is not cleared in the beginning. This feature allows user to compute a single histogram from several images, or to update the histogram online. </param>
#endif
        public void Calc(IplImage[] image, bool accumulate)
        {
            Cv.CalcHist(image, this, accumulate, null);
        }
예제 #17
0
        /// <summary>
        /// Calculates bayesian probabilistic histograms
        /// </summary>
        /// <param name="src"></param>
        /// <param name="dst"></param>
#else
        /// <summary>
        /// Calculates bayesian probabilistic histograms
        /// </summary>
        /// <param name="src"></param>
        /// <param name="dst"></param>
#endif
        public static void CalcBayesianProb(CvHistogram[] src, CvHistogram[] dst)
        {
            Cv.CalcBayesianProb(src, dst);
        }
예제 #18
0
        /// <summary>
        /// 画像群のヒストグラムを計算する (cvCalcHist相当).
        /// ヒストグラムのビンを増加(インクリメント)するために用いられるタプルの各要素は, 対応する入力画像群の同じ場所から取り出される.
        /// </summary>
        /// <param name="image">入力画像群.全て同じサイズ・タイプ.</param>
        /// <param name="accumulate">計算フラグ.セットされている場合は,ヒストグラムは処理前には最初にクリアされない. </param>
        /// <param name="mask">処理マスク.入力画像中のどのピクセルをカウントするかを決定する.</param>
#else
        /// <summary>
        /// Calculates the histogram of single-channel images.
        /// The elements of a tuple that is used to increment a histogram bin are taken at the same location from the corresponding input images.
        /// </summary>
        /// <param name="image">Source images, all are of the same size and type.</param>
        /// <param name="accumulate">Accumulation flag. If it is set, the histogram is not cleared in the beginning. This feature allows user to compute a single histogram from several images, or to update the histogram online. </param>
        /// <param name="mask">The operation mask, determines what pixels of the source images are counted. </param>
#endif
        public void Calc(IplImage[] image, bool accumulate, CvArr mask)
        {
            Cv.CalcHist(image, this, accumulate, mask);
        }
예제 #19
0
        /// <summary>
        /// 一つのヒストグラムをもう一方のヒストグラムで割る (cvCalcProbDensity相当).
        /// </summary>
        /// <param name="hist1">一番目のヒストグラム(除数)</param>
        /// <param name="hist2">二番目のヒストグラム</param>
        /// <param name="dstHist">出力ヒストグラム</param>
        /// <param name="scale">出力ヒストグラムのスケール係数</param>
#else
        /// <summary>
        /// Divides one histogram by another.
        /// </summary>
        /// <param name="hist1">first histogram (the divisor). </param>
        /// <param name="hist2">second histogram. </param>
        /// <param name="dstHist">destination histogram. </param>
        /// <param name="scale">scale factor for the destination histogram. </param>
#endif
        public static void CalcProbDensity(CvHistogram hist1, CvHistogram hist2, CvHistogram dstHist, double scale)
        {
            Cv.CalcProbDensity(hist1, hist2, dstHist, scale);
        }
예제 #20
0
        /// <summary>
        /// 配列群のヒストグラムを計算する (cvCalcArrHist相当).
        /// ヒストグラムのビンを増加(インクリメント)するために用いられるタプルの各要素は, 対応する入力画像群の同じ場所から取り出される.
        /// </summary>
        /// <param name="arr">入力配列群.全て同じサイズ・タイプ.</param>
#else
        /// <summary>
        /// Calculates the histogram of single-channel images.
        /// The elements of a tuple that is used to increment a histogram bin are taken at the same location from the corresponding input images.
        /// </summary>
        /// <param name="arr">Source images (though, you may pass CvMat** as well), all are of the same size and type.</param>
#endif
        public void CalcArr(CvArr[] arr)
        {
            Cv.CalcArrHist(arr, this);
        }
예제 #21
0
        /// <summary>
        /// ヒストグラムのコピーを作成する (cvCopyHist相当).
        /// コピー先のヒストグラムへのポインタdstがnullの場合は,srcと同じサイズの新しいヒストグラムが作成される.
        /// それ以外の場合は,二つのヒストグラムは同一タイプ,サイズでないといけない.
        /// この関数はコピー元のヒストグラムのビンの値を,コピー先にコピーし, src内に定義されているのと同じビンの値域をセットする.
        /// </summary>
        /// <param name="dst">コピー先のヒストグラムへのポインタ. </param>
#else
        /// <summary>
        /// Makes a copy of the histogram.
        /// If the second histogram dst is null, a new histogram of the same size as src is created.
        /// Otherwise, both histograms must have equal types and sizes.
        /// Then the function copies the source histogram bins values to destination histogram and sets the same bin values ranges as in src.
        /// </summary>
        /// <param name="dst">Reference to destination histogram. </param>
#endif
        public void Copy(CvHistogram dst)
        {
            Cv.CopyHist(this, ref dst);
        }
예제 #22
0
        /// <summary>
        /// 配列群のヒストグラムを計算する (cvCalcArrHist相当).
        /// ヒストグラムのビンを増加(インクリメント)するために用いられるタプルの各要素は, 対応する入力画像群の同じ場所から取り出される.
        /// </summary>
        /// <param name="arr">入力配列群.全て同じサイズ・タイプ.</param>
        /// <param name="accumulate">計算フラグ.セットされている場合は,ヒストグラムは処理前には最初にクリアされない. </param>
#else
        /// <summary>
        /// Calculates the histogram of single-channel images.
        /// The elements of a tuple that is used to increment a histogram bin are taken at the same location from the corresponding input images.
        /// </summary>
        /// <param name="arr">Source images (though, you may pass CvMat** as well), all are of the same size and type.</param>
        /// <param name="accumulate">Accumulation flag. If it is set, the histogram is not cleared in the beginning. This feature allows user to compute a single histogram from several images, or to update the histogram online. </param>
#endif
        public void CalcArr(CvArr[] arr, bool accumulate)
        {
            Cv.CalcArrHist(arr, this, accumulate, null);
        }
예제 #23
0
        /// <summary>
        /// 2次元ヒストグラムの指定されたビンへのポインタを返す.
        /// 疎なヒストグラムの場合で,既にビンが存在している場合以外は,この関数が新しいビンを作成し,0にセットする.
        /// </summary>
        /// <param name="idx0">要素インデックスの,0を基準とした第1成分.</param>
        /// <param name="idx1">要素インデックスの,0を基準とした第2成分.</param>
        /// <returns>指定した要素のポインタ</returns>
#else
        /// <summary>
        /// Returns pointer to histogram bin.
        /// </summary>
        /// <param name="idx0">1st index of the bin.</param>
        /// <param name="idx1">2rd index of the bin.</param>
        /// <returns></returns>
#endif
        public IntPtr GetValue2D(int idx0, int idx1)
        {
            return(Cv.GetHistValue_2D(this, idx0, idx1));
        }
예제 #24
0
        /// <summary>
        /// 配列群のヒストグラムを計算する (cvCalcArrHist相当).
        /// ヒストグラムのビンを増加(インクリメント)するために用いられるタプルの各要素は, 対応する入力画像群の同じ場所から取り出される.
        /// </summary>
        /// <param name="arr">入力配列群.全て同じサイズ・タイプ.</param>
        /// <param name="accumulate">計算フラグ.セットされている場合は,ヒストグラムは処理前には最初にクリアされない. </param>
        /// <param name="mask">処理マスク.入力画像中のどのピクセルをカウントするかを決定する.</param>
#else
        /// <summary>
        /// Calculates the histogram of single-channel images.
        /// The elements of a tuple that is used to increment a histogram bin are taken at the same location from the corresponding input images.
        /// </summary>
        /// <param name="arr">Source images (though, you may pass CvMat** as well), all are of the same size and type.</param>
        /// <param name="accumulate">Accumulation flag. If it is set, the histogram is not cleared in the beginning. This feature allows user to compute a single histogram from several images, or to update the histogram online. </param>
        /// <param name="mask">The operation mask, determines what pixels of the source images are counted. </param>
#endif
        public void CalcArr(CvArr[] arr, bool accumulate, CvArr mask)
        {
            Cv.CalcArrHist(arr, this, accumulate, mask);
        }
예제 #25
0
        /// <summary>
        /// n次元ヒストグラムの指定されたビンへのポインタを返す.
        /// 疎なヒストグラムの場合で,既にビンが存在している場合以外は,この関数が新しいビンを作成し,0にセットする.
        /// </summary>
        /// <param name="idx">要素インデックスの配列(可変長引数)</param>
        /// <returns>指定した要素のポインタ</returns>
#else
        /// <summary>
        /// Returns pointer to histogram bin.
        /// </summary>
        /// <param name="idx">Indices of the bin. </param>
        /// <returns></returns>
#endif
        public IntPtr GetValueND(params int[] idx)
        {
            return(Cv.GetHistValue_nD(this, idx));
        }
예제 #26
0
        /// <summary>
        /// バックプロジェクションの計算を行う
        /// </summary>
        /// <param name="image">入力画像群</param>
        /// <param name="backProject">出力のバックプロジェクション画像.入力画像群と同じタイプ.</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Calculates back projection
        /// </summary>
        /// <param name="image">Source images (though you may pass CvMat** as well), all are of the same size and type </param>
        /// <param name="backProject">Destination back projection image of the same type as the source images. </param>
        /// <returns></returns>
#endif
        public void CalcArrBackProject(CvArr[] image, CvArr backProject)
        {
            Cv.CalcArrBackProject(image, backProject, this);
        }
예제 #27
0
        /// <summary>
        /// ヒストグラムのビンの最小値/最大値とそれらの場所を求める (cvGetMinMaxHistValue相当).
        /// 同じ値の最大値や最小値が複数存在する場合,辞書順に並べたときに最も先頭になるインデックスが返される.
        /// </summary>
        /// <param name="minValue">ヒストグラムの最小値の出力</param>
        /// <param name="maxValue">ヒストグラムの最大値の出力</param>
        /// <param name="minIdx">最小値の配列中のインデックスの出力</param>
        /// <param name="maxIdx">最大値の配列中のインデックスの出力</param>
#else
        /// <summary>
        /// Finds minimum and maximum histogram bins.
        /// </summary>
        /// <param name="minValue">The minimum value of the histogram.</param>
        /// <param name="maxValue">The maximum value of the histogram.</param>
        /// <param name="minIdx">The array of coordinates for minimum.</param>
        /// <param name="maxIdx">The array of coordinates for maximum.</param>
#endif
        public void GetMinMaxValue(out float minValue, out float maxValue, out int[] minIdx, out int[] maxIdx)
        {
            Cv.GetMinMaxHistValue(this, out minValue, out maxValue, out minIdx, out maxIdx);
        }
예제 #28
0
        /// <summary>
        /// バックプロジェクションの計算を行う
        /// </summary>
        /// <param name="image">入力画像群</param>
        /// <param name="backProject">出力のバックプロジェクション画像.入力画像群と同じタイプ.</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Calculates back projection
        /// </summary>
        /// <param name="image">Source images (though you may pass CvMat** as well), all are of the same size and type </param>
        /// <param name="backProject">Destination back projection image of the same type as the source images. </param>
        /// <returns></returns>
#endif
        public void CalcBackProject(IplImage[] image, CvArr backProject)
        {
            Cv.CalcBackProject(image, backProject, this);
        }
예제 #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="m1"></param>
        /// <param name="m2"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public override unsafe int RunKernel(CvMat m1, CvMat m2, CvMat model)
        {
            int           count = m1.Rows * m1.Cols;
            CvPoint2D64f *M     = (CvPoint2D64f *)m1.DataByte;
            CvPoint2D64f *m     = (CvPoint2D64f *)m2.DataByte;

            double *LtL         = stackalloc double[9 * 9],
                   W            = stackalloc double[9 * 9],
                   V            = stackalloc double[9 * 9];
            CvMat        _LtL   = new CvMat(9, 9, MatrixType.F64C1, new IntPtr(LtL));
            CvMat        matW   = new CvMat(9, 9, MatrixType.F64C1, new IntPtr(W));
            CvMat        matV   = new CvMat(9, 9, MatrixType.F64C1, new IntPtr(V));
            CvMat        _H0    = new CvMat(3, 3, MatrixType.F64C1, new IntPtr(V + (9 * 8)));
            CvMat        _Htemp = new CvMat(3, 3, MatrixType.F64C1, new IntPtr(V + (9 * 7)));
            CvPoint2D64f cM     = new CvPoint2D64f(0, 0),
                         cm     = new CvPoint2D64f(0, 0),
                         sM     = new CvPoint2D64f(0, 0),
                         sm     = new CvPoint2D64f(0, 0);

            for (int i = 0; i < count; i++)
            {
                cm.X += m[i].X; cm.Y += m[i].Y;
                cM.X += M[i].X; cM.Y += M[i].Y;
            }

            cm.X /= count; cm.Y /= count;
            cM.X /= count; cM.Y /= count;

            for (int i = 0; i < count; i++)
            {
                sm.X += Math.Abs(m[i].X - cm.X);
                sm.Y += Math.Abs(m[i].Y - cm.Y);
                sM.X += Math.Abs(M[i].X - cM.X);
                sM.Y += Math.Abs(M[i].Y - cM.Y);
            }

            if (Math.Abs(sm.X) < double.Epsilon || Math.Abs(sm.Y) < double.Epsilon ||
                Math.Abs(sM.X) < double.Epsilon || Math.Abs(sM.Y) < double.Epsilon)
            {
                return(0);
            }
            sm.X = count / sm.X; sm.Y = count / sm.Y;
            sM.X = count / sM.X; sM.Y = count / sM.Y;

            double[] invHnorm = new double[9] {
                1.0 / sm.X, 0, cm.X, 0, 1.0 / sm.Y, cm.Y, 0, 0, 1
            };
            double[] Hnorm2 = new double[9] {
                sM.X, 0, -cM.X * sM.X, 0, sM.Y, -cM.Y * sM.Y, 0, 0, 1
            };
            CvMat _invHnorm = new CvMat(3, 3, MatrixType.F64C1, invHnorm);
            CvMat _Hnorm2   = new CvMat(3, 3, MatrixType.F64C1, Hnorm2);

            Cv.Zero(_LtL);
            for (int i = 0; i < count; i++)
            {
                double   x = (m[i].X - cm.X) * sm.X, y = (m[i].Y - cm.Y) * sm.Y;
                double   X = (M[i].X - cM.X) * sM.X, Y = (M[i].Y - cM.Y) * sM.Y;
                double[] Lx = { X, Y, 1, 0, 0, 0, -x * X, -x * Y, -x };
                double[] Ly = { 0, 0, 0, X, Y, 1, -y * X, -y * Y, -y };
                int      j, k;
                for (j = 0; j < 9; j++)
                {
                    for (k = j; k < 9; k++)
                    {
                        LtL[j * 9 + k] += Lx[j] * Lx[k] + Ly[j] * Ly[k];
                    }
                }
            }
            Cv.CompleteSymm(_LtL);

            //cvSVD( &_LtL, &matW, 0, &matV, CV_SVD_MODIFY_A + CV_SVD_V_T );
            Cv.EigenVV(_LtL, matV, matW);
            Cv.MatMul(_invHnorm, _H0, _Htemp);
            Cv.MatMul(_Htemp, _Hnorm2, _H0);
            Cv.ConvertScale(_H0, model, 1.0 / _H0.DataDouble[8]);

            return(1);
        }
예제 #30
0
        /// <summary>
        /// Remove vectors from LSH, as addressed by given indices.
        /// </summary>
        /// <param name="indices"></param>
#else
        /// <summary>
        /// Remove vectors from LSH, as addressed by given indices.
        /// </summary>
        /// <param name="indices"></param>
#endif
        public void Remove(CvMat indices)
        {
            Cv.LSHRemove(this, indices);
        }