本文整理汇总了C#中CvMat.ThrowIfDisposed方法的典型用法代码示例。如果您正苦于以下问题:C# CvMat.ThrowIfDisposed方法的具体用法?C# CvMat.ThrowIfDisposed怎么用?C# CvMat.ThrowIfDisposed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvMat
的用法示例。
在下文中一共展示了CvMat.ThrowIfDisposed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CvNormalBayesClassifier
/// <summary>
/// 学習データを与えて初期化
/// </summary>
/// <param name="trainData">既知のサンプル (m*n)</param>
/// <param name="responses">既知のサンプルのクラス (m*1)</param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <returns></returns>
#else
/// <summary>
/// Bayes classifier for normally distributed data
/// </summary>
/// <param name="trainData">Known samples (m*n)</param>
/// <param name="responses">Classes for known samples (m*1)</param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <returns></returns>
#endif
public CvNormalBayesClassifier(
CvMat trainData,
CvMat responses,
CvMat varIdx = null,
CvMat sampleIdx = null)
{
if (trainData == null)
throw new ArgumentNullException("trainData");
if (responses == null)
throw new ArgumentNullException("responses");
trainData.ThrowIfDisposed();
responses.ThrowIfDisposed();
ptr = NativeMethods.ml_CvNormalBayesClassifier_new2_CvMat(
trainData.CvPtr, responses.CvPtr, Cv2.ToPtr(varIdx), Cv2.ToPtr(sampleIdx));
}
示例2: CvKNearest
/// <summary>
/// 学習データを与えて初期化
/// </summary>
/// <param name="trainData">既知のサンプル (m*n)</param>
/// <param name="responses">既知のサンプルのクラス (m*1)</param>
/// <param name="sampleIdx"></param>
/// <param name="isRegression"></param>
/// <param name="maxK">FindNearestに渡される近傍の最大値</param>
#else
/// <summary>
/// Training constructor
/// </summary>
/// <param name="trainData">Known samples (m*n)</param>
/// <param name="responses">Classes for known samples (m*1)</param>
/// <param name="sampleIdx"></param>
/// <param name="isRegression"></param>
/// <param name="maxK">Maximum number of neighbors to return</param>
#endif
public CvKNearest(
CvMat trainData,
CvMat responses,
CvMat sampleIdx = null,
bool isRegression = false,
int maxK = 32)
{
if (trainData == null)
throw new ArgumentNullException("trainData");
if (responses == null)
throw new ArgumentNullException("responses");
trainData.ThrowIfDisposed();
responses.ThrowIfDisposed();
ptr = NativeMethods.ml_CvKNearest_new2_CvMat(
trainData.CvPtr,
responses.CvPtr,
Cv2.ToPtr(sampleIdx),
isRegression ? 1 : 0,
maxK
);
}
示例3: Train
/// <summary>
/// MLPの学習と更新
/// </summary>
/// <param name="inputs">入力ベクトルの浮動小数点の行列で,1行で1ベクトル.</param>
/// <param name="outputs">対応する出力ベクトルの浮動小数点の行列で,1行で1ベクトル.</param>
/// <param name="sampleWeights">(RPROPのみ)各サンプルの重みを指定する浮動小数点のベクトル.オプション. 学習において,幾つかのサンプルは他のものより重要な場合がある. 例えば検出率と誤検出率間の適切なバランスを探すために,あるクラスの重みを増加させたい場合など.</param>
/// <param name="sampleIdx">用いるサンプルを表す整数のベクトル(すなわち_inputsと_outputsの行).</param>
/// <param name="param">学習パラメータ</param>
/// <param name="flags">学習アルゴリズムを制御する様々なパラメータ</param>
/// <returns>ネットワークの重みを計算/調整した繰り返し回数.</returns>
#else
/// <summary>
/// Trains/updates MLP
/// </summary>
/// <param name="inputs">A floating-point matrix of input vectors, one vector per row. </param>
/// <param name="outputs">A floating-point matrix of the corresponding output vectors, one vector per row. </param>
/// <param name="sampleWeights">(RPROP only) The optional floating-point vector of weights for each sample. Some samples may be more important than others for training, e.g. user may want to gain the weight of certain classes to find the right balance between hit-rate and false-alarm rate etc. </param>
/// <param name="sampleIdx">The optional integer vector indicating the samples (i.e. rows of _inputs and _outputs) that are taken into account. </param>
/// <param name="param">The training params.</param>
/// <param name="flags">The various parameters to control the training algorithm.</param>
/// <returns>the number of done iterations.</returns>
#endif
public virtual int Train(CvMat inputs, CvMat outputs, CvMat sampleWeights,
CvMat sampleIdx = null,
CvANN_MLP_TrainParams param = null,
MLPTrainingFlag flags = MLPTrainingFlag.Zero )
{
if (inputs == null)
throw new ArgumentNullException("inputs");
if (outputs == null)
throw new ArgumentNullException("outputs");
inputs.ThrowIfDisposed();
outputs.ThrowIfDisposed();
if(param == null)
param = new CvANN_MLP_TrainParams();
return NativeMethods.ml_CvANN_MLP_train_CvMat(
ptr,
inputs.CvPtr,
outputs.CvPtr,
Cv2.ToPtr(sampleWeights),
Cv2.ToPtr(sampleIdx),
param.NativeStruct,
(int)flags
);
}
示例4: 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(
CvMat 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_CvMat(
ptr, layerSizes.CvPtr, (int)activFunc, fParam1, fParam2);
}
示例5: CvBoost
/// <summary>
/// 学習データを与えて初期化
/// </summary>
/// <param name="trainData"></param>
/// <param name="tflag"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="varType"></param>
/// <param name="missingMask"></param>
/// <param name="param"></param>
#else
/// <summary>
/// Training constructor
/// </summary>
/// <param name="trainData"></param>
/// <param name="tflag"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="varType"></param>
/// <param name="missingMask"></param>
/// <param name="param"></param>
#endif
public CvBoost(
CvMat trainData,
DTreeDataLayout tflag,
CvMat responses,
CvMat varIdx = null,
CvMat sampleIdx = null,
CvMat varType = null,
CvMat missingMask = null,
CvBoostParams param = null)
{
if (trainData == null)
throw new ArgumentNullException("trainData");
if (responses == null)
throw new ArgumentNullException("responses");
trainData.ThrowIfDisposed();
responses.ThrowIfDisposed();
if (param == null)
param = new CvBoostParams();
ptr = NativeMethods.ml_CvBoost_new_CvMat(
trainData.CvPtr,
(int)tflag,
responses.CvPtr,
Cv2.ToPtr(varIdx),
Cv2.ToPtr(sampleIdx),
Cv2.ToPtr(varType),
Cv2.ToPtr(missingMask),
param.CvPtr
);
}
示例6: Train
/// <summary>
/// ブーストされた分類器の学習
/// </summary>
/// <param name="trainData"></param>
/// <param name="tflag"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="varType"></param>
/// <param name="missingMask"></param>
/// <param name="param"></param>
/// <param name="update"></param>
/// <returns></returns>
#else
/// <summary>
/// Trains boosted tree classifier
/// </summary>
/// <param name="trainData"></param>
/// <param name="tflag"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="varType"></param>
/// <param name="missingMask"></param>
/// <param name="param"></param>
/// <param name="update"></param>
/// <returns></returns>
#endif
public virtual bool Train(
CvMat trainData,
DTreeDataLayout tflag,
CvMat responses,
CvMat varIdx = null,
CvMat sampleIdx = null,
CvMat varType = null,
CvMat missingMask = null,
CvBoostParams param = null,
bool update = false )
{
if (trainData == null)
throw new ArgumentNullException("trainData");
if (responses == null)
throw new ArgumentNullException("responses");
trainData.ThrowIfDisposed();
responses.ThrowIfDisposed();
if(param == null)
param = new CvBoostParams();
int ret = NativeMethods.ml_CvBoost_train_CvMat(
ptr,
trainData.CvPtr,
(int)tflag,
responses.CvPtr,
Cv2.ToPtr(varIdx),
Cv2.ToPtr(sampleIdx),
Cv2.ToPtr(varType),
Cv2.ToPtr(missingMask),
param.CvPtr,
update ? 1 : 0);
return ret != 0;
}
示例7: CvSVM
/// <summary>
/// 初期化
/// </summary>
/// <param name="trainData"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="param"></param>
#else
/// <summary>
/// Training constructor
/// </summary>
/// <param name="trainData"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="param"></param>
#endif
public CvSVM(
CvMat trainData,
CvMat responses,
CvMat varIdx = null,
CvMat sampleIdx = null,
CvSVMParams param = null)
{
if (trainData == null)
throw new ArgumentNullException("trainData");
if (responses == null)
throw new ArgumentNullException("responses");
if(param == null)
param = new CvSVMParams();
trainData.ThrowIfDisposed();
responses.ThrowIfDisposed();
ptr = NativeMethods.ml_CvSVM_new2_CvMat(
trainData.CvPtr,
responses.CvPtr,
Cv2.ToPtr(varIdx),
Cv2.ToPtr(sampleIdx),
param.NativeStruct
);
}
示例8: Predict
/// <summary>
/// サンプルに対する応答を予測する
/// </summary>
/// <param name="sample"></param>
/// <param name="results"></param>
/// <returns></returns>
#else
/// <summary>
/// Predicts the response for sample
/// </summary>
/// <param name="sample"></param>
/// <param name="results"></param>
/// <returns></returns>
#endif
public virtual float Predict(CvMat sample, CvMat results)
{
if (sample == null)
throw new ArgumentNullException("sample");
if (results == null)
throw new ArgumentNullException("results");
sample.ThrowIfDisposed();
results.ThrowIfDisposed();
return NativeMethods.ml_CvSVM_predict_CvMat2(ptr, sample.CvPtr, results.CvPtr);
}
示例9: PredictProb
/// <summary>
/// 入力サンプルに対する出力を予測する
/// </summary>
/// <param name="sample"></param>
/// <param name="missing"></param>
/// <returns></returns>
#else
/// <summary>
/// Predicts the output for the input sample
/// </summary>
/// <param name="sample"></param>
/// <param name="missing"></param>
/// <returns></returns>
#endif
public virtual double PredictProb(CvMat sample, CvMat missing = null)
{
if (sample == null)
throw new ArgumentNullException("sample");
sample.ThrowIfDisposed();
return NativeMethods.ml_CvRTrees_predict_prob_CvMat(
ptr, sample.CvPtr, Cv2.ToPtr(missing));
}
示例10: TrainAuto
/// <summary>
/// SVMを最適なパラメータで学習する
/// </summary>
/// <param name="trainData"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="param"></param>
/// <param name="kFold">交差検定(Cross-validation)パラメータ.学習集合は,k_foldの部分集合に分割され,一つの部分集合がモデルの学習に用いられ,その他の部分集合はテスト集合となる.つまり,SVM アルゴリズムは,k_fold回実行される.</param>
/// <param name="cGrid"></param>
/// <param name="gammaGrid"></param>
/// <param name="pGrid"></param>
/// <param name="nuGrid"></param>
/// <param name="coefGrid"></param>
/// <param name="degreeGrid"></param>
/// <param name="balanced"></param>
/// <returns></returns>
#else
/// <summary>
/// Trains SVM with optimal parameters
/// </summary>
/// <param name="trainData"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="param"></param>
/// <param name="kFold">Cross-validation parameter. The training set is divided into k_fold subsets, one subset being used to train the model, the others forming the test set. So, the SVM algorithm is executed k_fold times. </param>
/// <param name="cGrid"></param>
/// <param name="gammaGrid"></param>
/// <param name="pGrid"></param>
/// <param name="nuGrid"></param>
/// <param name="coefGrid"></param>
/// <param name="degreeGrid"></param>
/// <param name="balanced"></param>
/// <returns></returns>
#endif
public virtual bool TrainAuto(
CvMat trainData,
CvMat responses,
CvMat varIdx,
CvMat sampleIdx,
CvSVMParams param,
int kFold = 10,
CvParamGrid? cGrid = null,
CvParamGrid? gammaGrid = null,
CvParamGrid? pGrid = null,
CvParamGrid? nuGrid = null,
CvParamGrid? coefGrid = null,
CvParamGrid? degreeGrid = null,
bool balanced = false)
{
if (trainData == null)
throw new ArgumentNullException("trainData");
if (responses == null)
throw new ArgumentNullException("responses");
if (varIdx == null)
throw new ArgumentNullException("varIdx");
if (sampleIdx == null)
throw new ArgumentNullException("sampleIdx");
trainData.ThrowIfDisposed();
responses.ThrowIfDisposed();
varIdx.ThrowIfDisposed();
sampleIdx.ThrowIfDisposed();
if(param == null)
param = new CvSVMParams();
var defaultGrid = GetDefaultGrid(SVMParamType.C);
var cGrid0 = cGrid.GetValueOrDefault(defaultGrid);
var gammaGrid0 = gammaGrid.GetValueOrDefault(defaultGrid);
var pGrid0 = pGrid.GetValueOrDefault(defaultGrid);
var nuGrid0 = nuGrid.GetValueOrDefault(defaultGrid);
var coefGrid0 = coefGrid.GetValueOrDefault(defaultGrid);
var degreeGrid0 = degreeGrid.GetValueOrDefault(defaultGrid);
return NativeMethods.ml_CvSVM_train_auto_CvMat(
ptr,
trainData.CvPtr,
responses.CvPtr,
varIdx.CvPtr,
sampleIdx.CvPtr,
param.NativeStruct,
kFold,
cGrid0,
gammaGrid0,
pGrid0,
nuGrid0,
coefGrid0,
degreeGrid0,
balanced ? 1 : 0) != 0;
}
示例11: Predict
/// <summary>
/// サンプルに対する応答を予測する
/// </summary>
/// <param name="sample">未知のサンプル (l*n)</param>
/// <param name="results">既知のサンプルのクラス (l*1)</param>
#else
/// <summary>
/// Predicts the response for sample(s)
/// </summary>
/// <param name="sample">Unkown samples (l*n)</param>
/// <param name="results">Classes for known samples (l*1)</param>
#endif
public virtual float Predict(CvMat sample, CvMat results = null)
{
if (sample == null)
throw new ArgumentNullException("sample");
sample.ThrowIfDisposed();
return NativeMethods.ml_CvNormalBayesClassifier_predict_CvMat(
ptr,
sample.CvPtr,
Cv2.ToPtr(results));
}
示例12: Train
/// <summary>
/// モデルの学習
/// </summary>
/// <param name="trainData">既知のサンプル (m*n)</param>
/// <param name="responses">既知のサンプルのクラス (m*1)</param>
/// <param name="sampleIdx"></param>
/// <param name="isRegression"></param>
/// <param name="maxK">FindNearestに渡される近傍の最大数</param>
/// <param name="updateBase">モデルを始めから作り直す(false)か,新しい教師データを使って更新する(true)か</param>
/// <returns></returns>
#else
/// <summary>
/// Trains the model
/// </summary>
/// <param name="trainData">Known samples (m*n)</param>
/// <param name="responses">Classes for known samples (m*1)</param>
/// <param name="sampleIdx"></param>
/// <param name="isRegression"></param>
/// <param name="maxK">Maximum number of neighbors to return</param>
/// <param name="updateBase">Adds known samples to model(true) or makes a new one(false)</param>
/// <returns></returns>
#endif
public virtual bool Train(
CvMat trainData,
CvMat responses,
CvMat sampleIdx = null,
bool isRegression = false,
int maxK = 32,
bool updateBase = false)
{
if (trainData == null)
throw new ArgumentNullException("trainData");
if (responses == null)
throw new ArgumentNullException("responses");
trainData.ThrowIfDisposed();
responses.ThrowIfDisposed();
return NativeMethods.ml_CvKNearest_train_CvMat(
ptr,
trainData.CvPtr,
responses.CvPtr,
Cv2.ToPtr(sampleIdx),
isRegression ? 1 : 0,
maxK,
updateBase ? 1 : 0
) != 0;
}
示例13: Train
/// <summary>
///
/// </summary>
/// <param name="trainData"></param>
/// <param name="tflag"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="varType"></param>
/// <param name="missingMask"></param>
/// <param name="param"></param>
/// <returns></returns>
#else
/// <summary>
///
/// </summary>
/// <param name="trainData"></param>
/// <param name="tflag"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="varType"></param>
/// <param name="missingMask"></param>
/// <param name="param"></param>
/// <returns></returns>
#endif
public virtual bool Train(
CvMat trainData,
int tflag,
CvMat responses,
CvMat varIdx = null,
CvMat sampleIdx = null,
CvMat varType = null,
CvMat missingMask = null,
CvRTParams param = null)
{
if (trainData == null)
throw new ArgumentNullException("trainData");
if (responses == null)
throw new ArgumentNullException("responses");
trainData.ThrowIfDisposed();
responses.ThrowIfDisposed();
if (param == null)
param = new CvRTParams();
return NativeMethods.ml_CvERTrees_train1(
ptr,
trainData.CvPtr,
tflag,
responses.CvPtr,
Cv2.ToPtr(varIdx),
Cv2.ToPtr(sampleIdx),
Cv2.ToPtr(varType),
Cv2.ToPtr(missingMask),
param.CvPtr) != 0;
}
示例14: 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(CvMat inputs, CvMat 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);
}
示例15: CvDTreeTrainData
/// <summary>
/// 学習データを与えて初期化
/// </summary>
/// <param name="trainData"></param>
/// <param name="tflag"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="varType"></param>
/// <param name="missingMask"></param>
/// <param name="param"></param>
/// <param name="shared"></param>
/// <param name="addLabels"></param>
/// <returns></returns>
#else
/// <summary>
/// Training constructor
/// </summary>
/// <param name="trainData"></param>
/// <param name="tflag"></param>
/// <param name="responses"></param>
/// <param name="varIdx"></param>
/// <param name="sampleIdx"></param>
/// <param name="varType"></param>
/// <param name="missingMask"></param>
/// <param name="param"></param>
/// <param name="shared"></param>
/// <param name="addLabels"></param>
/// <returns></returns>
#endif
public CvDTreeTrainData(
CvMat trainData,
DTreeDataLayout tflag,
CvMat responses,
CvMat varIdx = null,
CvMat sampleIdx = null,
CvMat varType = null,
CvMat missingMask = null,
CvDTreeParams param = null,
bool shared = false,
bool addLabels = false)
{
if (trainData == null)
throw new ArgumentNullException("trainData");
if (responses == null)
throw new ArgumentNullException("responses");
trainData.ThrowIfDisposed();
responses.ThrowIfDisposed();
if(param == null)
param = new CvDTreeParams();
ptr = NativeMethods.ml_CvDTreeTrainData_new2(
trainData.CvPtr,
(int)tflag,
responses.CvPtr,
Cv2.ToPtr(varIdx),
Cv2.ToPtr(sampleIdx),
Cv2.ToPtr(varType),
Cv2.ToPtr(missingMask),
param.CvPtr,
shared ? 1 : 0,
addLabels ? 1 : 0
);
}