本文整理汇总了C#中OpenCvSharp.CPlusPlus.Mat.ThrowIfDisposed方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.ThrowIfDisposed方法的具体用法?C# Mat.ThrowIfDisposed怎么用?C# Mat.ThrowIfDisposed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCvSharp.CPlusPlus.Mat
的用法示例。
在下文中一共展示了Mat.ThrowIfDisposed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChamferMatching
/// <summary>
///
/// </summary>
/// <param name="img"></param>
/// <param name="templ"></param>
/// <param name="results"></param>
/// <param name="cost"></param>
/// <param name="templScale"></param>
/// <param name="maxMatches"></param>
/// <param name="minMatchDistance"></param>
/// <param name="padX"></param>
/// <param name="padY"></param>
/// <param name="scales"></param>
/// <param name="minScale"></param>
/// <param name="maxScale"></param>
/// <param name="orientationWeight"></param>
/// <param name="truncate"></param>
/// <returns></returns>
public static int ChamferMatching(
Mat img, Mat templ,
out Point[][] results, out float[] cost,
double templScale=1, int maxMatches = 20,
double minMatchDistance = 1.0, int padX = 3,
int padY = 3, int scales = 5, double minScale = 0.6, double maxScale = 1.6,
double orientationWeight = 0.5, double truncate = 20)
{
if (img == null)
throw new ArgumentNullException("img");
if (templ == null)
throw new ArgumentNullException("templ");
img.ThrowIfDisposed();
templ.ThrowIfDisposed();
using (var resultsVec = new VectorOfVectorPoint())
using (var costVec = new VectorOfFloat())
{
int ret = NativeMethods.contrib_chamerMatching(
img.CvPtr, templ.CvPtr, resultsVec.CvPtr, costVec.CvPtr,
templScale, maxMatches, minMatchDistance,
padX, padY, scales, minScale, maxScale, orientationWeight, truncate);
GC.KeepAlive(img);
GC.KeepAlive(templ);
results = resultsVec.ToArray();
cost = costVec.ToArray();
return ret;
}
}
示例2: DrawKeypoints
/// <summary>
/// Draw keypoints.
/// </summary>
/// <param name="image"></param>
/// <param name="keypoints"></param>
/// <param name="outImage"></param>
/// <param name="color"></param>
/// <param name="flags"></param>
public static void DrawKeypoints(Mat image, IEnumerable<KeyPoint> keypoints, Mat outImage,
Scalar? color = null, DrawMatchesFlags flags = DrawMatchesFlags.Default)
{
if (image == null)
throw new ArgumentNullException("image");
if (outImage == null)
throw new ArgumentNullException("outImage");
if (keypoints == null)
throw new ArgumentNullException("keypoints");
image.ThrowIfDisposed();
outImage.ThrowIfDisposed();
KeyPoint[] keypointsArray = EnumerableEx.ToArray(keypoints);
Scalar color0 = color.GetValueOrDefault(Scalar.All(-1));
NativeMethods.features2d_drawKeypoints(image.CvPtr, keypointsArray, keypointsArray.Length,
outImage.CvPtr, color0, (int)flags);
}
示例3: DetectMultiScaleROI
/// <summary>
/// evaluate specified ROI and return confidence value for each location in multiple scales
/// </summary>
/// <param name="img"></param>
/// <param name="foundLocations"></param>
/// <param name="locations"></param>
/// <param name="hitThreshold"></param>
/// <param name="groupThreshold"></param>
public void DetectMultiScaleROI(
Mat img,
out Rect[] foundLocations,
out DetectionROI[] locations,
double hitThreshold = 0,
int groupThreshold = 0)
{
if (disposed)
throw new ObjectDisposedException("HOGDescriptor");
if (img == null)
throw new ArgumentNullException("img");
img.ThrowIfDisposed();
using (var flVec = new VectorOfRect())
using (var scalesVec = new VectorOfDouble())
using (var locationsVec = new VectorOfVectorPoint())
using (var confidencesVec = new VectorOfVectorDouble())
{
NativeMethods.objdetect_HOGDescriptor_detectMultiScaleROI(
ptr, img.CvPtr, flVec.CvPtr,
scalesVec.CvPtr, locationsVec.CvPtr, confidencesVec.CvPtr,
hitThreshold, groupThreshold);
foundLocations = flVec.ToArray();
double[] s = scalesVec.ToArray();
Point[][] l = locationsVec.ToArray();
double[][] c = confidencesVec.ToArray();
if(s.Length != l.Length || l.Length != c.Length)
throw new OpenCvSharpException("Invalid result data 'locations'");
locations = new DetectionROI[s.Length];
for (int i = 0; i < s.Length; i++)
{
locations[i] = new DetectionROI
{
Scale = s[i],
Locations = l[i],
Confidences = c[i]
};
}
}
}
示例4: ComputeGradient
/// <summary>
///
/// </summary>
/// <param name="img"></param>
/// <param name="grad"></param>
/// <param name="angleOfs"></param>
/// <param name="paddingTL"></param>
/// <param name="paddingBR"></param>
public virtual void ComputeGradient(Mat img, Mat grad, Mat angleOfs, Size? paddingTL = null, Size? paddingBR = null)
{
if (disposed)
throw new ObjectDisposedException("HOGDescriptor");
if (img == null)
throw new ArgumentNullException("img");
if (grad == null)
throw new ArgumentNullException("grad");
if (angleOfs == null)
throw new ArgumentNullException("angleOfs");
img.ThrowIfDisposed();
grad.ThrowIfDisposed();
angleOfs.ThrowIfDisposed();
Size paddingTL0 = paddingTL.GetValueOrDefault(new Size());
Size paddingBR0 = paddingBR.GetValueOrDefault(new Size());
NativeMethods.objdetect_HOGDescriptor_computeGradient(ptr, img.CvPtr, grad.CvPtr, angleOfs.CvPtr, paddingTL0, paddingBR0);
}
示例5: Detect
/// <summary>
/// Performs object detection without a multi-scale window.
/// </summary>
/// <param name="img">Source image. CV_8UC1 and CV_8UC4 types are supported for now.</param>
/// <param name="weights"></param>
/// <param name="hitThreshold">Threshold for the distance between features and SVM classifying plane.
/// Usually it is 0 and should be specfied in the detector coefficients (as the last free coefficient).
/// But if the free coefficient is omitted (which is allowed), you can specify it manually here.</param>
/// <param name="winStride">Window stride. It must be a multiple of block stride.</param>
/// <param name="padding">Mock parameter to keep the CPU interface compatibility. It must be (0,0).</param>
/// <param name="searchLocations"></param>
/// <returns>Left-top corner points of detected objects boundaries.</returns>
public virtual Point[] Detect(Mat img, out double[] weights,
double hitThreshold = 0, Size? winStride = null, Size? padding = null, Point[] searchLocations = null)
{
if (disposed)
throw new ObjectDisposedException("HOGDescriptor");
if (img == null)
throw new ArgumentNullException("img");
img.ThrowIfDisposed();
Size winStride0 = winStride.GetValueOrDefault(new Size());
Size padding0 = padding.GetValueOrDefault(new Size());
using (var flVec = new VectorOfPoint())
using (var weightsVec = new VectorOfDouble())
{
int slLength = (searchLocations != null) ? searchLocations.Length : 0;
NativeMethods.objdetect_HOGDescriptor_detect(ptr, img.CvPtr, flVec.CvPtr, weightsVec.CvPtr,
hitThreshold, winStride0, padding0, searchLocations, slLength);
weights = weightsVec.ToArray();
return flVec.ToArray();
}
}
示例6: CalcOpticalFlowSF
/// <summary>
/// computes dense optical flow using Simple Flow algorithm
/// </summary>
/// <param name="from">First 8-bit 3-channel image.</param>
/// <param name="to">Second 8-bit 3-channel image</param>
/// <param name="flow">Estimated flow</param>
/// <param name="layers">Number of layers</param>
/// <param name="averagingBlockSize">Size of block through which we sum up when calculate cost function for pixel</param>
/// <param name="maxFlow">maximal flow that we search at each level</param>
public static void CalcOpticalFlowSF(
Mat from,
Mat to,
Mat flow,
int layers,
int averagingBlockSize,
int maxFlow)
{
if (from == null)
throw new ArgumentNullException("from");
if (to == null)
throw new ArgumentNullException("to");
if (flow == null)
throw new ArgumentNullException("flow");
from.ThrowIfDisposed();
to.ThrowIfDisposed();
flow.ThrowIfDisposed();
NativeMethods.video_calcOpticalFlowSF1(
from.CvPtr, to.CvPtr, flow.CvPtr,
layers, averagingBlockSize, maxFlow);
}
示例7: WarpPerspective
/// <summary>
///
/// </summary>
/// <param name="src"></param>
/// <param name="dst"></param>
/// <param name="m"></param>
/// <param name="dsize"></param>
/// <param name="flags"></param>
/// <param name="borderMode"></param>
/// <param name="borderValue"></param>
public static void WarpPerspective(InputArray src, OutputArray dst, Mat m, Size dsize,
Interpolation flags = Interpolation.Linear, BorderType borderMode = BorderType.Constant, Scalar? borderValue = null)
{
if (src == null)
throw new ArgumentNullException("src");
if (dst == null)
throw new ArgumentNullException("dst");
if (m == null)
throw new ArgumentNullException("m");
src.ThrowIfDisposed();
dst.ThrowIfDisposed();
m.ThrowIfDisposed();
CvScalar borderValue0 = borderValue.GetValueOrDefault(CvScalar.ScalarAll(0));
NativeMethods.imgproc_warpPerspective(src.CvPtr, dst.CvPtr, m.CvPtr, dsize, (int)flags, (int)borderMode, borderValue0);
dst.Fix();
}
示例8: Predict
/// <summary>
/// 入力サンプルに対する応答を予測する
/// </summary>
/// <param name="inputs">入力サンプル</param>
/// <param name="outputs"></param>
/// <returns></returns>
#else
/// <summary>
/// Predicts response for the input sample
/// </summary>
/// <param name="inputs">The input sample. </param>
/// <param name="outputs"></param>
/// <returns></returns>
#endif
public float Predict(Mat inputs, Mat outputs)
{
if (inputs == null)
throw new ArgumentNullException("inputs");
if (outputs == null)
throw new ArgumentNullException("outputs");
inputs.ThrowIfDisposed();
outputs.ThrowIfDisposed();
return NativeMethods.ml_CvANN_MLP_predict_CvMat(ptr, inputs.CvPtr, outputs.CvPtr);
}
示例9: 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(Mat img, RotatedRect box, Scalar color,
int thickness = 1, LineType lineType = LineType.Link8)
{
if (img == null)
throw new ArgumentNullException("img");
img.ThrowIfDisposed();
NativeMethods.core_ellipse(img.CvPtr, box, color, thickness, (int)lineType);
}
示例10: 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(Mat img, Point center, int radius, Scalar color,
int thickness = 1, LineType lineType = LineType.Link8, int shift = 0)
{
if (img == null)
throw new ArgumentNullException("img");
img.ThrowIfDisposed();
NativeMethods.core_circle(img.CvPtr, center, radius, color, thickness, (int)lineType, shift);
}
示例11: Abs
/// <summary>
///
/// </summary>
/// <param name="src"></param>
/// <returns></returns>
public static MatExpr Abs(Mat src)
{
if (src == null)
throw new ArgumentNullException("src");
src.ThrowIfDisposed();
IntPtr retPtr = NativeMethods.core_abs_Mat(src.CvPtr);
return new MatExpr(retPtr);
}
示例12: 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(Mat[] samples, Mat covar, Mat mean,
CovarMatrixFlag flags, MatType ctype)
{
if (samples == null)
throw new ArgumentNullException("samples");
if (covar == null)
throw new ArgumentNullException("covar");
if (mean == null)
throw new ArgumentNullException("mean");
covar.ThrowIfDisposed();
mean.ThrowIfDisposed();
IntPtr[] samplesPtr = EnumerableEx.SelectPtrs(samples);
NativeMethods.core_calcCovarMatrix_Mat(samplesPtr, samples.Length, covar.CvPtr, mean.CvPtr, (int)flags, ctype);
}
示例13: Max
/// <summary>
/// computes per-element maximum of array and scalar (dst = max(src1, src2))
/// </summary>
/// <param name="src1"></param>
/// <param name="src2"></param>
/// <param name="dst"></param>
public static void Max(Mat src1, double src2, Mat dst)
{
if (src1 == null)
throw new ArgumentNullException("src1");
if (dst == null)
throw new ArgumentNullException("dst");
src1.ThrowIfDisposed();
dst.ThrowIfDisposed();
NativeMethods.core_max_MatDouble(src1.CvPtr, src2, dst.CvPtr);
}
示例14: Min
/// <summary>
/// computes per-element minimum of two arrays (dst = min(src1, src2))
/// </summary>
/// <param name="src1"></param>
/// <param name="src2"></param>
/// <param name="dst"></param>
public static void Min(Mat src1, Mat src2, Mat dst)
{
if (src1 == null)
throw new ArgumentNullException("src1");
if (src2 == null)
throw new ArgumentNullException("src2");
if (dst == null)
throw new ArgumentNullException("dst");
src1.ThrowIfDisposed();
src2.ThrowIfDisposed();
dst.ThrowIfDisposed();
NativeMethods.core_min_MatMat(src1.CvPtr, src2.CvPtr, dst.CvPtr);
}
示例15: Create
/// <summary>
/// 指定したトポロジーでMLPを構築する
/// </summary>
/// <param name="layerSizes">入出力層を含む各層のニューロン数を指定する整数のベクトル</param>
/// <param name="activFunc">各ニューロンの活性化関数</param>
/// <param name="fParam1">活性化関数のフリーパラメータα</param>
/// <param name="fParam2">活性化関数のフリーパラメータβ</param>
#else
/// <summary>
/// Constructs the MLP with the specified topology
/// </summary>
/// <param name="layerSizes">The integer vector specifies the number of neurons in each layer including the input and output layers. </param>
/// <param name="activFunc">Specifies the activation function for each neuron</param>
/// <param name="fParam1">Free parameter α of the activation function</param>
/// <param name="fParam2">Free parameter β of the activation function</param>
#endif
public void Create(
Mat layerSizes,
MLPActivationFunc activFunc = MLPActivationFunc.SigmoidSym,
double fParam1 = 0, double fParam2 = 0)
{
if (disposed)
throw new ObjectDisposedException("StatModel");
if (layerSizes == null)
throw new ArgumentNullException("layerSizes");
layerSizes.ThrowIfDisposed();
NativeMethods.ml_CvANN_MLP_create_Mat(
ptr, layerSizes.CvPtr, (int)activFunc, fParam1, fParam2);
}