Esempio n. 1
0
        /// <summary>
        ///   Get parameters that are used by the bar code reader when processing a specific bar code type.
        ///   Instance represents: Handle of the bar code model.
        /// </summary>
        /// <param name="codeTypes">Names of the bar code types for which parameters should be queried. Default: "EAN-13"</param>
        /// <param name="genParamName">Names of the generic parameters that are to be queried for the bar code model. Default: "check_char"</param>
        /// <returns>Values of the generic parameters.</returns>
        public HTuple GetBarCodeParamSpecific(HTuple codeTypes, HTuple genParamName)
        {
            IntPtr proc = HalconAPI.PreCall(1995);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, codeTypes);
            HalconAPI.Store(proc, 2, genParamName);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(codeTypes);
            HalconAPI.UnpinTuple(genParamName);
            HTuple tuple;
            int    procResult = HTuple.LoadNew(proc, 0, err, out tuple);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
Esempio n. 2
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 void CreateClassLutMlp(HClassMlp MLPHandle, HTuple genParamName, HTuple genParamValue)
        {
            this.Dispose();
            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);
        }
Esempio n. 3
0
        /// <summary>
        ///   Detect and read bar code symbols in an image.
        ///   Instance represents: Handle of the bar code model.
        /// </summary>
        /// <param name="image">Input image. If the image has a reduced domain, the barcode search is reduced to that domain. This usually reduces the runtime of the operator. However, if the barcode is not fully inside the domain, the barcode cannot be decoded correctly.</param>
        /// <param name="codeType">Type of the searched bar code. Default: "auto"</param>
        /// <param name="decodedDataStrings">Data strings of all successfully decoded bar codes.</param>
        /// <returns>Regions of the successfully decoded bar code symbols.</returns>
        public HRegion FindBarCode(HImage image, string codeType, out string decodedDataStrings)
        {
            IntPtr proc = HalconAPI.PreCall(1993);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.StoreS(proc, 1, codeType);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 0);
            int     err1 = HalconAPI.CallProcedure(proc);
            HRegion hregion;
            int     err2       = HRegion.LoadNew(proc, 1, err1, out hregion);
            int     procResult = HalconAPI.LoadS(proc, 0, err2, out decodedDataStrings);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
            return(hregion);
        }
Esempio n. 4
0
        /// <summary>
        ///   Retrieve classification results inferred by a deep-learning-based  classifier.
        ///   Instance represents: Handle of the deep learning classification  results.
        /// </summary>
        /// <param name="index">Index of the image in the batch. Default: "all"</param>
        /// <param name="genResultName">Name of the generic parameter. Default: "predicted_classes"</param>
        /// <returns>Value of the generic parameter, either the confidence  values, the class names or class indices.</returns>
        public HTuple GetDlClassifierResult(HTuple index, HTuple genResultName)
        {
            IntPtr proc = HalconAPI.PreCall(2115);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, index);
            HalconAPI.Store(proc, 2, genResultName);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(index);
            HalconAPI.UnpinTuple(genResultName);
            HTuple tuple;
            int    procResult = HTuple.LoadNew(proc, 0, err, out tuple);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
Esempio n. 5
0
        /// <summary>
        ///   Retrieve information about an object of a sample identifier.
        ///   Instance represents: Handle of the sample identifier.
        /// </summary>
        /// <param name="objectIdx">Index of the object for which information is retrieved.</param>
        /// <param name="infoName">Define, for which kind of object information is retrieved. Default: "num_training_objects"</param>
        /// <returns>Information about the object.</returns>
        public HTuple GetSampleIdentifierObjectInfo(HTuple objectIdx, HTuple infoName)
        {
            IntPtr proc = HalconAPI.PreCall(907);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, objectIdx);
            HalconAPI.Store(proc, 2, infoName);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(objectIdx);
            HalconAPI.UnpinTuple(infoName);
            HTuple tuple;
            int    procResult = HTuple.LoadNew(proc, 0, err, out tuple);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
