예제 #1
0
        /// <summary>
        ///   Return the parameters of an NCC model.
        ///   Instance represents: Handle of the model.
        /// </summary>
        /// <param name="angleStart">Smallest rotation of the pattern.</param>
        /// <param name="angleExtent">Extent of the rotation angles.</param>
        /// <param name="angleStep">Step length of the angles (resolution).</param>
        /// <param name="metric">Match metric.</param>
        /// <returns>Number of pyramid levels.</returns>
        public int GetNccModelParams(
            out double angleStart,
            out double angleExtent,
            out double angleStep,
            out string metric)
        {
            IntPtr proc = HalconAPI.PreCall(988);

            this.Store(proc, 0);
            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 intValue;
            int err2       = HalconAPI.LoadI(proc, 0, err1, out intValue);
            int err3       = HalconAPI.LoadD(proc, 1, err2, out angleStart);
            int err4       = HalconAPI.LoadD(proc, 2, err3, out angleExtent);
            int err5       = HalconAPI.LoadD(proc, 3, err4, out angleStep);
            int procResult = HalconAPI.LoadS(proc, 4, err5, out metric);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(intValue);
        }
예제 #2
0
        /// <summary>
        ///   Classify a single character with an CNN-based OCR classifier.
        ///   Instance represents: Handle of the OCR classifier.
        /// </summary>
        /// <param name="character">Character to be recognized.</param>
        /// <param name="image">Gray values of the character.</param>
        /// <param name="num">Number of best classes to determine. Default: 1</param>
        /// <param name="confidence">Confidence(s) of the class(es) of the character.</param>
        /// <returns>Result of classifying the character with the CNN.</returns>
        public string DoOcrSingleClassCnn(
            HRegion character,
            HImage image,
            HTuple num,
            out double confidence)
        {
            IntPtr proc = HalconAPI.PreCall(2057);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)character);
            HalconAPI.Store(proc, 2, (HObjectBase)image);
            HalconAPI.Store(proc, 1, num);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int err1 = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(num);
            string stringValue;
            int    err2       = HalconAPI.LoadS(proc, 0, err1, out stringValue);
            int    procResult = HalconAPI.LoadD(proc, 1, err2, out confidence);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)character);
            GC.KeepAlive((object)image);
            return(stringValue);
        }
예제 #3
0
        /// <summary>
        ///   Identify objects with a sample identifier.
        ///   Instance represents: Handle of the sample identifier.
        /// </summary>
        /// <param name="image">Image showing the object to be identified.</param>
        /// <param name="numResults">Number of suggested object indices. Default: 1</param>
        /// <param name="ratingThreshold">Rating threshold. Default: 0.0</param>
        /// <param name="genParamName">Generic parameter name. Default: []</param>
        /// <param name="genParamValue">Generic parameter value. Default: []</param>
        /// <param name="rating">Rating value of the identified object.</param>
        /// <returns>Index of the identified object.</returns>
        public int ApplySampleIdentifier(
            HImage image,
            int numResults,
            double ratingThreshold,
            HTuple genParamName,
            HTuple genParamValue,
            out double rating)
        {
            IntPtr proc = HalconAPI.PreCall(904);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.StoreI(proc, 1, numResults);
            HalconAPI.StoreD(proc, 2, ratingThreshold);
            HalconAPI.Store(proc, 3, genParamName);
            HalconAPI.Store(proc, 4, genParamValue);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int err1 = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(genParamName);
            HalconAPI.UnpinTuple(genParamValue);
            int intValue;
            int err2       = HalconAPI.LoadI(proc, 0, err1, out intValue);
            int procResult = HalconAPI.LoadD(proc, 1, err2, out rating);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
            return(intValue);
        }
