当前位置: 首页>>代码示例>>C#>>正文


C# InputOutputArray.ThrowIfNotReady方法代码示例

本文整理汇总了C#中OpenCvSharp.InputOutputArray.ThrowIfNotReady方法的典型用法代码示例。如果您正苦于以下问题:C# InputOutputArray.ThrowIfNotReady方法的具体用法?C# InputOutputArray.ThrowIfNotReady怎么用?C# InputOutputArray.ThrowIfNotReady使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenCvSharp.InputOutputArray的用法示例。


在下文中一共展示了InputOutputArray.ThrowIfNotReady方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateMotionHistory

 /// <summary>
 /// Updates motion history image using the current silhouette
 /// </summary>
 /// <param name="silhouette">Silhouette mask that has non-zero pixels where the motion occurs.</param>
 /// <param name="mhi">Motion history image that is updated by the function (single-channel, 32-bit floating-point).</param>
 /// <param name="timestamp">Current time in milliseconds or other units.</param>
 /// <param name="duration">Maximal duration of the motion track in the same units as timestamp .</param>
 public static void UpdateMotionHistory(
     InputArray silhouette, InputOutputArray mhi,
     double timestamp, double duration)
 {
     if (silhouette == null)
         throw new ArgumentNullException("silhouette");
     if (mhi == null)
         throw new ArgumentNullException("mhi");
     silhouette.ThrowIfDisposed();
     mhi.ThrowIfNotReady();
     NativeMethods.optflow_motempl_updateMotionHistory(
         silhouette.CvPtr, mhi.CvPtr, timestamp, duration);
     mhi.Fix();
 }
开发者ID:CodeSang,项目名称:opencvsharp,代码行数:21,代码来源:Cv2_optflow.cs

示例2: Watershed

 /// <summary>
 /// Performs a marker-based image segmentation using the watershed algorithm.
 /// </summary>
 /// <param name="image">Input 8-bit 3-channel image.</param>
 /// <param name="markers">Input/output 32-bit single-channel image (map) of markers. 
 /// It should have the same size as image.</param>
 public static void Watershed(InputArray image, InputOutputArray markers)
 {
     if (image == null)
         throw new ArgumentNullException(nameof(image));
     if (markers == null)
         throw new ArgumentNullException(nameof(markers));
     image.ThrowIfDisposed();
     markers.ThrowIfNotReady();
     NativeMethods.imgproc_watershed(image.CvPtr, markers.CvPtr);
     GC.KeepAlive(image);
     markers.Fix();
 }
开发者ID:shimat,项目名称:opencvsharp,代码行数:18,代码来源:Cv2_imgproc.cs

示例3: InsertChannel

 /// <summary>
 /// inserts a single channel to dst (coi is 0-based index)
 /// </summary>
 /// <param name="src"></param>
 /// <param name="dst"></param>
 /// <param name="coi"></param>
 public static void InsertChannel(InputArray src, InputOutputArray dst, int coi)
 {
     if (src == null)
         throw new ArgumentNullException("src");
     if (dst == null)
         throw new ArgumentNullException("dst");
     src.ThrowIfDisposed();
     dst.ThrowIfNotReady();
     NativeMethods.core_insertChannel(src.CvPtr, dst.CvPtr, coi);
     GC.KeepAlive(src);
     dst.Fix();
 }
开发者ID:fdncred,项目名称:opencvsharp,代码行数:18,代码来源:Cv2_core.cs

示例4: RandShuffle

        /// <summary>
        /// shuffles the input array elements
        /// </summary>
        /// <param name="dst">The input/output numerical 1D array</param>
        /// <param name="iterFactor">The scale factor that determines the number of random swap operations.</param>
        /// <param name="rng">The optional random number generator used for shuffling. 
        /// If it is null, theRng() is used instead.</param>
        public static void RandShuffle(InputOutputArray dst, double iterFactor, RNG rng = null)
        {
            if (dst == null)
                throw new ArgumentNullException("dst");
            dst.ThrowIfNotReady();

            if (rng == null)
            {
                NativeMethods.core_randShuffle(dst.CvPtr, iterFactor, IntPtr.Zero);
            }
            else
            {
                ulong state = rng.State;
                NativeMethods.core_randShuffle(dst.CvPtr, iterFactor, ref state);
                rng.State = state;
            }
            dst.Fix();
        }
开发者ID:fdncred,项目名称:opencvsharp,代码行数:25,代码来源:Cv2_core.cs