Esempio n. 6
0
        /// <summary>
        ///   Compose two functions.
        ///   Instance represents: Input function 1.
        /// </summary>
        /// <param name="function2">Input function 2.</param>
        /// <param name="border">Border treatment for the input functions. Default: "constant"</param>
        /// <returns>Composed function.</returns>
        public HFunction1D ComposeFunct1d(HFunction1D function2, string border)
        {
            IntPtr proc = HalconAPI.PreCall(1377);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HData)function2);
            HalconAPI.StoreS(proc, 2, border);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            this.UnpinTuple();
            HalconAPI.UnpinTuple((HTuple)((HData)function2));
            HFunction1D hfunction1D;
            int         procResult = HFunction1D.LoadNew(proc, 0, err, out hfunction1D);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(hfunction1D);
        }
Esempio n. 7
0
        /// <summary>
        ///   Return the value of a function at an arbitrary position.
        ///   Instance represents: Input function.
        /// </summary>
        /// <param name="x">X coordinate at which the function should be evaluated.</param>
        /// <param name="border">Border treatment for the input function. Default: "constant"</param>
        /// <returns>Y value at the given x value.</returns>
        public HTuple GetYValueFunct1d(HTuple x, string border)
        {
            IntPtr proc = HalconAPI.PreCall(1385);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, x);
            HalconAPI.StoreS(proc, 2, border);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            this.UnpinTuple();
            HalconAPI.UnpinTuple(x);
            HTuple tuple;
            int    procResult = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, err, out tuple);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
Esempio n. 8
0
        /// <summary>
        ///   Test an OCR classifier.
        ///   Instance represents: ID of the desired OCR-classifier.
        /// </summary>
        /// <param name="character">Characters to be tested.</param>
        /// <param name="image">Gray values for the characters.</param>
        /// <param name="classVal">Class (name) of the characters. Default: "a"</param>
        /// <returns>Confidence for the character to belong to the class.</returns>
        public double TestdOcrClassBox(HRegion character, HImage image, string classVal)
        {
            IntPtr proc = HalconAPI.PreCall(725);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)character);
            HalconAPI.Store(proc, 2, (HObjectBase)image);
            HalconAPI.StoreS(proc, 1, classVal);
            HalconAPI.InitOCT(proc, 0);
            int    err = HalconAPI.CallProcedure(proc);
            double doubleValue;
            int    procResult = HalconAPI.LoadD(proc, 0, err, out doubleValue);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)character);
            GC.KeepAlive((object)image);
            return(doubleValue);
        }
Esempio n. 9
0
        /// <summary>
        ///   Create a model to perform 3D-measurements using the sheet-of-light technique.
        ///   Modified instance represents: Handle for using and accessing the sheet-of-light model.
        /// </summary>
        /// <param name="profileRegion">Region of the images containing the profiles to be processed. If the provided region is not rectangular, its smallest enclosing rectangle will be used.</param>
        /// <param name="genParamName">Names of the generic parameters that can be adjusted for the sheet-of-light model. Default: "min_gray"</param>
        /// <param name="genParamValue">Values of the generic parameters that can be adjusted for the sheet-of-light model. Default: 50</param>
        public void CreateSheetOfLightModel(
            HRegion profileRegion,
            string genParamName,
            int genParamValue)
        {
            this.Dispose();
            IntPtr proc = HalconAPI.PreCall(391);

            HalconAPI.Store(proc, 1, (HObjectBase)profileRegion);
            HalconAPI.StoreS(proc, 0, genParamName);
            HalconAPI.StoreI(proc, 1, genParamValue);
            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)profileRegion);
        }
        /// <summary>
        ///   Get details of a result from deformable surface based matching.
        ///   Instance represents: Handle of the deformable surface matching result.
        /// </summary>
        /// <param name="resultName">Name of the result property. Default: "sampled_scene"</param>
        /// <param name="resultIndex">Index of the result property. Default: 0</param>
        /// <returns>Value of the result property.</returns>
        public HTuple GetDeformableSurfaceMatchingResult(HTuple resultName, HTuple resultIndex)
        {
            IntPtr proc = HalconAPI.PreCall(1019);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, resultName);
            HalconAPI.Store(proc, 2, resultIndex);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(resultName);
            HalconAPI.UnpinTuple(resultIndex);
            HTuple tuple;
            int    procResult = HTuple.LoadNew(proc, 0, err, out tuple);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