예제 #4
0
        /// <summary>
        ///   Apply an arbitrary affine 3D transformation to points.
        ///   Instance represents: Input transformation matrix.
        /// </summary>
        /// <param name="px">Input point(s) (x coordinate). Default: 64</param>
        /// <param name="py">Input point(s) (y coordinate). Default: 64</param>
        /// <param name="pz">Input point(s) (z coordinate). Default: 64</param>
        /// <param name="qy">Output point(s) (y coordinate).</param>
        /// <param name="qz">Output point(s) (z coordinate).</param>
        /// <returns>Output point(s) (x coordinate).</returns>
        public double AffineTransPoint3d(
            double px,
            double py,
            double pz,
            out double qy,
            out double qz)
        {
            IntPtr proc = HalconAPI.PreCall(241);

            this.Store(proc, 0);
            HalconAPI.StoreD(proc, 1, px);
            HalconAPI.StoreD(proc, 2, py);
            HalconAPI.StoreD(proc, 3, pz);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            int err1 = HalconAPI.CallProcedure(proc);

            this.UnpinTuple();
            double doubleValue;
            int    err2       = HalconAPI.LoadD(proc, 0, err1, out doubleValue);
            int    err3       = HalconAPI.LoadD(proc, 1, err2, out qy);
            int    procResult = HalconAPI.LoadD(proc, 2, err3, out qz);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(doubleValue);
        }
예제 #5
0
        /// <summary>
        ///   Calculate transformation parameters between two functions.
        ///   Instance represents: Function 1.
        /// </summary>
        /// <param name="function2">Function 2.</param>
        /// <param name="border">Border treatment for function 2. Default: "constant"</param>
        /// <param name="paramsConst">Values of the parameters to remain constant. Default: [1.0,0.0,1.0,0.0]</param>
        /// <param name="useParams">Should a parameter be adapted for it? Default: ["true","true","true","true"]</param>
        /// <param name="chiSquare">Quadratic error of the output function.</param>
        /// <param name="covar">Covariance Matrix of the transformation parameters.</param>
        /// <returns>Transformation parameters between the functions.</returns>
        public HTuple MatchFunct1dTrans(
            HFunction1D function2,
            string border,
            HTuple paramsConst,
            HTuple useParams,
            out double chiSquare,
            out HTuple covar)
        {
            IntPtr proc = HalconAPI.PreCall(1393);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HData)function2);
            HalconAPI.StoreS(proc, 2, border);
            HalconAPI.Store(proc, 3, paramsConst);
            HalconAPI.Store(proc, 4, useParams);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            int err1 = HalconAPI.CallProcedure(proc);

            this.UnpinTuple();
            HalconAPI.UnpinTuple((HTuple)((HData)function2));
            HalconAPI.UnpinTuple(paramsConst);
            HalconAPI.UnpinTuple(useParams);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, err1, out tuple);
            int    err3       = HalconAPI.LoadD(proc, 1, err2, out chiSquare);
            int    procResult = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out covar);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
예제 #6
0
        /// <summary>
        ///   Classify a related group of characters with an CNN-based OCR classifier.
        ///   Instance represents: Handle of the OCR classifier.
        /// </summary>
        /// <param name="character">Characters to be recognized.</param>
        /// <param name="image">Gray values of the characters.</param>
        /// <param name="expression">Expression describing the allowed word structure.</param>
        /// <param name="numAlternatives">Number of classes per character considered for the internal word correction. Default: 3</param>
        /// <param name="numCorrections">Maximum number of corrected characters. Default: 2</param>
        /// <param name="confidence">Confidence of the class of the characters.</param>
        /// <param name="word">Word text after classification and correction.</param>
        /// <param name="score">Measure of similarity between corrected word and uncorrected classification results.</param>
        /// <returns>Result of classifying the characters with the CNN.</returns>
        public string DoOcrWordCnn(
            HRegion character,
            HImage image,
            string expression,
            int numAlternatives,
            int numCorrections,
            out double confidence,
            out string word,
            out double score)
        {
            IntPtr proc = HalconAPI.PreCall(2058);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)character);
            HalconAPI.Store(proc, 2, (HObjectBase)image);
            HalconAPI.StoreS(proc, 1, expression);
            HalconAPI.StoreI(proc, 2, numAlternatives);
            HalconAPI.StoreI(proc, 3, numCorrections);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            int    err1 = HalconAPI.CallProcedure(proc);
            string stringValue;
            int    err2       = HalconAPI.LoadS(proc, 0, err1, out stringValue);
            int    err3       = HalconAPI.LoadD(proc, 1, err2, out confidence);
            int    err4       = HalconAPI.LoadS(proc, 2, err3, out word);
            int    procResult = HalconAPI.LoadD(proc, 3, err4, out score);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)character);
            GC.KeepAlive((object)image);
            return(stringValue);
        }