示例5: Randn

 /// <summary>
 /// fills array with normally-distributed random numbers with the specified mean and the standard deviation
 /// </summary>
 /// <param name="dst">The output array of random numbers. 
 /// The array must be pre-allocated and have 1 to 4 channels</param>
 /// <param name="mean">The mean value (expectation) of the generated random numbers</param>
 /// <param name="stddev">The standard deviation of the generated random numbers</param>
 public static void Randn(InputOutputArray dst, InputArray mean, InputArray stddev)
 {
     if (dst == null)
         throw new ArgumentNullException("dst");
     if (mean == null)
         throw new ArgumentNullException("mean");
     if (stddev == null)
         throw new ArgumentNullException("stddev");
     dst.ThrowIfNotReady();
     mean.ThrowIfDisposed();
     stddev.ThrowIfDisposed();
     NativeMethods.core_randn_InputArray(dst.CvPtr, mean.CvPtr, stddev.CvPtr);
     GC.KeepAlive(mean);
     GC.KeepAlive(stddev); 
     dst.Fix();
 }
开发者ID:fdncred,项目名称:opencvsharp,代码行数:23,代码来源:Cv2_core.cs

示例6: Randu

 /// <summary>
 /// fills array with uniformly-distributed random numbers from the range [low, high)
 /// </summary>
 /// <param name="dst">The output array of random numbers. 
 /// The array must be pre-allocated and have 1 to 4 channels</param>
 /// <param name="low">The inclusive lower boundary of the generated random numbers</param>
 /// <param name="high">The exclusive upper boundary of the generated random numbers</param>
 public static void Randu(InputOutputArray dst, InputArray low, InputArray high)
 {
     if (dst == null)
         throw new ArgumentNullException("dst");
     if (low == null)
         throw new ArgumentNullException("low");
     if (high == null)
         throw new ArgumentNullException("high");
     dst.ThrowIfNotReady();
     low.ThrowIfDisposed();
     high.ThrowIfDisposed();
     NativeMethods.core_randu_InputArray(dst.CvPtr, low.CvPtr, high.CvPtr);
     GC.KeepAlive(low);
     GC.KeepAlive(high); 
     dst.Fix();
 }
开发者ID:fdncred,项目名称:opencvsharp,代码行数:23,代码来源:Cv2_core.cs

示例7: CalcCovarMatrix

 /// <summary>
 /// computes covariation matrix of a set of samples
 /// </summary>
 /// <param name="samples"></param>
 /// <param name="covar"></param>
 /// <param name="mean"></param>
 /// <param name="flags"></param>
 /// <param name="ctype"></param>
 public static void CalcCovarMatrix(InputArray samples, OutputArray covar,
     InputOutputArray mean, CovarFlags flags, MatType ctype)
 {
     if (samples == null)
         throw new ArgumentNullException("samples");
     if (covar == null)
         throw new ArgumentNullException("covar");
     if (mean == null)
         throw new ArgumentNullException("mean");
     samples.ThrowIfDisposed();
     covar.ThrowIfNotReady();
     mean.ThrowIfNotReady();
     NativeMethods.core_calcCovarMatrix_InputArray(samples.CvPtr, covar.CvPtr, mean.CvPtr, (int)flags, ctype);
     GC.KeepAlive(samples); 
     covar.Fix();
     mean.Fix();
 }
开发者ID:fdncred,项目名称:opencvsharp,代码行数:25,代码来源:Cv2_core.cs

示例8: CompleteSymm

 /// <summary>
 /// extends the symmetrical matrix from the lower half or from the upper half
 /// </summary>
 /// <param name="mtx"> Input-output floating-point square matrix</param>
 /// <param name="lowerToUpper">If true, the lower half is copied to the upper half, 
 /// otherwise the upper half is copied to the lower half</param>
 public static void CompleteSymm(InputOutputArray mtx, bool lowerToUpper = false)
 {
     if (mtx == null)
         throw new ArgumentNullException("mtx");
     mtx.ThrowIfNotReady();
     NativeMethods.core_completeSymm(mtx.CvPtr, lowerToUpper ? 1 : 0);
     mtx.Fix();
 }
开发者ID:fdncred,项目名称:opencvsharp,代码行数:14,代码来源:Cv2_core.cs