Esempio n. 11
0
        /// <summary>
        ///   Add a translation to a homogeneous 3D transformation matrix.
        ///   Instance represents: Input transformation matrix.
        /// </summary>
        /// <param name="tx">Translation along the x-axis. Default: 64</param>
        /// <param name="ty">Translation along the y-axis. Default: 64</param>
        /// <param name="tz">Translation along the z-axis. Default: 64</param>
        /// <returns>Output transformation matrix.</returns>
        public HHomMat3D HomMat3dTranslateLocal(double tx, double ty, double tz)
        {
            IntPtr proc = HalconAPI.PreCall(251);

            this.Store(proc, 0);
            HalconAPI.StoreD(proc, 1, tx);
            HalconAPI.StoreD(proc, 2, ty);
            HalconAPI.StoreD(proc, 3, tz);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            this.UnpinTuple();
            HHomMat3D hhomMat3D;
            int       procResult = HHomMat3D.LoadNew(proc, 0, err, out hhomMat3D);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(hhomMat3D);
        }
Esempio n. 12
0
        /// <summary>
        ///   Receive one or more messages from the message queue.
        ///   Instance represents: Message queue handle.
        /// </summary>
        /// <param name="genParamName">Names of optional generic parameters Default: "timeout"</param>
        /// <param name="genParamValue">Values of optional generic parameters Default: "infinite"</param>
        /// <returns>Handle(s) of the dequeued message(s).</returns>
        public HMessage[] DequeueMessage(HTuple genParamName, HTuple genParamValue)
        {
            IntPtr proc = HalconAPI.PreCall(530);

            this.Store(proc, 0);
            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);
            HMessage[] hmessageArray;
            int        procResult = HMessage.LoadNew(proc, 0, err, out hmessageArray);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(hmessageArray);
        }
Esempio n. 13
0
        /// <summary>
        ///   Replaces one or more elements of an iconic object tuple.
        ///   Instance represents: Iconic Input Object.
        /// </summary>
        /// <param name="objectsReplace">Element(s) to replace.</param>
        /// <param name="index">Index/Indices of elements to be replaced.</param>
        /// <returns>Tuple with replaced elements.</returns>
        public HXLDModPara ReplaceObj(HXLDModPara objectsReplace, HTuple index)
        {
            IntPtr proc = HalconAPI.PreCall(2125);

            this.Store(proc, 1);
            HalconAPI.Store(proc, 2, (HObjectBase)objectsReplace);
            HalconAPI.Store(proc, 0, index);
            HalconAPI.InitOCT(proc, 1);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(index);
            HXLDModPara hxldModPara;
            int         procResult = HXLDModPara.LoadNew(proc, 1, err, out hxldModPara);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)objectsReplace);
            return(hxldModPara);
        }
Esempio n. 14
0
        /// <summary>
        ///   Add an instance of a 3D object model to a 3D scene.
        ///   Instance represents: Handle of the 3D scene.
        /// </summary>
        /// <param name="objectModel3D">Handle of the 3D object model.</param>
        /// <param name="pose">Pose of the 3D object model.</param>
        /// <returns>Index of the new instance in the 3D scene.</returns>
        public int AddScene3dInstance(HObjectModel3D objectModel3D, HPose pose)
        {
            IntPtr proc = HalconAPI.PreCall(1217);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HTool)objectModel3D);
            HalconAPI.Store(proc, 2, (HData)pose);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple((HTuple)((HData)pose));
            int intValue;
            int procResult = HalconAPI.LoadI(proc, 0, err, out intValue);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)objectModel3D);
            return(intValue);
        }
Esempio n. 15
0
        /// <summary>
        ///   Compare iconic objects regarding equality.
        ///   Instance represents: Reference objects.
        /// </summary>
        /// <param name="objects2">Test objects.</param>
        /// <param name="epsilon">Maximum allowed difference between two gray values or  coordinates etc. Default: 0.0</param>
        /// <returns>Boolean result value.</returns>
        public int CompareObj(HXLDModPara objects2, HTuple epsilon)
        {
            IntPtr proc = HalconAPI.PreCall(588);

            this.Store(proc, 1);
            HalconAPI.Store(proc, 2, (HObjectBase)objects2);
            HalconAPI.Store(proc, 0, epsilon);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(epsilon);
            int intValue;
            int procResult = HalconAPI.LoadI(proc, 0, err, out intValue);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)objects2);
            return(intValue);
        }