예제 #7
0
        /// <summary>
        ///   Return the parameters of a support vector machine.
        ///   Instance represents: SVM handle.
        /// </summary>
        /// <param name="kernelType">The kernel type.</param>
        /// <param name="kernelParam">Additional parameter for the kernel.</param>
        /// <param name="nu">Regularization constant of the SVM.</param>
        /// <param name="numClasses">Number of classes of the test data.</param>
        /// <param name="mode">The mode of the SVM.</param>
        /// <param name="preprocessing">Type of preprocessing used to transform the feature vectors.</param>
        /// <param name="numComponents">Preprocessing parameter: Number of transformed features (ignored for Preprocessing $=$ 'none' and Preprocessing $=$ 'normalization').</param>
        /// <returns>Number of input variables (features) of the SVM.</returns>
        public int GetParamsClassSvm(
            out string kernelType,
            out double kernelParam,
            out double nu,
            out int numClasses,
            out string mode,
            out string preprocessing,
            out int numComponents)
        {
            IntPtr proc = HalconAPI.PreCall(1860);

            this.Store(proc, 0);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            HalconAPI.InitOCT(proc, 4);
            HalconAPI.InitOCT(proc, 5);
            HalconAPI.InitOCT(proc, 6);
            HalconAPI.InitOCT(proc, 7);
            int err1 = HalconAPI.CallProcedure(proc);
            int intValue;
            int err2       = HalconAPI.LoadI(proc, 0, err1, out intValue);
            int err3       = HalconAPI.LoadS(proc, 1, err2, out kernelType);
            int err4       = HalconAPI.LoadD(proc, 2, err3, out kernelParam);
            int err5       = HalconAPI.LoadD(proc, 3, err4, out nu);
            int err6       = HalconAPI.LoadI(proc, 4, err5, out numClasses);
            int err7       = HalconAPI.LoadS(proc, 5, err6, out mode);
            int err8       = HalconAPI.LoadS(proc, 6, err7, out preprocessing);
            int procResult = HalconAPI.LoadI(proc, 7, err8, out numComponents);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(intValue);
        }
        /// <summary>
        ///   Find the best match of a deformable surface model in a 3D scene.
        ///   Modified instance represents: Handle of the matching result.
        /// </summary>
        /// <param name="deformableSurfaceModel">Handle of the deformable surface model.</param>
        /// <param name="objectModel3D">Handle of the 3D object model containing the scene.</param>
        /// <param name="relSamplingDistance">Scene sampling distance relative to the diameter of the surface model. Default: 0.05</param>
        /// <param name="minScore">Minimum score of the returned match. Default: 0</param>
        /// <param name="genParamName">Names of the generic parameters. Default: []</param>
        /// <param name="genParamValue">Values of the generic parameters. Default: []</param>
        /// <returns>Score of the found instances of the surface model.</returns>
        public double FindDeformableSurfaceModel(
            HDeformableSurfaceModel deformableSurfaceModel,
            HObjectModel3D objectModel3D,
            double relSamplingDistance,
            double minScore,
            HTuple genParamName,
            HTuple genParamValue)
        {
            this.Dispose();
            IntPtr proc = HalconAPI.PreCall(1027);

            HalconAPI.Store(proc, 0, (HTool)deformableSurfaceModel);
            HalconAPI.Store(proc, 1, (HTool)objectModel3D);
            HalconAPI.StoreD(proc, 2, relSamplingDistance);
            HalconAPI.StoreD(proc, 3, minScore);
            HalconAPI.Store(proc, 4, genParamName);
            HalconAPI.Store(proc, 5, genParamValue);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 0);
            int err1 = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(genParamName);
            HalconAPI.UnpinTuple(genParamValue);
            int    err2 = this.Load(proc, 1, err1);
            double doubleValue;
            int    procResult = HalconAPI.LoadD(proc, 0, err2, out doubleValue);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)deformableSurfaceModel);
            GC.KeepAlive((object)objectModel3D);
            return(doubleValue);
        }
        /// <summary>
        ///   Refine the position and deformation of a deformable surface model in a 3D scene.
        ///   Modified instance represents: Handle of the matching result.
        /// </summary>
        /// <param name="deformableSurfaceModel">Handle of the deformable surface model.</param>
        /// <param name="objectModel3D">Handle of the 3D object model containing the scene.</param>
        /// <param name="relSamplingDistance">Relative sampling distance of the scene. Default: 0.05</param>
        /// <param name="initialDeformationObjectModel3D">Initial deformation of the 3D object model</param>
        /// <param name="genParamName">Names of the generic parameters. Default: []</param>
        /// <param name="genParamValue">Values of the generic parameters. Default: []</param>
        /// <returns>Score of the refined model.</returns>
        public double RefineDeformableSurfaceModel(
            HDeformableSurfaceModel deformableSurfaceModel,
            HObjectModel3D objectModel3D,
            double relSamplingDistance,
            HObjectModel3D initialDeformationObjectModel3D,
            string genParamName,
            string genParamValue)
        {
            this.Dispose();
            IntPtr proc = HalconAPI.PreCall(1026);

            HalconAPI.Store(proc, 0, (HTool)deformableSurfaceModel);
            HalconAPI.Store(proc, 1, (HTool)objectModel3D);
            HalconAPI.StoreD(proc, 2, relSamplingDistance);
            HalconAPI.Store(proc, 3, (HTool)initialDeformationObjectModel3D);
            HalconAPI.StoreS(proc, 4, genParamName);
            HalconAPI.StoreS(proc, 5, genParamValue);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 0);
            int    err1 = HalconAPI.CallProcedure(proc);
            int    err2 = this.Load(proc, 1, err1);
            double doubleValue;
            int    procResult = HalconAPI.LoadD(proc, 0, err2, out doubleValue);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)deformableSurfaceModel);
            GC.KeepAlive((object)objectModel3D);
            GC.KeepAlive((object)initialDeformationObjectModel3D);
            return(doubleValue);
        }
