示例#1
0
        /// <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 referring.</param>
        /// <param name="score">The achieved score using two-fold cross-validation.</param>
        /// <returns>A trained MLP classifier using only the selected  features.</returns>
        public HClassMlp SelectFeatureSetMlp(
            string selectionMethod,
            string genParamName,
            double genParamValue,
            out HTuple selectedFeatureIndices,
            out HTuple score)
        {
            IntPtr proc = HalconAPI.PreCall(1799);

            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);
            HClassMlp hclassMlp;
            int       err2       = HClassMlp.LoadNew(proc, 0, err1, out hclassMlp);
            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(hclassMlp);
        }
示例#2
0
        public static HClassMlp Deserialize(Stream stream)
        {
            HClassMlp hclassMlp = new HClassMlp();

            hclassMlp.DeserializeClassMlp(HSerializedItem.Deserialize(stream));
            return(hclassMlp);
        }
示例#3
0
        public HClassMlp Clone()
        {
            HSerializedItem serializedItemHandle = this.SerializeClassMlp();
            HClassMlp       hclassMlp            = new HClassMlp();

            hclassMlp.DeserializeClassMlp(serializedItemHandle);
            serializedItemHandle.Dispose();
            return(hclassMlp);
        }
示例#4
0
        /// <summary>
        ///   Add training data to a multilayer perceptron (MLP).
        ///   Instance represents: Training data for a classifier.
        /// </summary>
        /// <param name="MLPHandle">MLP handle which receives the training data.</param>
        public void AddClassTrainDataMlp(HClassMlp MLPHandle)
        {
            IntPtr proc = HalconAPI.PreCall(1788);

            this.Store(proc, 1);
            HalconAPI.Store(proc, 0, (HTool)MLPHandle);
            int procResult = HalconAPI.CallProcedure(proc);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)MLPHandle);
        }
示例#5
0
        internal static int LoadNew(IntPtr proc, int parIndex, int err, out HClassMlp[] obj)
        {
            HTuple tuple;

            err = HTuple.LoadNew(proc, parIndex, err, out tuple);
            obj = new HClassMlp[tuple.Length];
            for (int index = 0; index < tuple.Length; ++index)
            {
                obj[index] = new HClassMlp(tuple[index].IP);
            }
            return(err);
        }
示例#6
0
        /// <summary>
        ///   Get the training data of a multilayer perceptron (MLP).
        ///   Modified instance represents: Handle of the training data of the classifier.
        /// </summary>
        /// <param name="MLPHandle">Handle of a MLP that contains training data.</param>
        public void GetClassTrainDataMlp(HClassMlp MLPHandle)
        {
            this.Dispose();
            IntPtr proc = HalconAPI.PreCall(1787);

            HalconAPI.Store(proc, 0, (HTool)MLPHandle);
            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)MLPHandle);
        }
示例#7
0
        /// <summary>
        ///   Create a look-up table using a multi-layer perceptron to classify byte images.
        ///   Modified instance represents: Handle of the LUT classifier.
        /// </summary>
        /// <param name="MLPHandle">MLP 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(HClassMlp MLPHandle, HTuple genParamName, HTuple genParamValue)
        {
            IntPtr proc = HalconAPI.PreCall(1822);

            HalconAPI.Store(proc, 0, (HTool)MLPHandle);
            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)MLPHandle);
        }
示例#8
0
 internal static int LoadNew(IntPtr proc, int parIndex, int err, out HClassMlp obj)
 {
     obj = new HClassMlp(HTool.UNDEF);
     return(obj.Load(proc, parIndex, err));
 }