Esempio n. 16
0
        /// <summary>
        ///   Choose all contours or polygons containing a given point.
        ///   Instance represents: Contours or polygons to be examined.
        /// </summary>
        /// <param name="row">Line coordinate of the test point. Default: 100.0</param>
        /// <param name="column">Column coordinate of the test point. Default: 100.0</param>
        /// <returns>All contours or polygons containing the test point.</returns>
        public HXLDModPara SelectXldPoint(HTuple row, HTuple column)
        {
            IntPtr proc = HalconAPI.PreCall(1676);

            this.Store(proc, 1);
            HalconAPI.Store(proc, 0, row);
            HalconAPI.Store(proc, 1, column);
            HalconAPI.InitOCT(proc, 1);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(row);
            HalconAPI.UnpinTuple(column);
            HXLDModPara hxldModPara;
            int         procResult = HXLDModPara.LoadNew(proc, 1, err, out hxldModPara);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(hxldModPara);
        }
Esempio n. 17
0
        /// <summary>
        ///   Create a look-up table using a k-nearest neighbors classifier (k-NN) to classify byte images.
        ///   Instance represents: Handle of the k-NN classifier.
        /// </summary>
        /// <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>
        /// <returns>Handle of the LUT classifier.</returns>
        public HClassLUT CreateClassLutKnn(HTuple genParamName, HTuple genParamValue)
        {
            IntPtr proc = HalconAPI.PreCall(1819);

            this.Store(proc, 0);
            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);
            HClassLUT hclassLut;
            int       procResult = HClassLUT.LoadNew(proc, 0, err, out hclassLut);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(hclassLut);
        }
        /// <summary>
        ///   Interpolation of scattered data using a scattered data interpolator.
        ///   Instance represents: Handle of the scattered data interpolator
        /// </summary>
        /// <param name="row">Row coordinates of points  to be interpolated</param>
        /// <param name="column">Column coordinates of points  to be interpolated</param>
        /// <returns>Values of interpolated points</returns>
        public HTuple InterpolateScatteredData(HTuple row, HTuple column)
        {
            IntPtr proc = HalconAPI.PreCall(291);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, row);
            HalconAPI.Store(proc, 2, column);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(row);
            HalconAPI.UnpinTuple(column);
            HTuple tuple;
            int    procResult = HTuple.LoadNew(proc, 0, err, out tuple);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
Esempio n. 19
0
        /// <summary>Query specific parameters of I/O channels.</summary>
        /// <param name="IOChannelHandle">Handles of the opened I/O channels.</param>
        /// <param name="genParamName">Parameter names. Default: "param_name"</param>
        /// <returns>Parameter values.</returns>
        public static HTuple GetIoChannelParam(HIOChannel[] IOChannelHandle, HTuple genParamName)
        {
            HTuple htuple = HTool.ConcatArray((HTool[])IOChannelHandle);
            IntPtr proc   = HalconAPI.PreCall(2014);

            HalconAPI.Store(proc, 0, htuple);
            HalconAPI.Store(proc, 1, genParamName);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(htuple);
            HalconAPI.UnpinTuple(genParamName);
            HTuple tuple;
            int    procResult = HTuple.LoadNew(proc, 0, err, out tuple);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)IOChannelHandle);
            return(tuple);
        }
Esempio n. 20
0
        /// <summary>
        ///   Search for the next neighbors for a given feature vector.
        ///   Instance represents: Handle of the k-NN classifier.
        /// </summary>
        /// <param name="features">Features that should be classified.</param>
        /// <param name="rating">A rating for the results. This value contains either a  distance, a frequency or a weighted frequency.</param>
        /// <returns>The classification result, either class IDs or sample  indices.</returns>
        public HTuple ClassifyClassKnn(HTuple features, out HTuple rating)
        {
            IntPtr proc = HalconAPI.PreCall(1813);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, features);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int err1 = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(features);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, HTupleType.INTEGER, err1, out tuple);
            int    procResult = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out rating);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