示例9: Ellipse

        /// <summary>
        /// 枠だけの楕円,楕円弧,もしくは塗りつぶされた扇形の楕円を描画する
        /// </summary>
        /// <param name="img">楕円が描画される画像</param>
        /// <param name="center">楕円の中心</param>
        /// <param name="axes">楕円の軸の長さ</param>
        /// <param name="angle">回転角度</param>
        /// <param name="startAngle">楕円弧の開始角度</param>
        /// <param name="endAngle">楕円弧の終了角度</param>
        /// <param name="color">楕円の色</param>
        /// <param name="thickness">楕円弧の線の幅 [既定値は1]</param>
        /// <param name="lineType">楕円弧の線の種類 [既定値はLineType.Link8]</param>
        /// <param name="shift">中心座標と軸の長さの小数点以下の桁を表すビット数 [既定値は0]</param>
#else
        /// <summary>
        /// Draws simple or thick elliptic arc or fills ellipse sector
        /// </summary>
        /// <param name="img">Image. </param>
        /// <param name="center">Center of the ellipse. </param>
        /// <param name="axes">Length of the ellipse axes. </param>
        /// <param name="angle">Rotation angle. </param>
        /// <param name="startAngle">Starting angle of the elliptic arc. </param>
        /// <param name="endAngle">Ending angle of the elliptic arc. </param>
        /// <param name="color">Ellipse color. </param>
        /// <param name="thickness">Thickness of the ellipse arc. [By default this is 1]</param>
        /// <param name="lineType">Type of the ellipse boundary. [By default this is LineType.Link8]</param>
        /// <param name="shift">Number of fractional bits in the center coordinates and axes' values. [By default this is 0]</param>
