/// <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(GetType().Name); } if (samples == null) { throw new ArgumentNullException(nameof(samples)); } if (means0 == null) { throw new ArgumentNullException(nameof(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(); } GC.KeepAlive(samples); GC.KeepAlive(means0); GC.KeepAlive(covs0); GC.KeepAlive(weights0); return(ret != 0); }
/// <summary> /// Merges images. /// </summary> /// <param name="src">vector of input images</param> /// <param name="dst">result image</param> /// <param name="times">vector of exposure time values for each image</param> /// <param name="response"> 256x1 matrix with inverse camera response function for each pixel value, it should have the same number of channels as images.</param> public virtual void Process(IEnumerable <Mat> src, OutputArray dst, IEnumerable <float> times, InputArray response) { if (src == null) { throw new ArgumentNullException(nameof(src)); } if (dst == null) { throw new ArgumentNullException(nameof(dst)); } if (times == null) { throw new ArgumentNullException(nameof(times)); } if (response == null) { throw new ArgumentNullException(nameof(response)); } dst.ThrowIfNotReady(); var srcArray = EnumerableEx.SelectPtrs(src); var timesArray = EnumerableEx.ToArray(times); if (srcArray.Length != timesArray.Length) { throw new OpenCvSharpException("src.Count() != times.Count"); } NativeMethods.photo_MergeExposures_process(ptr, srcArray, srcArray.Length, dst.CvPtr, timesArray, response.CvPtr); dst.Fix(); GC.KeepAlive(this); GC.KeepAlive(src); GC.KeepAlive(dst); GC.KeepAlive(response); }
/// <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("mat"); } if (a == null) { throw new ArgumentNullException("a"); } if (b == null) { throw new ArgumentNullException("b"); } mat.ThrowIfNotReady(); a.ThrowIfDisposed(); b.ThrowIfDisposed(); NativeMethods.core_RNG_fill(State, mat.CvPtr, (int)distType, a.CvPtr, b.CvPtr, saturateRange ? 1 : 0); mat.Fix(); }
/// <summary> /// Decodes QR codes in image once it's found by the detect() method. /// Returns UTF8-encoded output string or empty string if the code cannot be decoded. /// </summary> /// <param name="img">grayscale or color (BGR) image containing QR code.</param> /// <param name="points">Quadrangle vertices found by detect() method (or some other algorithm).</param> /// <param name="decodedInfo">UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded. </param> /// <param name="straightQrCode">The optional output image containing rectified and binarized QR code</param> /// <returns></returns> public bool DecodeMulti(InputArray img, IEnumerable <Point2f> points, out string?[] decodedInfo, out Mat[] straightQrCode) { return(DecodeMulti(img, points, out decodedInfo, out straightQrCode, true)); }
/// <summary> /// Decodes QR codes in image once it's found by the detect() method. /// Returns UTF8-encoded output string or empty string if the code cannot be decoded. /// </summary> /// <param name="img">grayscale or color (BGR) image containing QR code.</param> /// <param name="points">Quadrangle vertices found by detect() method (or some other algorithm).</param> /// <param name="decodedInfo">UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded. </param> /// <returns></returns> public bool DecodeMulti(InputArray img, IEnumerable <Point2f> points, out string?[] decodedInfo) { return(DecodeMulti(img, points, out decodedInfo, out _, false)); }
/// <summary> /// /// </summary> /// <param name="frame0"></param> /// <param name="frame1"></param> /// <param name="flow"></param> public abstract void Calc(InputArray frame0, InputArray frame1, InputOutputArray flow);
/// <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) { var 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); }
/// <summary> /// /// </summary> /// <param name="frame0"></param> /// <param name="frame1"></param> /// <param name="flow"></param> protected abstract void Calc(InputArray frame0, InputArray frame1, InputOutputArray flow);