Esempio n. 21
0
        /// <summary>Read a value from the specified I/O channels.</summary>
        /// <param name="IOChannelHandle">Handles of the opened I/O channels.</param>
        /// <param name="status">Status of read value.</param>
        /// <returns>Read value.</returns>
        public static HTuple ReadIoChannel(HIOChannel[] IOChannelHandle, out HTuple status)
        {
            HTuple htuple = HTool.ConcatArray((HTool[])IOChannelHandle);
            IntPtr proc   = HalconAPI.PreCall(2012);

            HalconAPI.Store(proc, 0, htuple);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int err1 = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(htuple);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, err1, out tuple);
            int    procResult = HTuple.LoadNew(proc, 1, HTupleType.INTEGER, err2, out status);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)IOChannelHandle);
            return(tuple);
        }
Esempio n. 22
0
        /// <summary>
        ///   Query information about channels of the specified I/O device.
        ///   Instance represents: Handle of the opened I/O device.
        /// </summary>
        /// <param name="IOChannelName">Channel names to query.</param>
        /// <param name="query">Name of the query. Default: "param_name"</param>
        /// <returns>List of values (according to Query).</returns>
        public HTuple QueryIoDevice(HTuple IOChannelName, HTuple query)
        {
            IntPtr proc = HalconAPI.PreCall(2017);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, IOChannelName);
            HalconAPI.Store(proc, 2, query);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(IOChannelName);
            HalconAPI.UnpinTuple(query);
            HTuple tuple;
            int    procResult = HTuple.LoadNew(proc, 0, err, out tuple);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
Esempio n. 23
0
        /// <summary>
        ///   Classify a feature vector by a support vector machine.
        ///   Instance represents: SVM handle.
        /// </summary>
        /// <param name="features">Feature vector.</param>
        /// <param name="num">Number of best classes to determine. Default: 1</param>
        /// <returns>Result of classifying the feature vector with the SVM.</returns>
        public HTuple ClassifyClassSvm(HTuple features, HTuple num)
        {
            IntPtr proc = HalconAPI.PreCall(1851);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, features);
            HalconAPI.Store(proc, 2, num);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(features);
            HalconAPI.UnpinTuple(num);
            HTuple tuple;
            int    procResult = HTuple.LoadNew(proc, 0, HTupleType.INTEGER, err, out tuple);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
Esempio n. 24
0
        /// <summary>
        ///   Find the best matches of a descriptor model in an image.
        ///   Instance represents: The handle to the descriptor model.
        /// </summary>
        /// <param name="image">Input image where the model should be found.</param>
        /// <param name="detectorParamName">The detector's parameter names. Default: []</param>
        /// <param name="detectorParamValue">Values of the detector's parameters. Default: []</param>
        /// <param name="descriptorParamName">The descriptor's parameter names. Default: []</param>
        /// <param name="descriptorParamValue">Values of the descriptor's parameters. Default: []</param>
        /// <param name="minScore">Minimum score of the instances of the models to be found. Default: 0.2</param>
        /// <param name="numMatches">Maximal number of found instances. Default: 1</param>
        /// <param name="scoreType">Score type to be evaluated in Score. Default: "num_points"</param>
        /// <param name="score">Score of the found instances according to the ScoreType input.</param>
        /// <returns>Homography between model and found instance.</returns>
        public HHomMat2D[] FindUncalibDescriptorModel(
            HImage image,
            HTuple detectorParamName,
            HTuple detectorParamValue,
            HTuple descriptorParamName,
            HTuple descriptorParamValue,
            HTuple minScore,
            int numMatches,
            HTuple scoreType,
            out HTuple score)
        {
            IntPtr proc = HalconAPI.PreCall(949);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.Store(proc, 1, detectorParamName);
            HalconAPI.Store(proc, 2, detectorParamValue);
            HalconAPI.Store(proc, 3, descriptorParamName);
            HalconAPI.Store(proc, 4, descriptorParamValue);
            HalconAPI.Store(proc, 5, minScore);
            HalconAPI.StoreI(proc, 6, numMatches);
            HalconAPI.Store(proc, 7, scoreType);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int err1 = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(detectorParamName);
            HalconAPI.UnpinTuple(detectorParamValue);
            HalconAPI.UnpinTuple(descriptorParamName);
            HalconAPI.UnpinTuple(descriptorParamValue);
            HalconAPI.UnpinTuple(minScore);
            HalconAPI.UnpinTuple(scoreType);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, err1, out tuple);
            int    procResult = HTuple.LoadNew(proc, 1, err2, out score);

            HalconAPI.PostCall(proc, procResult);
            HHomMat2D[] hhomMat2DArray = HHomMat2D.SplitArray(tuple);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
            return(hhomMat2DArray);
        }
