本文整理汇总了C#中OpenCvSharp.InputOutputArray.Fix方法的典型用法代码示例。如果您正苦于以下问题:C# InputOutputArray.Fix方法的具体用法?C# InputOutputArray.Fix怎么用?C# InputOutputArray.Fix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCvSharp.InputOutputArray
的用法示例。
在下文中一共展示了InputOutputArray.Fix方法的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();
}
示例2: 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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例7: PCAComputeVar
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/// <param name="mean"></param>
/// <param name="eigenvectors"></param>
/// <param name="retainedVariance"></param>
public static void PCAComputeVar(InputArray data, InputOutputArray mean,
OutputArray eigenvectors, double retainedVariance)
{
if (data == null)
throw new ArgumentNullException("data");
if (mean == null)
throw new ArgumentNullException("mean");
if (eigenvectors == null)
throw new ArgumentNullException("eigenvectors");
data.ThrowIfDisposed();
mean.ThrowIfNotReady();
eigenvectors.ThrowIfNotReady();
NativeMethods.core_PCAComputeVar(data.CvPtr, mean.CvPtr, eigenvectors.CvPtr, retainedVariance);
GC.KeepAlive(data);
mean.Fix();
eigenvectors.Fix();
}
示例8: SetIdentity
/// <summary>
/// initializes scaled identity matrix
/// </summary>
/// <param name="mtx">The matrix to initialize (not necessarily square)</param>
/// <param name="s">The value to assign to the diagonal elements</param>
public static void SetIdentity(InputOutputArray mtx, Scalar? s = null)
{
if (mtx == null)
throw new ArgumentNullException("mtx");
mtx.ThrowIfNotReady();
Scalar s0 = s.GetValueOrDefault(new Scalar(1));
NativeMethods.core_setIdentity(mtx.CvPtr, s0);
mtx.Fix();
}
示例9: DrawContours
/// <summary>
/// 輪郭線,または内側が塗りつぶされた輪郭を描きます.
/// </summary>
/// <param name="image">出力画像</param>
/// <param name="contours"> 入力される全輪郭.各輪郭は,点のベクトルとして格納されています.</param>
/// <param name="contourIdx">描かれる輪郭を示します.これが負値の場合,すべての輪郭が描画されます.</param>
/// <param name="color">輪郭の色.</param>
/// <param name="thickness">輪郭線の太さ.これが負値の場合(例えば thickness=CV_FILLED ),輪郭の内側が塗りつぶされます.</param>
/// <param name="lineType">線の連結性</param>
/// <param name="hierarchy">階層に関するオプションの情報.これは,特定の輪郭だけを描画したい場合にのみ必要になります.</param>
/// <param name="maxLevel">描画される輪郭の最大レベル.0ならば,指定された輪郭のみが描画されます.
/// 1ならば,指定された輪郭と,それに入れ子になったすべての輪郭が描画されます.2ならば,指定された輪郭と,
/// それに入れ子になったすべての輪郭,さらにそれに入れ子になったすべての輪郭が描画されます.このパラメータは,
/// hierarchy が有効な場合のみ考慮されます.</param>
/// <param name="offset">輪郭をシフトするオプションパラメータ.指定された offset = (dx,dy) だけ,すべての描画輪郭がシフトされます.</param>
#else
/// <summary>
/// draws contours in the image
/// </summary>
/// <param name="image">Destination image.</param>
/// <param name="contours">All the input contours. Each contour is stored as a point vector.</param>
/// <param name="contourIdx">Parameter indicating a contour to draw. If it is negative, all the contours are drawn.</param>
/// <param name="color">Color of the contours.</param>
/// <param name="thickness">Thickness of lines the contours are drawn with. If it is negative (for example, thickness=CV_FILLED ),
/// the contour interiors are drawn.</param>
/// <param name="lineType">Line connectivity. </param>
/// <param name="hierarchy">Optional information about hierarchy. It is only needed if you want to draw only some of the contours</param>
/// <param name="maxLevel">Maximal level for drawn contours. If it is 0, only the specified contour is drawn.
/// If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function draws the contours,
/// all the nested contours, all the nested-to-nested contours, and so on. This parameter is only taken into account
/// when there is hierarchy available.</param>
/// <param name="offset">Optional contour shift parameter. Shift all the drawn contours by the specified offset = (dx, dy)</param>
#endif
public static void DrawContours(
InputOutputArray image,
IEnumerable<IEnumerable<Point>> contours,
int contourIdx,
Scalar color,
int thickness = 1,
LineTypes lineType = LineTypes.Link8,
IEnumerable<HierarchyIndex> hierarchy = null,
int maxLevel = Int32.MaxValue,
Point? offset = null)
{
if (image == null)
throw new ArgumentNullException(nameof(image));
if (contours == null)
throw new ArgumentNullException(nameof(contours));
image.ThrowIfNotReady();
Point offset0 = offset.GetValueOrDefault(new Point());
Point[][] contoursArray = EnumerableEx.SelectToArray(contours, EnumerableEx.ToArray);
int[] contourSize2 = EnumerableEx.SelectToArray(contoursArray, pts => pts.Length);
using (var contoursPtr = new ArrayAddress2<Point>(contoursArray))
{
if (hierarchy == null)
{
NativeMethods.imgproc_drawContours_vector(image.CvPtr, contoursPtr.Pointer, contoursArray.Length, contourSize2,
contourIdx, color, thickness, (int)lineType, IntPtr.Zero, 0, maxLevel, offset0);
}
else
{
Vec4i[] hiearchyVecs = EnumerableEx.SelectToArray(hierarchy, hi => hi.ToVec4i());
NativeMethods.imgproc_drawContours_vector(image.CvPtr, contoursPtr.Pointer, contoursArray.Length, contourSize2,
contourIdx, color, thickness, (int)lineType, hiearchyVecs, hiearchyVecs.Length, maxLevel, offset0);
}
}
image.Fix();
}
示例10: Polylines
/// <summary>
/// draws one or more polygonal curves
/// </summary>
/// <param name="img"></param>
/// <param name="pts"></param>
/// <param name="isClosed"></param>
/// <param name="color"></param>
/// <param name="thickness"></param>
/// <param name="lineType"></param>
/// <param name="shift"></param>
public static void Polylines(
InputOutputArray img, InputArray pts, bool isClosed, Scalar color,
int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0)
{
if (img == null)
throw new ArgumentNullException(nameof(img));
if (pts == null)
throw new ArgumentNullException(nameof(pts));
img.ThrowIfDisposed();
pts.ThrowIfDisposed();
NativeMethods.imgproc_polylines_InputOutputArray(
img.CvPtr, pts.CvPtr, isClosed ? 1 : 0, color, thickness, (int)lineType, shift);
img.Fix();
GC.KeepAlive(pts);
}
示例11: FillPoly
/// <summary>
/// 1つ,または複数のポリゴンで区切られた領域を塗りつぶします.
/// </summary>
/// <param name="img">画像</param>
/// <param name="pts">ポリゴンの配列.各要素は,点の配列で表現されます.</param>
/// <param name="color">ポリゴンの色.</param>
/// <param name="lineType">ポリゴンの枠線の種類,</param>
/// <param name="shift">ポリゴンの頂点座標において,小数点以下の桁を表すビット数.</param>
/// <param name="offset"></param>
#else
/// <summary>
/// Fills the area bounded by one or more polygons
/// </summary>
/// <param name="img">Image</param>
/// <param name="pts">Array of polygons, each represented as an array of points</param>
/// <param name="color">Polygon color</param>
/// <param name="lineType">Type of the polygon boundaries</param>
/// <param name="shift">The number of fractional bits in the vertex coordinates</param>
/// <param name="offset"></param>
#endif
public static void FillPoly(
InputOutputArray img, InputArray pts, Scalar color,
LineTypes lineType = LineTypes.Link8, int shift = 0, Point? offset = null)
{
if (img == null)
throw new ArgumentNullException(nameof(img));
if (pts == null)
throw new ArgumentNullException(nameof(pts));
img.ThrowIfDisposed();
pts.ThrowIfDisposed();
Point offset0 = offset.GetValueOrDefault(new Point());
NativeMethods.imgproc_fillPoly_InputOutputArray(
img.CvPtr, pts.CvPtr, color, (int)lineType, shift, offset0);
GC.KeepAlive(pts);
img.Fix();
}
示例12: Ellipse
/// <summary>
/// 枠だけの楕円,もしくは塗りつぶされた楕円を描画する
/// </summary>
/// <param name="img">楕円が描かれる画像.</param>
/// <param name="box">描画したい楕円を囲む矩形領域.</param>
/// <param name="color">楕円の色.</param>
/// <param name="thickness">楕円境界線の幅.[既定値は1]</param>
/// <param name="lineType">楕円境界線の種類.[既定値はLineType.Link8]</param>
#else
/// <summary>
/// Draws simple or thick elliptic arc or fills ellipse sector
/// </summary>
/// <param name="img">Image. </param>
/// <param name="box">The enclosing box of the ellipse drawn </param>
/// <param name="color">Ellipse color. </param>
/// <param name="thickness">Thickness of the ellipse boundary. [By default this is 1]</param>
/// <param name="lineType">Type of the ellipse boundary. [By default this is LineType.Link8]</param>
#endif
public static void Ellipse(InputOutputArray img, RotatedRect box, Scalar color,
int thickness = 1, LineTypes lineType = LineTypes.Link8)
{
if (img == null)
throw new ArgumentNullException(nameof(img));
img.ThrowIfDisposed();
NativeMethods.imgproc_ellipse2(img.CvPtr, box, color, thickness, (int)lineType);
img.Fix();
}
示例13: Circle
/// <summary>
/// 円を描画する
/// </summary>
/// <param name="img">画像</param>
/// <param name="center">円の中心</param>
/// <param name="radius">円の半径</param>
/// <param name="color">円の色</param>
/// <param name="thickness">線の幅.負の値を指定した場合は塗りつぶされる.[既定値は1]</param>
/// <param name="lineType">線の種類. [既定値はLineType.Link8]</param>
/// <param name="shift">中心座標と半径の小数点以下の桁を表すビット数. [既定値は0]</param>
#else
/// <summary>
/// Draws a circle
/// </summary>
/// <param name="img">Image where the circle is drawn. </param>
/// <param name="center">Center of the circle. </param>
/// <param name="radius">Radius of the circle. </param>
/// <param name="color">Circle color. </param>
/// <param name="thickness">Thickness of the circle outline if positive, otherwise indicates that a filled circle has to be drawn. [By default this is 1]</param>
/// <param name="lineType">Type of the circle boundary. [By default this is LineType.Link8]</param>
/// <param name="shift">Number of fractional bits in the center coordinates and radius value. [By default this is 0]</param>
#endif
public static void Circle(InputOutputArray img, Point center, int radius, Scalar color,
int thickness = 1, LineTypes lineType = LineTypes.Link8, int shift = 0)
{
if (img == null)
throw new ArgumentNullException(nameof(img));
img.ThrowIfDisposed();
NativeMethods.imgproc_circle(img.CvPtr, center, radius, color, thickness, (int)lineType, shift);
img.Fix();
}
示例14: Rectangle
/// <summary>
/// 枠のみ,もしくは塗りつぶされた矩形を描画する
/// </summary>
/// <param name="img">画像</param>
/// <param name="rect">矩形</param>
/// <param name="color">線の色(RGB),もしくは輝度(グレースケール画像).</param>
/// <param name="thickness">矩形を描く線の太さ.負の値を指定した場合は塗りつぶされる. [既定値は1]</param>
/// <param name="lineType">線の種類. [既定値はLineType.Link8]</param>
/// <param name="shift">座標の小数点以下の桁を表すビット数. [既定値は0]</param>
#else
/// <summary>
/// Draws simple, thick or filled rectangle
/// </summary>
/// <param name="img">Image. </param>
/// <param name="rect">Rectangle.</param>
/// <param name="color">Line color (RGB) or brightness (grayscale image). </param>
/// <param name="thickness">Thickness of lines that make up the rectangle. Negative values make the function to draw a filled rectangle. [By default this is 1]</param>
/// <param name="lineType">Type of the line, see cvLine description. [By default this is LineType.Link8]</param>
/// <param name="shift">Number of fractional bits in the point coordinates. [By default this is 0]</param>
#endif
public static void Rectangle(
InputOutputArray img, Rect rect, Scalar color, int thickness = 1,
LineTypes lineType = LineTypes.Link8, int shift = 0)
{
if (img == null)
throw new ArgumentNullException(nameof(img));
NativeMethods.imgproc_rectangle_InputOutputArray(img.CvPtr, rect.TopLeft, rect.BottomRight, color, thickness, (int)lineType, shift);
img.Fix();
}
示例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();
}