Пример #1
0
        /// <summary>
        /// サンプル集合からガウス混合パラメータを推定する
        /// </summary>
        /// <param name="samples"></param>
        /// <param name="means0"></param>
        /// <param name="covs0"></param>
        /// <param name="weights0"></param>
        /// <param name="logLikelihoods"></param>
        /// <param name="labels"></param>
        /// <param name="probs"></param>
#else
        /// <summary>
        /// Estimates Gaussian mixture parameters from the sample set
        /// </summary>
        /// <param name="samples"></param>
        /// <param name="means0"></param>
        /// <param name="covs0"></param>
        /// <param name="weights0"></param>
        /// <param name="logLikelihoods"></param>
        /// <param name="labels"></param>
        /// <param name="probs"></param>
#endif
        public virtual bool TrainE(
            InputArray samples,
            InputArray means0,
            InputArray covs0           = null,
            InputArray weights0        = null,
            OutputArray logLikelihoods = null,
            OutputArray labels         = null,
            OutputArray probs          = null)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("EM");
            }
            if (samples == null)
            {
                throw new ArgumentNullException("samples");
            }
            if (means0 == null)
            {
                throw new ArgumentNullException("means0");
            }
            samples.ThrowIfDisposed();
            means0.ThrowIfDisposed();

            if (logLikelihoods != null)
            {
                logLikelihoods.ThrowIfNotReady();
            }
            if (covs0 != null)
            {
                covs0.ThrowIfDisposed();
            }
            if (weights0 != null)
            {
                weights0.ThrowIfDisposed();
            }
            if (labels != null)
            {
                labels.ThrowIfNotReady();
            }
            if (probs != null)
            {
                probs.ThrowIfNotReady();
            }

            int ret = NativeMethods.ml_EM_trainE(
                ptr,
                samples.CvPtr,
                means0.CvPtr,
                Cv2.ToPtr(covs0),
                Cv2.ToPtr(weights0),
                Cv2.ToPtr(logLikelihoods),
                Cv2.ToPtr(labels),
                Cv2.ToPtr(probs));

            if (logLikelihoods != null)
            {
                logLikelihoods.Fix();
            }
            if (labels != null)
            {
                labels.Fix();
            }
            if (probs != null)
            {
                probs.Fix();
            }

            return(ret != 0);
        }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="frame0"></param>
 /// <param name="frame1"></param>
 /// <param name="flow1"></param>
 /// <param name="flow2"></param>
 protected abstract void Calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2 = null);
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="frame0"></param>
 /// <param name="frame1"></param>
 /// <param name="flow1"></param>
 /// <param name="flow2"></param>
 public abstract void Calc(InputArray frame0, InputArray frame1, OutputArray flow1, OutputArray flow2 = null);
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mat"></param>
 /// <param name="distType"></param>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <param name="saturateRange"></param>
 public void Fill(InputOutputArray mat, DistributionType distType, InputArray a, InputArray b,
                  bool saturateRange = false)
 {
     if (mat == null)
     {
         throw new ArgumentNullException(nameof(mat));
     }
     if (a == null)
     {
         throw new ArgumentNullException(nameof(a));
     }
     if (b == null)
     {
         throw new ArgumentNullException(nameof(b));
     }
     mat.ThrowIfNotReady();
     a.ThrowIfDisposed();
     b.ThrowIfDisposed();
     NativeMethods.core_RNG_fill(ref state, mat.CvPtr, (int)distType, a.CvPtr, b.CvPtr, saturateRange ? 1 : 0);
     mat.Fix();
 }
Пример #5
0
        /// <summary>
        /// Calculates all of the moments
        /// up to the third order of a polygon or rasterized shape.
        /// </summary>
        /// <param name="array">A raster image (single-channel, 8-bit or floating-point
        /// 2D array) or an array ( 1xN or Nx1 ) of 2D points ( Point or Point2f )</param>
        /// <param name="binaryImage">If it is true, then all the non-zero image pixels are treated as 1’s</param>
        /// <returns></returns>
        private void InitializeFromInputArray(InputArray array, bool binaryImage)
        {
            WCvMoments m = NativeMethods.imgproc_moments(array.CvPtr, binaryImage ? 1 : 0);

            Initialize(m.m00, m.m10, m.m01, m.m20, m.m11, m.m02, m.m30, m.m21, m.m12, m.m03);
        }