Esempio n. 25
0
        /// <summary>
        ///   Prepare a component model for matching based on trained components.
        ///   Instance represents: Handle of the training result.
        /// </summary>
        /// <param name="angleStart">Smallest rotation of the component model. Default: -0.39</param>
        /// <param name="angleExtent">Extent of the rotation of the component model. Default: 0.79</param>
        /// <param name="minContrastComp">Minimum contrast of the components in the search images. Default: "auto"</param>
        /// <param name="minScoreComp">Minimum score of the instances of the components to be found. Default: 0.5</param>
        /// <param name="numLevelsComp">Maximum number of pyramid levels for the components. Default: "auto"</param>
        /// <param name="angleStepComp">Step length of the angles (resolution) for the components. Default: "auto"</param>
        /// <param name="optimizationComp">Kind of optimization for the components. Default: "auto"</param>
        /// <param name="metricComp">Match metric used for the components. Default: "use_polarity"</param>
        /// <param name="pregenerationComp">Complete pregeneration of the shape models for the components if equal to 'true'. Default: "false"</param>
        /// <param name="rootRanking">Ranking of the model components expressing the suitability to act as the root component.</param>
        /// <returns>Handle of the component model.</returns>
        public HComponentModel CreateTrainedComponentModel(
            double angleStart,
            double angleExtent,
            HTuple minContrastComp,
            HTuple minScoreComp,
            HTuple numLevelsComp,
            HTuple angleStepComp,
            string optimizationComp,
            HTuple metricComp,
            HTuple pregenerationComp,
            out HTuple rootRanking)
        {
            IntPtr proc = HalconAPI.PreCall(1005);

            this.Store(proc, 0);
            HalconAPI.StoreD(proc, 1, angleStart);
            HalconAPI.StoreD(proc, 2, angleExtent);
            HalconAPI.Store(proc, 3, minContrastComp);
            HalconAPI.Store(proc, 4, minScoreComp);
            HalconAPI.Store(proc, 5, numLevelsComp);
            HalconAPI.Store(proc, 6, angleStepComp);
            HalconAPI.StoreS(proc, 7, optimizationComp);
            HalconAPI.Store(proc, 8, metricComp);
            HalconAPI.Store(proc, 9, pregenerationComp);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int err1 = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(minContrastComp);
            HalconAPI.UnpinTuple(minScoreComp);
            HalconAPI.UnpinTuple(numLevelsComp);
            HalconAPI.UnpinTuple(angleStepComp);
            HalconAPI.UnpinTuple(metricComp);
            HalconAPI.UnpinTuple(pregenerationComp);
            HComponentModel hcomponentModel;
            int             err2       = HComponentModel.LoadNew(proc, 0, err1, out hcomponentModel);
            int             procResult = HTuple.LoadNew(proc, 1, HTupleType.INTEGER, err2, out rootRanking);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(hcomponentModel);
        }
        /// <summary>
        ///   Refine the pose of a surface model in a 3D scene and in images.
        ///   Modified instance represents: Handle of the matching result, if enabled in ReturnResultHandle.
        /// </summary>
        /// <param name="image">Images of the scene.</param>
        /// <param name="surfaceModelID">Handle of the surface model.</param>
        /// <param name="objectModel3D">Handle of the 3D object model containing the scene.</param>
        /// <param name="initialPose">Initial pose of the surface model in the scene.</param>
        /// <param name="minScore">Minimum score of the returned poses. Default: 0</param>
        /// <param name="returnResultHandle">Enable returning a result handle in SurfaceMatchingResultID. Default: "false"</param>
        /// <param name="genParamName">Names of the generic parameters. Default: []</param>
        /// <param name="genParamValue">Values of the generic parameters. Default: []</param>
        /// <param name="score">Score of the found instances of the model.</param>
        /// <returns>3D pose of the surface model in the scene.</returns>
        public HPose RefineSurfaceModelPoseImage(
            HImage image,
            HSurfaceModel surfaceModelID,
            HObjectModel3D objectModel3D,
            HPose initialPose,
            double minScore,
            string returnResultHandle,
            HTuple genParamName,
            HTuple genParamValue,
            out HTuple score)
        {
            this.Dispose();
            IntPtr proc = HalconAPI.PreCall(2084);

            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.Store(proc, 0, (HTool)surfaceModelID);
            HalconAPI.Store(proc, 1, (HTool)objectModel3D);
            HalconAPI.Store(proc, 2, (HData)initialPose);
            HalconAPI.StoreD(proc, 3, minScore);
            HalconAPI.StoreS(proc, 4, returnResultHandle);
            HalconAPI.Store(proc, 5, genParamName);
            HalconAPI.Store(proc, 6, genParamValue);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int err1 = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple((HTuple)((HData)initialPose));
            HalconAPI.UnpinTuple(genParamName);
            HalconAPI.UnpinTuple(genParamValue);
            int   err2 = this.Load(proc, 2, err1);
            HPose hpose;
            int   err3       = HPose.LoadNew(proc, 0, err2, out hpose);
            int   procResult = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err3, out score);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
            GC.KeepAlive((object)surfaceModelID);
            GC.KeepAlive((object)objectModel3D);
            return(hpose);
        }