예제 #10
0
        /// <summary>Passed Time.</summary>
        /// <returns>Processtime since the program start.</returns>
        public static double CountSeconds()
        {
            IntPtr proc = HalconAPI.PreCall(323);

            HalconAPI.InitOCT(proc, 0);
            int    err = HalconAPI.CallProcedure(proc);
            double doubleValue;
            int    procResult = HalconAPI.LoadD(proc, 0, err, out doubleValue);

            HalconAPI.PostCall(proc, procResult);
            return(doubleValue);
        }
예제 #11
0
        /// <summary>
        ///   Return the origin (reference point) of an NCC model.
        ///   Instance represents: Handle of the model.
        /// </summary>
        /// <param name="row">Row coordinate of the origin of the NCC model.</param>
        /// <param name="column">Column coordinate of the origin of the NCC model.</param>
        public void GetNccModelOrigin(out double row, out double column)
        {
            IntPtr proc = HalconAPI.PreCall(989);

            this.Store(proc, 0);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int err1       = HalconAPI.CallProcedure(proc);
            int err2       = HalconAPI.LoadD(proc, 0, err1, out row);
            int procResult = HalconAPI.LoadD(proc, 1, err2, out column);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
        }
예제 #12
0
        /// <summary>
        ///   Determine all camera parameters by a simultaneous minimization process.
        ///   Instance represents: Handle of a calibration data model.
        /// </summary>
        /// <returns>Back projection root mean square error (RMSE) of the optimization.</returns>
        public double CalibrateCameras()
        {
            IntPtr proc = HalconAPI.PreCall(1966);

            this.Store(proc, 0);
            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);
            return(doubleValue);
        }
예제 #13
0
        /// <summary>
        ///   Train an OCR classifier with the help of a training file.
        ///   Instance represents: ID of the desired OCR-network.
        /// </summary>
        /// <param name="trainingFile">Names of the training files. Default: "train_ocr"</param>
        /// <returns>Average confidence during a re-classification of the trained characters.</returns>
        public double TrainfOcrClassBox(string trainingFile)
        {
            IntPtr proc = HalconAPI.PreCall(718);

            this.Store(proc, 0);
            HalconAPI.StoreS(proc, 1, trainingFile);
            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);
            return(doubleValue);
        }
        /// <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 double InterpolateScatteredData(double row, double column)
        {
            IntPtr proc = HalconAPI.PreCall(291);

            this.Store(proc, 0);
            HalconAPI.StoreD(proc, 1, row);
            HalconAPI.StoreD(proc, 2, column);
            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);
            return(doubleValue);
        }
