public static HClassSvm Deserialize(Stream stream) { HClassSvm hclassSvm = new HClassSvm(); hclassSvm.DeserializeClassSvm(HSerializedItem.Deserialize(stream)); return(hclassSvm); }
/// <summary> /// Selects an optimal combination of features to classify the provided data. /// Instance represents: Handle of the training data. /// </summary> /// <param name="selectionMethod">Method to perform the selection. Default: "greedy"</param> /// <param name="genParamName">Names of generic parameters to configure the selection process and the classifier. Default: []</param> /// <param name="genParamValue">Values of generic parameters to configure the selection process and the classifier. Default: []</param> /// <param name="selectedFeatureIndices">The selected feature set, contains indices.</param> /// <param name="score">The achieved score using two-fold cross-validation.</param> /// <returns>A trained SVM classifier using only the selected features.</returns> public HClassSvm SelectFeatureSetSvm( string selectionMethod, string genParamName, double genParamValue, out HTuple selectedFeatureIndices, out HTuple score) { IntPtr proc = HalconAPI.PreCall(1800); this.Store(proc, 0); HalconAPI.StoreS(proc, 1, selectionMethod); HalconAPI.StoreS(proc, 2, genParamName); HalconAPI.StoreD(proc, 3, genParamValue); HalconAPI.InitOCT(proc, 0); HalconAPI.InitOCT(proc, 1); HalconAPI.InitOCT(proc, 2); int err1 = HalconAPI.CallProcedure(proc); HClassSvm hclassSvm; int err2 = HClassSvm.LoadNew(proc, 0, err1, out hclassSvm); int err3 = HTuple.LoadNew(proc, 1, err2, out selectedFeatureIndices); int procResult = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out score); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); return(hclassSvm); }
public HClassSvm Clone() { HSerializedItem serializedItemHandle = this.SerializeClassSvm(); HClassSvm hclassSvm = new HClassSvm(); hclassSvm.DeserializeClassSvm(serializedItemHandle); serializedItemHandle.Dispose(); return(hclassSvm); }
/// <summary> /// Add training data to a support vector machine (SVM). /// Instance represents: Training data for a classifier. /// </summary> /// <param name="SVMHandle">Handle of a SVM which receives the training data.</param> public void AddClassTrainDataSvm(HClassSvm SVMHandle) { IntPtr proc = HalconAPI.PreCall(1792); this.Store(proc, 1); HalconAPI.Store(proc, 0, (HTool)SVMHandle); int procResult = HalconAPI.CallProcedure(proc); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); GC.KeepAlive((object)SVMHandle); }
internal static int LoadNew(IntPtr proc, int parIndex, int err, out HClassSvm[] obj) { HTuple tuple; err = HTuple.LoadNew(proc, parIndex, err, out tuple); obj = new HClassSvm[tuple.Length]; for (int index = 0; index < tuple.Length; ++index) { obj[index] = new HClassSvm(tuple[index].IP); } return(err); }
/// <summary> /// Get the training data of a support vector machine (SVM). /// Modified instance represents: Handle of the training data of the classifier. /// </summary> /// <param name="SVMHandle">Handle of a SVM that contains training data.</param> public void GetClassTrainDataSvm(HClassSvm SVMHandle) { this.Dispose(); IntPtr proc = HalconAPI.PreCall(1791); HalconAPI.Store(proc, 0, (HTool)SVMHandle); HalconAPI.InitOCT(proc, 0); int err = HalconAPI.CallProcedure(proc); int procResult = this.Load(proc, 0, err); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); GC.KeepAlive((object)SVMHandle); }
/// <summary> /// Approximate a trained support vector machine by a reduced support vector machine for faster classification. /// Instance represents: Original SVM handle. /// </summary> /// <param name="method">Type of postprocessing to reduce number of SV. Default: "bottom_up"</param> /// <param name="minRemainingSV">Minimum number of remaining SVs. Default: 2</param> /// <param name="maxError">Maximum allowed error of reduction. Default: 0.001</param> /// <returns>SVMHandle of reduced SVM.</returns> public HClassSvm ReduceClassSvm(string method, int minRemainingSV, double maxError) { IntPtr proc = HalconAPI.PreCall(1852); this.Store(proc, 0); HalconAPI.StoreS(proc, 1, method); HalconAPI.StoreI(proc, 2, minRemainingSV); HalconAPI.StoreD(proc, 3, maxError); HalconAPI.InitOCT(proc, 0); int err = HalconAPI.CallProcedure(proc); HClassSvm hclassSvm; int procResult = HClassSvm.LoadNew(proc, 0, err, out hclassSvm); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); return(hclassSvm); }
/// <summary> /// Create a look-up table using a Support-Vector-Machine to classify byte images. /// Modified instance represents: Handle of the LUT classifier. /// </summary> /// <param name="SVMHandle">SVM handle.</param> /// <param name="genParamName">Names of the generic parameters that can be adjusted for the LUT classifier creation. Default: []</param> /// <param name="genParamValue">Values of the generic parameters that can be adjusted for the LUT classifier creation. Default: []</param> public HClassLUT(HClassSvm SVMHandle, HTuple genParamName, HTuple genParamValue) { IntPtr proc = HalconAPI.PreCall(1821); HalconAPI.Store(proc, 0, (HTool)SVMHandle); HalconAPI.Store(proc, 1, genParamName); HalconAPI.Store(proc, 2, genParamValue); HalconAPI.InitOCT(proc, 0); int err = HalconAPI.CallProcedure(proc); HalconAPI.UnpinTuple(genParamName); HalconAPI.UnpinTuple(genParamValue); int procResult = this.Load(proc, 0, err); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); GC.KeepAlive((object)SVMHandle); }
internal static int LoadNew(IntPtr proc, int parIndex, int err, out HClassSvm obj) { obj = new HClassSvm(HTool.UNDEF); return(obj.Load(proc, parIndex, err)); }