Esempio n. 27
0
        /// <summary>
        ///   Find the best matches of multiple NCC models.
        ///   Instance represents: Handle of the models.
        /// </summary>
        /// <param name="image">Input image in which the model should be found.</param>
        /// <param name="angleStart">Smallest rotation of the models. Default: -0.39</param>
        /// <param name="angleExtent">Extent of the rotation angles. Default: 0.79</param>
        /// <param name="minScore">Minimum score of the instances of the models to be found. Default: 0.8</param>
        /// <param name="numMatches">Number of instances of the models to be found (or 0 for all matches). Default: 1</param>
        /// <param name="maxOverlap">Maximum overlap of the instances of the models to be found. Default: 0.5</param>
        /// <param name="subPixel">Subpixel accuracy if not equal to 'none'. Default: "true"</param>
        /// <param name="numLevels">Number of pyramid levels used in the matching (and lowest pyramid level to use if $|NumLevels| = 2$). Default: 0</param>
        /// <param name="row">Row coordinate of the found instances of the models.</param>
        /// <param name="column">Column coordinate of the found instances of the models.</param>
        /// <param name="angle">Rotation angle of the found instances of the models.</param>
        /// <param name="score">Score of the found instances of the models.</param>
        /// <param name="model">Index of the found instances of the models.</param>
        public void FindNccModels(
            HImage image,
            double angleStart,
            double angleExtent,
            double minScore,
            int numMatches,
            double maxOverlap,
            string subPixel,
            int numLevels,
            out HTuple row,
            out HTuple column,
            out HTuple angle,
            out HTuple score,
            out HTuple model)
        {
            IntPtr proc = HalconAPI.PreCall(2068);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.StoreD(proc, 1, angleStart);
            HalconAPI.StoreD(proc, 2, angleExtent);
            HalconAPI.StoreD(proc, 3, minScore);
            HalconAPI.StoreI(proc, 4, numMatches);
            HalconAPI.StoreD(proc, 5, maxOverlap);
            HalconAPI.StoreS(proc, 6, subPixel);
            HalconAPI.StoreI(proc, 7, numLevels);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            HalconAPI.InitOCT(proc, 4);
            int err1       = HalconAPI.CallProcedure(proc);
            int err2       = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, err1, out row);
            int err3       = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out column);
            int err4       = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out angle);
            int err5       = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, err4, out score);
            int procResult = HTuple.LoadNew(proc, 4, HTupleType.INTEGER, err5, out model);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
        }