예제 #15
0
        /// <summary>
        ///   Smallest and largest x value of the function.
        ///   Instance represents: Input function.
        /// </summary>
        /// <param name="XMin">Smallest x value.</param>
        /// <param name="XMax">Largest x value.</param>
        public void XRangeFunct1d(out double XMin, out double XMax)
        {
            IntPtr proc = HalconAPI.PreCall(1389);

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

            this.UnpinTuple();
            int err2       = HalconAPI.LoadD(proc, 0, err1, out XMin);
            int procResult = HalconAPI.LoadD(proc, 1, err2, out XMax);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
        }
예제 #16
0
        /// <summary>
        ///   Compute the determinant of a homogeneous 3D transformation matrix.
        ///   Instance represents: Input transformation matrix.
        /// </summary>
        /// <returns>Determinant of the input matrix.</returns>
        public double HomMat3dDeterminant()
        {
            IntPtr proc = HalconAPI.PreCall(243);

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

            this.UnpinTuple();
            double doubleValue;
            int    procResult = HalconAPI.LoadD(proc, 0, err, out doubleValue);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(doubleValue);
        }
예제 #17
0
        /// <summary>
        ///   Classify a set of arrays.
        ///   Instance represents: Key of the test data.
        /// </summary>
        /// <param name="classifHandle">Handle of the classifier.</param>
        /// <returns>Error during the assignment.</returns>
        public double TestSampsetBox(HClassBox classifHandle)
        {
            IntPtr proc = HalconAPI.PreCall(1897);

            this.Store(proc, 1);
            HalconAPI.Store(proc, 0, (HTool)classifHandle);
            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)classifHandle);
            return(doubleValue);
        }
예제 #18
0
        /// <summary>
        ///   Access a function value using the index of the control points.
        ///   Instance represents: Input function.
        /// </summary>
        /// <param name="index">Index of the control points.</param>
        /// <param name="x">X value at the given control points.</param>
        /// <param name="y">Y value at the given control points.</param>
        public void GetPairFunct1d(int index, out double x, out double y)
        {
            IntPtr proc = HalconAPI.PreCall(1386);

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

            this.UnpinTuple();
            int err2       = HalconAPI.LoadD(proc, 0, err1, out x);
            int procResult = HalconAPI.LoadD(proc, 1, err2, out y);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
        }
예제 #19
0
        /// <summary>
        ///   Return the index of a support vector from a trained support vector machine.
        ///   Instance represents: SVM handle.
        /// </summary>
        /// <param name="indexSupportVector">Number of stored support vectors.</param>
        /// <returns>Index of the support vector in the training set.</returns>
        public double GetSupportVectorClassSvm(HTuple indexSupportVector)
        {
            IntPtr proc = HalconAPI.PreCall(1856);

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

            HalconAPI.UnpinTuple(indexSupportVector);
            double doubleValue;
            int    procResult = HalconAPI.LoadD(proc, 0, err, out doubleValue);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(doubleValue);
        }
예제 #20
0
        /// <summary>
        ///   Compute the positive and negative areas of a function.
        ///   Instance represents: Input function.
        /// </summary>
        /// <param name="negative">Area under the negative part of the function.</param>
        /// <returns>Area under the positive part of the function.</returns>
        public double IntegrateFunct1d(out HTuple negative)
        {
            IntPtr proc = HalconAPI.PreCall(1396);

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

            this.UnpinTuple();
            double doubleValue;
            int    err2       = HalconAPI.LoadD(proc, 0, err1, out doubleValue);
            int    procResult = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out negative);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(doubleValue);
        }
예제 #21
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 double GetYValueFunct1d(double x, string border)
        {
            IntPtr proc = HalconAPI.PreCall(1385);

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

            this.UnpinTuple();
            double doubleValue;
            int    procResult = HalconAPI.LoadD(proc, 0, err, out doubleValue);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(doubleValue);
        }
