/// <summary>
        ///   Selects an optimal combination from a set 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 classifier. Default: []</param>
        /// <param name="genParamValue">Values of generic parameters to configure  the classifier. Default: []</param>
        /// <param name="selectedFeatureIndices">The selected feature set, contains indices or names.</param>
        /// <param name="score">The achieved score using two-fold cross-validation.</param>
        /// <returns>A trained GMM classifier using only the selected  features.</returns>
        public HClassGmm SelectFeatureSetGmm(
            string selectionMethod,
            string genParamName,
            double genParamValue,
            out HTuple selectedFeatureIndices,
            out HTuple score)
        {
            IntPtr proc = HalconAPI.PreCall(1801);

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

            hclassGmm.DeserializeClassGmm(HSerializedItem.Deserialize(stream));
            return(hclassGmm);
        }
Beispiel #3
0
        public HClassGmm Clone()
        {
            HSerializedItem serializedItemHandle = this.SerializeClassGmm();
            HClassGmm       hclassGmm            = new HClassGmm();

            hclassGmm.DeserializeClassGmm(serializedItemHandle);
            serializedItemHandle.Dispose();
            return(hclassGmm);
        }
        /// <summary>
        ///   Add training data to a Gaussian Mixture Model (GMM).
        ///   Instance represents: Handle of training data for a classifier.
        /// </summary>
        /// <param name="GMMHandle">Handle of a GMM which receives the training data.</param>
        public void AddClassTrainDataGmm(HClassGmm GMMHandle)
        {
            IntPtr proc = HalconAPI.PreCall(1786);

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

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

            err = HTuple.LoadNew(proc, parIndex, err, out tuple);
            obj = new HClassGmm[tuple.Length];
            for (int index = 0; index < tuple.Length; ++index)
            {
                obj[index] = new HClassGmm(tuple[index].IP);
            }
            return(err);
        }
        /// <summary>
        ///   Get the training data of a Gaussian Mixture Model (GMM).
        ///   Modified instance represents: Handle of the training data of the classifier.
        /// </summary>
        /// <param name="GMMHandle">Handle of a GMM that contains training data.</param>
        public void GetClassTrainDataGmm(HClassGmm GMMHandle)
        {
            this.Dispose();
            IntPtr proc = HalconAPI.PreCall(1785);

            HalconAPI.Store(proc, 0, (HTool)GMMHandle);
            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)GMMHandle);
        }
Beispiel #7
0
        /// <summary>
        ///   Create a look-up table using a gaussian mixture model to classify byte images.
        ///   Modified instance represents: Handle of the LUT classifier.
        /// </summary>
        /// <param name="GMMHandle">GMM 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(HClassGmm GMMHandle, HTuple genParamName, HTuple genParamValue)
        {
            IntPtr proc = HalconAPI.PreCall(1820);

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