Esempio n. 28
0
        /// <summary>
        ///   Find the best matches of a calibrated descriptor model in an image and return their 3D pose.
        ///   Instance represents: The handle to the descriptor model.
        /// </summary>
        /// <param name="image">Input image where the model should be found.</param>
        /// <param name="detectorParamName">The detector's parameter names. Default: []</param>
        /// <param name="detectorParamValue">Values of the detector's parameters. Default: []</param>
        /// <param name="descriptorParamName">The descriptor's parameter names. Default: []</param>
        /// <param name="descriptorParamValue">Values of the descriptor's parameters. Default: []</param>
        /// <param name="minScore">Minimum score of the instances of the models to be found. Default: 0.2</param>
        /// <param name="numMatches">Maximal number of found instances. Default: 1</param>
        /// <param name="camParam">Camera parameter (inner orientation) obtained from camera calibration.</param>
        /// <param name="scoreType">Score type to be evaluated in Score. Default: "num_points"</param>
        /// <param name="score">Score of the found instances according to the ScoreType input.</param>
        /// <returns>3D pose of the object.</returns>
        public HPose FindCalibDescriptorModel(
            HImage image,
            HTuple detectorParamName,
            HTuple detectorParamValue,
            HTuple descriptorParamName,
            HTuple descriptorParamValue,
            double minScore,
            int numMatches,
            HCamPar camParam,
            string scoreType,
            out double score)
        {
            IntPtr proc = HalconAPI.PreCall(948);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.Store(proc, 1, detectorParamName);
            HalconAPI.Store(proc, 2, detectorParamValue);
            HalconAPI.Store(proc, 3, descriptorParamName);
            HalconAPI.Store(proc, 4, descriptorParamValue);
            HalconAPI.StoreD(proc, 5, minScore);
            HalconAPI.StoreI(proc, 6, numMatches);
            HalconAPI.Store(proc, 7, (HData)camParam);
            HalconAPI.StoreS(proc, 8, scoreType);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int err1 = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(detectorParamName);
            HalconAPI.UnpinTuple(detectorParamValue);
            HalconAPI.UnpinTuple(descriptorParamName);
            HalconAPI.UnpinTuple(descriptorParamValue);
            HalconAPI.UnpinTuple((HTuple)((HData)camParam));
            HPose hpose;
            int   err2       = HPose.LoadNew(proc, 0, err1, out hpose);
            int   procResult = HalconAPI.LoadD(proc, 1, err2, out score);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
            return(hpose);
        }
Esempio n. 29
0
        /// <summary>
        ///   Searching all good grayvalue matches in a pyramid.
        ///   Instance represents: Template number.
        /// </summary>
        /// <param name="image">Input image inside of which the pattern has to be found.</param>
        /// <param name="maxError">Maximal average difference of the grayvalues. Default: 30.0</param>
        /// <param name="numLevel">Number of levels in the pyramid. Default: 3</param>
        /// <returns>All points which have an error below a certain threshold.</returns>
        public HRegion FastMatchMg(HImage image, double maxError, HTuple numLevel)
        {
            IntPtr proc = HalconAPI.PreCall(1499);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.StoreD(proc, 1, maxError);
            HalconAPI.Store(proc, 2, numLevel);
            HalconAPI.InitOCT(proc, 1);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(numLevel);
            HRegion hregion;
            int     procResult = HRegion.LoadNew(proc, 1, err, out hregion);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
            return(hregion);
        }
        /// <summary>
        ///   Inspection of the texture within an image.
        ///   Instance represents: Handle of the texture inspection model.
        /// </summary>
        /// <param name="image">Image of the texture to be inspected.</param>
        /// <param name="textureInspectionResultID">Handle of the inspection results.</param>
        /// <returns>Novelty regions.</returns>
        public HRegion ApplyTextureInspectionModel(
            HImage image,
            out HTextureInspectionResult textureInspectionResultID)
        {
            IntPtr proc = HalconAPI.PreCall(2044);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 0);
            int     err1 = HalconAPI.CallProcedure(proc);
            HRegion hregion;
            int     err2       = HRegion.LoadNew(proc, 1, err1, out hregion);
            int     procResult = HTextureInspectionResult.LoadNew(proc, 0, err2, out textureInspectionResultID);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
            return(hregion);
        }