예제 #22
0
        /// <summary>
        ///   Transform a 3D line with a unit dual quaternion.
        ///   Instance represents: Unit dual quaternion representing the transformation.
        /// </summary>
        /// <param name="lineFormat">Format of the line parameters. Default: "moment"</param>
        /// <param name="lineDirectionX">X component of the direction vector of the line.</param>
        /// <param name="lineDirectionY">Y component of the direction vector of the line.</param>
        /// <param name="lineDirectionZ">Z component of the direction vector of the line.</param>
        /// <param name="lineMomentOrPointX">X component of the moment vector or a point on the line.</param>
        /// <param name="lineMomentOrPointY">Y component of the moment vector or a point on the line.</param>
        /// <param name="lineMomentOrPointZ">Z component of the moment vector or a point on the line.</param>
        /// <param name="transLineDirectionX">X component of the direction vector of the transformed line.</param>
        /// <param name="transLineDirectionY">Y component of the direction vector of the transformed line.</param>
        /// <param name="transLineDirectionZ">Z component of the direction vector of the transformed line.</param>
        /// <param name="transLineMomentOrPointX">X component of the moment vector or a point on the transformed line.</param>
        /// <param name="transLineMomentOrPointY">Y component of the moment vector or a point on the transformed line.</param>
        /// <param name="transLineMomentOrPointZ">Z component of the moment vector or a point on the transformed line.</param>
        public void DualQuatTransLine3d(
            string lineFormat,
            double lineDirectionX,
            double lineDirectionY,
            double lineDirectionZ,
            double lineMomentOrPointX,
            double lineMomentOrPointY,
            double lineMomentOrPointZ,
            out double transLineDirectionX,
            out double transLineDirectionY,
            out double transLineDirectionZ,
            out double transLineMomentOrPointX,
            out double transLineMomentOrPointY,
            out double transLineMomentOrPointZ)
        {
            IntPtr proc = HalconAPI.PreCall(2066);

            this.Store(proc, 0);
            HalconAPI.StoreS(proc, 1, lineFormat);
            HalconAPI.StoreD(proc, 2, lineDirectionX);
            HalconAPI.StoreD(proc, 3, lineDirectionY);
            HalconAPI.StoreD(proc, 4, lineDirectionZ);
            HalconAPI.StoreD(proc, 5, lineMomentOrPointX);
            HalconAPI.StoreD(proc, 6, lineMomentOrPointY);
            HalconAPI.StoreD(proc, 7, lineMomentOrPointZ);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            HalconAPI.InitOCT(proc, 4);
            HalconAPI.InitOCT(proc, 5);
            int err1 = HalconAPI.CallProcedure(proc);

            this.UnpinTuple();
            int err2       = HalconAPI.LoadD(proc, 0, err1, out transLineDirectionX);
            int err3       = HalconAPI.LoadD(proc, 1, err2, out transLineDirectionY);
            int err4       = HalconAPI.LoadD(proc, 2, err3, out transLineDirectionZ);
            int err5       = HalconAPI.LoadD(proc, 3, err4, out transLineMomentOrPointX);
            int err6       = HalconAPI.LoadD(proc, 4, err5, out transLineMomentOrPointY);
            int procResult = HalconAPI.LoadD(proc, 5, err6, out transLineMomentOrPointZ);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
        }
예제 #23
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);
        }
예제 #24
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);
        }
예제 #25
0
        /// <summary>
        ///   Return the parameters of the data set.
        ///   Instance represents: ID of the BgEsti data set.
        /// </summary>
        /// <param name="syspar2">2. system matrix parameter.</param>
        /// <param name="gainMode">Gain type.</param>
        /// <param name="gain1">Kalman gain / foreground adaptation time.</param>
        /// <param name="gain2">Kalman gain / background adaptation time.</param>
        /// <param name="adaptMode">Threshold adaptation.</param>
        /// <param name="minDiff">Foreground / background threshold.</param>
        /// <param name="statNum">Number of statistic data sets.</param>
        /// <param name="confidenceC">Confidence constant.</param>
        /// <param name="timeC">Constant for decay time.</param>
        /// <returns>1. system matrix parameter.</returns>
        public double GetBgEstiParams(
            out double syspar2,
            out string gainMode,
            out double gain1,
            out double gain2,
            out string adaptMode,
            out double minDiff,
            out int statNum,
            out double confidenceC,
            out double timeC)
        {
            IntPtr proc = HalconAPI.PreCall(2006);

            this.Store(proc, 0);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            HalconAPI.InitOCT(proc, 4);
            HalconAPI.InitOCT(proc, 5);
            HalconAPI.InitOCT(proc, 6);
            HalconAPI.InitOCT(proc, 7);
            HalconAPI.InitOCT(proc, 8);
            HalconAPI.InitOCT(proc, 9);
            int    err1 = HalconAPI.CallProcedure(proc);
            double doubleValue;
            int    err2       = HalconAPI.LoadD(proc, 0, err1, out doubleValue);
            int    err3       = HalconAPI.LoadD(proc, 1, err2, out syspar2);
            int    err4       = HalconAPI.LoadS(proc, 2, err3, out gainMode);
            int    err5       = HalconAPI.LoadD(proc, 3, err4, out gain1);
            int    err6       = HalconAPI.LoadD(proc, 4, err5, out gain2);
            int    err7       = HalconAPI.LoadS(proc, 5, err6, out adaptMode);
            int    err8       = HalconAPI.LoadD(proc, 6, err7, out minDiff);
            int    err9       = HalconAPI.LoadI(proc, 7, err8, out statNum);
            int    err10      = HalconAPI.LoadD(proc, 8, err9, out confidenceC);
            int    procResult = HalconAPI.LoadD(proc, 9, err10, out timeC);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(doubleValue);
        }