#endif
        public static void Ellipse(
            InputOutputArray img, Point center, Size axes, double angle, double startAngle, double endAngle, Scalar color,
            int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0)
        {
            if (img == null)
                throw new ArgumentNullException(nameof(img));
            img.ThrowIfNotReady();
            NativeMethods.imgproc_ellipse1(img.CvPtr, center, axes, angle, startAngle, endAngle, color, thickness, (int)lineType, shift);
            img.Fix();
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:38,代码来源:Cv2_imgproc.cs

示例10: ArrowedLine

        /// <summary>
        /// Draws a arrow segment pointing from the first point to the second one.
        /// The function arrowedLine draws an arrow between pt1 and pt2 points in the image. 
        /// See also cv::line.
        /// </summary>
        /// <param name="img">Image.</param>
        /// <param name="pt1">The point the arrow starts from.</param>
        /// <param name="pt2">The point the arrow points to.</param>
        /// <param name="color">Line color.</param>
        /// <param name="thickness">Line thickness.</param>
        /// <param name="lineType">Type of the line, see cv::LineTypes</param>
        /// <param name="shift">Number of fractional bits in the point coordinates.</param>
        /// <param name="tipLength">The length of the arrow tip in relation to the arrow length</param>
        public static void ArrowedLine(
            InputOutputArray img, 
            Point pt1, Point pt2, 
            Scalar color,
            int thickness = 1, 
            LineTypes lineType = LineTypes.Link8,
            int shift = 0, 
            double tipLength = 0.1)
        {
            if (img == null)
                throw new ArgumentNullException(nameof(img));
            img.ThrowIfNotReady();

            NativeMethods.imgproc_arrowedLine(
                img.CvPtr, pt1, pt2, color, thickness, (int)lineType, shift, tipLength);

            img.Fix();
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:31,代码来源:Cv2_imgproc.cs

示例11: FindContoursAsMat

        /// <summary>
        /// 2値画像中の輪郭を検出します.
        /// </summary>
        /// <param name="image">入力画像,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます.
        /// また,この関数は,輪郭抽出処理中に入力画像 image の中身を書き換えます.</param>
        /// <param name="mode">輪郭抽出モード</param>
        /// <param name="method">輪郭の近似手法</param>
        /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param>
        /// <return>検出された輪郭.各輪郭は,点のベクトルとして格納されます.</return>
#else
        /// <summary>
        /// Finds contours in a binary image.
        /// </summary>
        /// <param name="image">Source, an 8-bit single-channel image. Non-zero pixels are treated as 1’s. 
        /// Zero pixels remain 0’s, so the image is treated as binary.
        /// The function modifies the image while extracting the contours.</param> 
        /// <param name="mode">Contour retrieval mode</param>
        /// <param name="method">Contour approximation method</param>
        /// <param name="offset"> Optional offset by which every contour point is shifted. 
        /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param>
        /// <returns>Detected contours. Each contour is stored as a vector of points.</returns>
#endif
        public static MatOfPoint[] FindContoursAsMat(InputOutputArray image,
            RetrievalModes mode, ContourApproximationModes method, Point? offset = null)
        {
            if (image == null)
                throw new ArgumentNullException(nameof(image));
            image.ThrowIfNotReady();

            Point offset0 = offset.GetValueOrDefault(new Point());
            IntPtr contoursPtr;
            NativeMethods.imgproc_findContours2_OutputArray(image.CvPtr, out contoursPtr, (int)mode, (int)method, offset0);
            image.Fix();

            using (var contoursVec = new VectorOfMat(contoursPtr))
            {
                return contoursVec.ToArray<MatOfPoint>();
            }
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:39,代码来源:Cv2_imgproc.cs

示例12: FindContours

        /// <summary>
        /// 2値画像中の輪郭を検出します.
        /// </summary>
        /// <param name="image">入力画像,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます.
        /// また,この関数は,輪郭抽出処理中に入力画像 image の中身を書き換えます.</param>
        /// <param name="contours">検出された輪郭.各輪郭は,点のベクトルとして格納されます.</param>
        /// <param name="hierarchy">画像のトポロジーに関する情報を含む出力ベクトル.これは,輪郭数と同じ数の要素を持ちます.各輪郭 contours[i] に対して,
        /// 要素 hierarchy[i]のメンバにはそれぞれ,同じ階層レベルに存在する前後の輪郭,最初の子輪郭,および親輪郭の 
        /// contours インデックス(0 基準)がセットされます.また,輪郭 i において,前後,親,子の輪郭が存在しない場合,
        /// それに対応する hierarchy[i] の要素は,負の値になります.</param>
        /// <param name="mode">輪郭抽出モード</param>
        /// <param name="method">輪郭の近似手法</param>
        /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param>
#else
        /// <summary>
        /// Finds contours in a binary image.
        /// </summary>
        /// <param name="image">Source, an 8-bit single-channel image. Non-zero pixels are treated as 1’s. 
        /// Zero pixels remain 0’s, so the image is treated as binary.
        /// The function modifies the image while extracting the contours.</param> 
        /// <param name="contours">Detected contours. Each contour is stored as a vector of points.</param>
        /// <param name="hierarchy">Optional output vector, containing information about the image topology. 
        /// It has as many elements as the number of contours. For each i-th contour contours[i], 
        /// the members of the elements hierarchy[i] are set to 0-based indices in contours of the next 
        /// and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. 
        /// If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.</param>
        /// <param name="mode">Contour retrieval mode</param>
        /// <param name="method">Contour approximation method</param>
        /// <param name="offset"> Optional offset by which every contour point is shifted. 
        /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param>
#endif
        public static void FindContours(InputOutputArray image, out Mat[] contours,
            OutputArray hierarchy, RetrievalModes mode, ContourApproximationModes method, Point? offset = null)
        {
            if (image == null)
                throw new ArgumentNullException(nameof(image));
            if (hierarchy == null)
                throw new ArgumentNullException(nameof(hierarchy));
            image.ThrowIfNotReady();
            hierarchy.ThrowIfNotReady();

            Point offset0 = offset.GetValueOrDefault(new Point());
            IntPtr contoursPtr;
            NativeMethods.imgproc_findContours1_OutputArray(image.CvPtr, out contoursPtr, hierarchy.CvPtr, (int)mode, (int)method, offset0);

            using (var contoursVec = new VectorOfMat(contoursPtr))
            {
                contours = contoursVec.ToArray();
            }
            image.Fix();
            hierarchy.Fix();
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:52,代码来源:Cv2_imgproc.cs

示例13: FloodFill

 /// <summary>
 /// Fills a connected component with the given color.
 /// </summary>
 /// <param name="image">Input/output 1- or 3-channel, 8-bit, or floating-point image. 
 /// It is modified by the function unless the FLOODFILL_MASK_ONLY flag is set in the 
 /// second variant of the function. See the details below.</param>
 /// <param name="mask">(For the second function only) Operation mask that should be a single-channel 8-bit image, 
 /// 2 pixels wider and 2 pixels taller. The function uses and updates the mask, so you take responsibility of 
 /// initializing the mask content. Flood-filling cannot go across non-zero pixels in the mask. For example, 
 /// an edge detector output can be used as a mask to stop filling at edges. It is possible to use the same mask 
 /// in multiple calls to the function to make sure the filled area does not overlap.</param>
 /// <param name="seedPoint">Starting point.</param>
 /// <param name="newVal">New value of the repainted domain pixels.</param>
 /// <param name="rect">Optional output parameter set by the function to the 
 /// minimum bounding rectangle of the repainted domain.</param>
 /// <param name="loDiff">Maximal lower brightness/color difference between the currently 
 /// observed pixel and one of its neighbors belonging to the component, or a seed pixel 
 /// being added to the component.</param>
 /// <param name="upDiff">Maximal upper brightness/color difference between the currently 
 /// observed pixel and one of its neighbors belonging to the component, or a seed pixel 
 /// being added to the component.</param>
 /// <param name="flags">Operation flags. Lower bits contain a connectivity value, 
 /// 4 (default) or 8, used within the function. Connectivity determines which 
 /// neighbors of a pixel are considered. </param>
 /// <returns></returns>
 public static int FloodFill(InputOutputArray image, InputOutputArray mask,
                             Point seedPoint, Scalar newVal, out Rect rect,
                             Scalar? loDiff = null, Scalar? upDiff = null,
                             FloodFillFlags flags = FloodFillFlags.Link4)
 {
     if (image == null)
         throw new ArgumentNullException(nameof(image));
     if (mask == null)
         throw new ArgumentNullException(nameof(mask));
     image.ThrowIfNotReady();
     mask.ThrowIfNotReady();
     Scalar loDiff0 = loDiff.GetValueOrDefault(new Scalar());
     Scalar upDiff0 = upDiff.GetValueOrDefault(new Scalar());
     int ret = NativeMethods.imgproc_floodFill(image.CvPtr, mask.CvPtr, seedPoint, 
         newVal, out rect, loDiff0, upDiff0, (int)flags);
     image.Fix();
     mask.Fix();
     return ret;
 }
开发者ID:shimat,项目名称:opencvsharp,代码行数:44,代码来源:Cv2_imgproc.cs

示例14: GrabCut

 /// <summary>
 /// Segments the image using GrabCut algorithm
 /// </summary>
 /// <param name="img">Input 8-bit 3-channel image.</param>
 /// <param name="mask">Input/output 8-bit single-channel mask. 
 /// The mask is initialized by the function when mode is set to GC_INIT_WITH_RECT. 
 /// Its elements may have Cv2.GC_BGD / Cv2.GC_FGD / Cv2.GC_PR_BGD / Cv2.GC_PR_FGD</param>
 /// <param name="rect">ROI containing a segmented object. The pixels outside of the ROI are 
 /// marked as "obvious background". The parameter is only used when mode==GC_INIT_WITH_RECT.</param>
 /// <param name="bgdModel">Temporary array for the background model. Do not modify it while you are processing the same image.</param>
 /// <param name="fgdModel">Temporary arrays for the foreground model. Do not modify it while you are processing the same image.</param>
 /// <param name="iterCount">Number of iterations the algorithm should make before returning the result. 
 /// Note that the result can be refined with further calls with mode==GC_INIT_WITH_MASK or mode==GC_EVAL .</param>
 /// <param name="mode">Operation mode that could be one of GrabCutFlag value.</param>
 public static void GrabCut(InputArray img, InputOutputArray mask, Rect rect,
                            InputOutputArray bgdModel, InputOutputArray fgdModel,
                            int iterCount, GrabCutModes mode)
 {
     if (img == null)
         throw new ArgumentNullException(nameof(img));
     if (mask == null)
         throw new ArgumentNullException(nameof(mask));
     if (bgdModel == null)
         throw new ArgumentNullException(nameof(bgdModel));
     if (fgdModel == null)
         throw new ArgumentNullException(nameof(fgdModel));
     img.ThrowIfDisposed();
     mask.ThrowIfNotReady();
     bgdModel.ThrowIfNotReady();
     fgdModel.ThrowIfNotReady();
     NativeMethods.imgproc_grabCut(img.CvPtr, mask.CvPtr, rect,
         bgdModel.CvPtr, fgdModel.CvPtr, iterCount, (int)mode);
     GC.KeepAlive(img);
     mask.Fix();
     bgdModel.Fix();
     fgdModel.Fix();
 }
开发者ID:shimat,项目名称:opencvsharp,代码行数:37,代码来源:Cv2_imgproc.cs

示例15: Fill

 /// <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();
 }
开发者ID:shimat,项目名称:opencvsharp,代码行数:23,代码来源:RNG.cs


注:本文中的OpenCvSharp.InputOutputArray.ThrowIfNotReady方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。