예제 #26
0
        /// <summary>
        ///   Calculate the class of a feature vector by a multilayer perceptron.
        ///   Instance represents: MLP handle.
        /// </summary>
        /// <param name="features">Feature vector.</param>
        /// <param name="num">Number of best classes to determine. Default: 1</param>
        /// <param name="confidence">Confidence(s) of the class(es) of the feature vector.</param>
        /// <returns>Result of classifying the feature vector with the MLP.</returns>
        public int ClassifyClassMlp(HTuple features, HTuple num, out double confidence)
        {
            IntPtr proc = HalconAPI.PreCall(1871);

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

            HalconAPI.UnpinTuple(features);
            HalconAPI.UnpinTuple(num);
            int intValue;
            int err2       = HalconAPI.LoadI(proc, 0, err1, out intValue);
            int procResult = HalconAPI.LoadD(proc, 1, err2, out confidence);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(intValue);
        }
예제 #27
0
        /// <summary>
        ///   Return the relations between the model components that are contained in a training result.
        ///   Instance represents: Handle of the training result.
        /// </summary>
        /// <param name="referenceComponent">Index of reference component.</param>
        /// <param name="image">Image for which the component relations are to be returned. Default: "model_image"</param>
        /// <param name="row">Row coordinate of the center of the rectangle representing the relation.</param>
        /// <param name="column">Column index of the center of the rectangle representing the relation.</param>
        /// <param name="phi">Orientation of the rectangle representing the relation (radians).</param>
        /// <param name="length1">First radius (half length) of the rectangle representing the relation.</param>
        /// <param name="length2">Second radius (half width) of the rectangle representing the relation.</param>
        /// <param name="angleStart">Smallest relative orientation angle.</param>
        /// <param name="angleExtent">Extent of the relative orientation angles.</param>
        /// <returns>Region representation of the relations.</returns>
        public HRegion GetComponentRelations(
            int referenceComponent,
            string image,
            out double row,
            out double column,
            out double phi,
            out double length1,
            out double length2,
            out double angleStart,
            out double angleExtent)
        {
            IntPtr proc = HalconAPI.PreCall(1008);

            this.Store(proc, 0);
            HalconAPI.StoreI(proc, 1, referenceComponent);
            HalconAPI.StoreS(proc, 2, image);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            HalconAPI.InitOCT(proc, 4);
            HalconAPI.InitOCT(proc, 5);
            HalconAPI.InitOCT(proc, 6);
            int     err1 = HalconAPI.CallProcedure(proc);
            HRegion hregion;
            int     err2       = HRegion.LoadNew(proc, 1, err1, out hregion);
            int     err3       = HalconAPI.LoadD(proc, 0, err2, out row);
            int     err4       = HalconAPI.LoadD(proc, 1, err3, out column);
            int     err5       = HalconAPI.LoadD(proc, 2, err4, out phi);
            int     err6       = HalconAPI.LoadD(proc, 3, err5, out length1);
            int     err7       = HalconAPI.LoadD(proc, 4, err6, out length2);
            int     err8       = HalconAPI.LoadD(proc, 5, err7, out angleStart);
            int     procResult = HalconAPI.LoadD(proc, 6, err8, out angleExtent);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(hregion);
        }
예제 #28
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,
            double minScore,
            int numMatches,
            string scoreType,
            out double 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.StoreD(proc, 5, minScore);
            HalconAPI.StoreI(proc, 6, numMatches);
            HalconAPI.StoreS(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);
            HHomMat2D hhomMat2D;
            int       err2       = HHomMat2D.LoadNew(proc, 0, err1, out hhomMat2D);
            int       procResult = HalconAPI.LoadD(proc, 1, err2, out score);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
            return(hhomMat2D);
        }
예제 #29
0
        /// <summary>
        ///   Convert a unit dual quaternion into a screw.
        ///   Instance represents: Unit dual quaternion.
        /// </summary>
        /// <param name="screwFormat">Format of the screw parameters. Default: "moment"</param>
        /// <param name="axisDirectionX">X component of the direction vector of the screw axis.</param>
        /// <param name="axisDirectionY">Y component of the direction vector of the screw axis.</param>
        /// <param name="axisDirectionZ">Z component of the direction vector of the screw axis.</param>
        /// <param name="axisMomentOrPointX">X component of the moment vector or a point on the screw axis.</param>
        /// <param name="axisMomentOrPointY">Y component of the moment vector or a point on the screw axis.</param>
        /// <param name="axisMomentOrPointZ">Z component of the moment vector or a point on the screw axis.</param>
        /// <param name="rotation">Rotation angle in radians.</param>
        /// <param name="translation">Translation.</param>
        public void DualQuatToScrew(
            string screwFormat,
            out double axisDirectionX,
            out double axisDirectionY,
            out double axisDirectionZ,
            out double axisMomentOrPointX,
            out double axisMomentOrPointY,
            out double axisMomentOrPointZ,
            out double rotation,
            out double translation)
        {
            IntPtr proc = HalconAPI.PreCall(2065);

            this.Store(proc, 0);
            HalconAPI.StoreS(proc, 1, screwFormat);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            HalconAPI.InitOCT(proc, 4);
            HalconAPI.InitOCT(proc, 5);
            HalconAPI.InitOCT(proc, 6);
            HalconAPI.InitOCT(proc, 7);
            int err1 = HalconAPI.CallProcedure(proc);

            this.UnpinTuple();
            int err2       = HalconAPI.LoadD(proc, 0, err1, out axisDirectionX);
            int err3       = HalconAPI.LoadD(proc, 1, err2, out axisDirectionY);
            int err4       = HalconAPI.LoadD(proc, 2, err3, out axisDirectionZ);
            int err5       = HalconAPI.LoadD(proc, 3, err4, out axisMomentOrPointX);
            int err6       = HalconAPI.LoadD(proc, 4, err5, out axisMomentOrPointY);
            int err7       = HalconAPI.LoadD(proc, 5, err6, out axisMomentOrPointZ);
            int err8       = HalconAPI.LoadD(proc, 6, err7, out rotation);
            int procResult = HalconAPI.LoadD(proc, 7, err8, out translation);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
        }
예제 #30
0
        /// <summary>
        ///   Train a multilayer perceptron.
        ///   Instance represents: MLP handle.
        /// </summary>
        /// <param name="maxIterations">Maximum number of iterations of the optimization algorithm. Default: 200</param>
        /// <param name="weightTolerance">Threshold for the difference of the weights of the MLP between two iterations of the optimization algorithm. Default: 1.0</param>
        /// <param name="errorTolerance">Threshold for the difference of the mean error of the MLP on the training data between two iterations of the optimization algorithm. Default: 0.01</param>
        /// <param name="errorLog">Mean error of the MLP on the training data as a function of the number of iterations of the optimization algorithm.</param>
        /// <returns>Mean error of the MLP on the training data.</returns>
        public double TrainClassMlp(
            int maxIterations,
            double weightTolerance,
            double errorTolerance,
            out HTuple errorLog)
        {
            IntPtr proc = HalconAPI.PreCall(1873);

            this.Store(proc, 0);
            HalconAPI.StoreI(proc, 1, maxIterations);
            HalconAPI.StoreD(proc, 2, weightTolerance);
            HalconAPI.StoreD(proc, 3, errorTolerance);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int    err1 = HalconAPI.CallProcedure(proc);
            double doubleValue;
            int    err2       = HalconAPI.LoadD(proc, 0, err1, out doubleValue);
            int    procResult = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out errorLog);

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