예제 #1
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 HTuple ApplySampleIdentifier(
            HImage image,
            int numResults,
            double ratingThreshold,
            HTuple genParamName,
            HTuple genParamValue,
            out HTuple 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);
            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);
            GC.KeepAlive((object)image);
            return(tuple);
        }
예제 #2
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);
        }
예제 #3
0
        /// <summary>Determine the parameters of an NCC model.</summary>
        /// <param name="template">Input image whose domain will be used to create the model.</param>
        /// <param name="numLevels">Maximum number of pyramid levels. Default: "auto"</param>
        /// <param name="angleStart">Smallest rotation of the model. Default: -0.39</param>
        /// <param name="angleExtent">Extent of the rotation angles. Default: 0.79</param>
        /// <param name="metric">Match metric. Default: "use_polarity"</param>
        /// <param name="parameters">Parameters to be determined automatically. Default: "all"</param>
        /// <param name="parameterValue">Value of the automatically determined parameter.</param>
        /// <returns>Name of the automatically determined parameter.</returns>
        public static HTuple DetermineNccModelParams(
            HImage template,
            int numLevels,
            double angleStart,
            double angleExtent,
            string metric,
            string parameters,
            out HTuple parameterValue)
        {
            IntPtr proc = HalconAPI.PreCall(987);

            HalconAPI.Store(proc, 1, (HObjectBase)template);
            HalconAPI.StoreI(proc, 0, numLevels);
            HalconAPI.StoreD(proc, 1, angleStart);
            HalconAPI.StoreD(proc, 2, angleExtent);
            HalconAPI.StoreS(proc, 3, metric);
            HalconAPI.StoreS(proc, 4, parameters);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int    err1 = HalconAPI.CallProcedure(proc);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, err1, out tuple);
            int    procResult = HTuple.LoadNew(proc, 1, err2, out parameterValue);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)template);
            return(tuple);
        }
예제 #4
0
        /// <summary>
        ///   Get information about an OCR classifier.
        ///   Instance represents: ID of the OCR classifier.
        /// </summary>
        /// <param name="widthPattern">Width of the scaled characters.</param>
        /// <param name="heightPattern">Height of the scaled characters.</param>
        /// <param name="interpolation">Interpolation mode for scaling the characters.</param>
        /// <param name="widthMaxChar">Width of the largest trained character.</param>
        /// <param name="heightMaxChar">Height of the largest trained character.</param>
        /// <param name="features">Used features.</param>
        /// <param name="characters">All characters of the set.</param>
        public void InfoOcrClassBox(
            out int widthPattern,
            out int heightPattern,
            out int interpolation,
            out int widthMaxChar,
            out int heightMaxChar,
            out HTuple features,
            out HTuple characters)
        {
            IntPtr proc = HalconAPI.PreCall(715);

            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);
            int err1       = HalconAPI.CallProcedure(proc);
            int err2       = HalconAPI.LoadI(proc, 0, err1, out widthPattern);
            int err3       = HalconAPI.LoadI(proc, 1, err2, out heightPattern);
            int err4       = HalconAPI.LoadI(proc, 2, err3, out interpolation);
            int err5       = HalconAPI.LoadI(proc, 3, err4, out widthMaxChar);
            int err6       = HalconAPI.LoadI(proc, 4, err5, out heightMaxChar);
            int err7       = HTuple.LoadNew(proc, 5, err6, out features);
            int procResult = HTuple.LoadNew(proc, 6, err7, out characters);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
        }
예제 #5
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 HTuple AffineTransPoint3d(
            HTuple px,
            HTuple py,
            HTuple pz,
            out HTuple qy,
            out HTuple qz)
        {
            IntPtr proc = HalconAPI.PreCall(241);

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

            this.UnpinTuple();
            HalconAPI.UnpinTuple(px);
            HalconAPI.UnpinTuple(py);
            HalconAPI.UnpinTuple(pz);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, err1, out tuple);
            int    err3       = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out qy);
            int    procResult = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out qz);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
예제 #6
0
        /// <summary>
        ///   Searching the best matching of a template and an image.
        ///   Instance represents: Template number.
        /// </summary>
        /// <param name="image">Input image inside of which the pattern has to be found.</param>
        /// <param name="maxError">Maximum average difference of the grayvalues. Default: 20.0</param>
        /// <param name="subPixel">Subpixel accuracy in case of 'true'. Default: "false"</param>
        /// <param name="row">Row position of the best match.</param>
        /// <param name="column">Column position of the best match.</param>
        /// <param name="error">Average divergence of the grayvalues of the best match.</param>
        public void BestMatch(
            HImage image,
            double maxError,
            string subPixel,
            out HTuple row,
            out HTuple column,
            out HTuple error)
        {
            IntPtr proc = HalconAPI.PreCall(1505);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.StoreD(proc, 1, maxError);
            HalconAPI.StoreS(proc, 2, subPixel);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            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 procResult = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out error);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
        }
예제 #7
0
        /// <summary>
        ///   Read XLD polygons from a DXF file.
        ///   Modified instance represents: Read XLD polygons.
        /// </summary>
        /// <param name="fileName">Name of the DXF file.</param>
        /// <param name="genParamName">Names of the generic parameters that can be adjusted for the DXF input. Default: []</param>
        /// <param name="genParamValue">Values of the generic parameters that can be adjusted for the DXF input. Default: []</param>
        /// <returns>Status information.</returns>
        public HTuple ReadPolygonXldDxf(
            string fileName,
            HTuple genParamName,
            HTuple genParamValue)
        {
            this.Dispose();
            IntPtr proc = HalconAPI.PreCall(1634);

            HalconAPI.StoreS(proc, 0, fileName);
            HalconAPI.Store(proc, 1, genParamName);
            HalconAPI.Store(proc, 2, 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);
            HTuple tuple;
            int    procResult = HTuple.LoadNew(proc, 0, err2, out tuple);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
예제 #8
0
        /// <summary>
        ///   Inspect beads in an image, as defined by the bead inspection model.
        ///   Instance represents: Handle of the bead inspection model to be used.
        /// </summary>
        /// <param name="image">Image to apply bead inspection on.</param>
        /// <param name="rightContour">The detected right contour of the beads.</param>
        /// <param name="errorSegment">Detected error segments</param>
        /// <param name="errorType">Types of detected errors.</param>
        /// <returns>The detected left contour of the beads.</returns>
        public HXLD ApplyBeadInspectionModel(
            HImage image,
            out HXLD rightContour,
            out HXLD errorSegment,
            out HTuple errorType)
        {
            IntPtr proc = HalconAPI.PreCall(1983);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            HalconAPI.InitOCT(proc, 0);
            int  err1 = HalconAPI.CallProcedure(proc);
            HXLD hxld;
            int  err2       = HXLD.LoadNew(proc, 1, err1, out hxld);
            int  err3       = HXLD.LoadNew(proc, 2, err2, out rightContour);
            int  err4       = HXLD.LoadNew(proc, 3, err3, out errorSegment);
            int  procResult = HTuple.LoadNew(proc, 0, err4, out errorType);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
            return(hxld);
        }
예제 #9
0
        /// <summary>
        ///   Return an XLD polygon's data (as lines).
        ///   Instance represents: Input XLD polygons.
        /// </summary>
        /// <param name="beginRow">Row coordinates of the lines' start points.</param>
        /// <param name="beginCol">Column coordinates of the lines' start points.</param>
        /// <param name="endRow">Column coordinates of the lines' end points.</param>
        /// <param name="endCol">Column coordinates of the lines' end points.</param>
        /// <param name="length">Lengths of the line segments.</param>
        /// <param name="phi">Angles of the line segments.</param>
        public void GetLinesXld(
            out HTuple beginRow,
            out HTuple beginCol,
            out HTuple endRow,
            out HTuple endCol,
            out HTuple length,
            out HTuple phi)
        {
            IntPtr proc = HalconAPI.PreCall(43);

            this.Store(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);
            int err1       = HalconAPI.CallProcedure(proc);
            int err2       = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, err1, out beginRow);
            int err3       = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out beginCol);
            int err4       = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out endRow);
            int err5       = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, err4, out endCol);
            int err6       = HTuple.LoadNew(proc, 4, HTupleType.DOUBLE, err5, out length);
            int procResult = HTuple.LoadNew(proc, 5, HTupleType.DOUBLE, err6, out phi);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
        }
예제 #10
0
        /// <summary>
        ///   Searching the best matching of a template and a pyramid with rotation.
        ///   Instance represents: Template number.
        /// </summary>
        /// <param name="image">Input image inside of which the pattern has to be found.</param>
        /// <param name="angleStart">Smallest Rotation of the pattern. Default: -0.39</param>
        /// <param name="angleExtend">Maximum positive Extension of AngleStart. Default: 0.79</param>
        /// <param name="maxError">Maximum average difference of the grayvalues. Default: 40.0</param>
        /// <param name="subPixel">Subpixel accuracy in case of 'true'. Default: "false"</param>
        /// <param name="numLevels">Number of the used resolution levels. Default: 3</param>
        /// <param name="row">Row position of the best match.</param>
        /// <param name="column">Column position of the best match.</param>
        /// <param name="angle">Rotation angle of pattern.</param>
        /// <param name="error">Average divergence of the grayvalues of the best match.</param>
        public void BestMatchRotMg(
            HImage image,
            double angleStart,
            double angleExtend,
            double maxError,
            string subPixel,
            int numLevels,
            out HTuple row,
            out HTuple column,
            out HTuple angle,
            out HTuple error)
        {
            IntPtr proc = HalconAPI.PreCall(1503);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.StoreD(proc, 1, angleStart);
            HalconAPI.StoreD(proc, 2, angleExtend);
            HalconAPI.StoreD(proc, 3, maxError);
            HalconAPI.StoreS(proc, 4, subPixel);
            HalconAPI.StoreI(proc, 5, numLevels);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            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 procResult = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, err4, out error);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
        }
예제 #11
0
        /// <summary>
        ///   Extract straight edges perpendicular to a rectangle or annular arc.
        ///   Instance represents: Measure object handle.
        /// </summary>
        /// <param name="image">Input image.</param>
        /// <param name="sigma">Sigma of gaussian smoothing. Default: 1.0</param>
        /// <param name="threshold">Minimum edge amplitude. Default: 30.0</param>
        /// <param name="transition">Light/dark or dark/light edge. Default: "all"</param>
        /// <param name="select">Selection of end points. Default: "all"</param>
        /// <param name="rowEdge">Row coordinate of the center of the edge.</param>
        /// <param name="columnEdge">Column coordinate of the center of the edge.</param>
        /// <param name="amplitude">Edge amplitude of the edge (with sign).</param>
        /// <param name="distance">Distance between consecutive edges.</param>
        public void MeasurePos(
            HImage image,
            double sigma,
            double threshold,
            string transition,
            string select,
            out HTuple rowEdge,
            out HTuple columnEdge,
            out HTuple amplitude,
            out HTuple distance)
        {
            IntPtr proc = HalconAPI.PreCall(836);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.StoreD(proc, 1, sigma);
            HalconAPI.StoreD(proc, 2, threshold);
            HalconAPI.StoreS(proc, 3, transition);
            HalconAPI.StoreS(proc, 4, select);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            int err1       = HalconAPI.CallProcedure(proc);
            int err2       = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, err1, out rowEdge);
            int err3       = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out columnEdge);
            int err4       = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out amplitude);
            int procResult = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, err4, out distance);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
        }
예제 #12
0
        /// <summary>
        ///   Return the parameters of an OCR classifier.
        ///   Instance represents: Handle of the OCR classifier.
        /// </summary>
        /// <param name="widthCharacter">Width of the rectangle to which the gray values of the segmented character are zoomed.</param>
        /// <param name="heightCharacter">Height of the rectangle to which the gray values of the segmented character are zoomed.</param>
        /// <param name="interpolation">Interpolation mode for the zooming of the characters.</param>
        /// <param name="features">Features to be used for classification.</param>
        /// <param name="characters">Characters of the character set to be read.</param>
        /// <param name="preprocessing">Type of preprocessing used to transform the feature vectors.</param>
        /// <param name="numTrees">Number of different trees used during the classifcation.</param>
        public void GetParamsOcrClassKnn(
            out int widthCharacter,
            out int heightCharacter,
            out string interpolation,
            out string features,
            out HTuple characters,
            out string preprocessing,
            out int numTrees)
        {
            IntPtr proc = HalconAPI.PreCall(657);

            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);
            int err1       = HalconAPI.CallProcedure(proc);
            int err2       = HalconAPI.LoadI(proc, 0, err1, out widthCharacter);
            int err3       = HalconAPI.LoadI(proc, 1, err2, out heightCharacter);
            int err4       = HalconAPI.LoadS(proc, 2, err3, out interpolation);
            int err5       = HalconAPI.LoadS(proc, 3, err4, out features);
            int err6       = HTuple.LoadNew(proc, 4, err5, out characters);
            int err7       = HalconAPI.LoadS(proc, 5, err6, out preprocessing);
            int procResult = HalconAPI.LoadI(proc, 6, err7, out numTrees);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
        }
예제 #13
0
        /// <summary>
        ///   Return the initial or model components in a certain image.
        ///   Instance represents: Handle of the training result.
        /// </summary>
        /// <param name="components">Type of returned components or index of an initial component. Default: "model_components"</param>
        /// <param name="image">Image for which the components are to be returned. Default: "model_image"</param>
        /// <param name="markOrientation">Mark the orientation of the components. Default: "false"</param>
        /// <param name="row">Row coordinate of the found instances of all initial components or model components.</param>
        /// <param name="column">Column coordinate of the found instances of all initial components or model components.</param>
        /// <param name="angle">Rotation angle of the found instances of all components.</param>
        /// <param name="score">Score of the found instances of all components.</param>
        /// <returns>Contour regions of the initial components or of the model components.</returns>
        public HRegion GetTrainingComponents(
            HTuple components,
            HTuple image,
            string markOrientation,
            out HTuple row,
            out HTuple column,
            out HTuple angle,
            out HTuple score)
        {
            IntPtr proc = HalconAPI.PreCall(1009);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, components);
            HalconAPI.Store(proc, 2, image);
            HalconAPI.StoreS(proc, 3, markOrientation);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            int err1 = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(components);
            HalconAPI.UnpinTuple(image);
            HRegion hregion;
            int     err2       = HRegion.LoadNew(proc, 1, err1, out hregion);
            int     err3       = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, err2, out row);
            int     err4       = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err3, out column);
            int     err5       = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err4, out angle);
            int     procResult = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, err5, out score);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(hregion);
        }
예제 #14
0
        /// <summary>
        ///   Selects an optimal subset from a set of features to solve a certain  classification problem.
        ///   Instance represents: Handle of the training data.
        /// </summary>
        /// <param name="selectionMethod">Method to perform the selection. Default: "greedy"</param>
        /// <param name="genParamName">Names of generic parameters to configure the selection process and the classifier. Default: []</param>
        /// <param name="genParamValue">Values of generic parameters to configure the  selection process and the classifier. Default: []</param>
        /// <param name="selectedFeatureIndices">The selected feature set, contains  indices or names.</param>
        /// <param name="score">The achieved score using two-fold cross-validation.</param>
        /// <returns>A trained k-NN classifier using only the selected  features.</returns>
        public HClassKnn SelectFeatureSetKnn(
            string selectionMethod,
            string genParamName,
            double genParamValue,
            out HTuple selectedFeatureIndices,
            out HTuple score)
        {
            IntPtr proc = HalconAPI.PreCall(1802);

            this.Store(proc, 0);
            HalconAPI.StoreS(proc, 1, selectionMethod);
            HalconAPI.StoreS(proc, 2, genParamName);
            HalconAPI.StoreD(proc, 3, genParamValue);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            int       err1 = HalconAPI.CallProcedure(proc);
            HClassKnn hclassKnn;
            int       err2       = HClassKnn.LoadNew(proc, 0, err1, out hclassKnn);
            int       err3       = HTuple.LoadNew(proc, 1, err2, out selectedFeatureIndices);
            int       procResult = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out score);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(hclassKnn);
        }
예제 #15
0
        /// <summary>
        ///   Describe the classes of a box classifier.
        ///   Instance represents: Handle of the classifier.
        /// </summary>
        /// <param name="dimensions">Highest dimension for output. Default: 3</param>
        /// <param name="boxIdx">Indices of the boxes.</param>
        /// <param name="boxLowerBound">Lower bounds of the boxes (for each dimension).</param>
        /// <param name="boxHigherBound">Higher bounds of the boxes (for each dimension).</param>
        /// <param name="boxNumSamplesTrain">Number of training samples that were used to define this box (for each dimension).</param>
        /// <param name="boxNumSamplesWrong">Number of training samples that were assigned incorrectly to the box.</param>
        /// <returns>Indices of the classes.</returns>
        public HTuple DescriptClassBox(
            int dimensions,
            out HTuple boxIdx,
            out HTuple boxLowerBound,
            out HTuple boxHigherBound,
            out HTuple boxNumSamplesTrain,
            out HTuple boxNumSamplesWrong)
        {
            IntPtr proc = HalconAPI.PreCall(1896);

            this.Store(proc, 0);
            HalconAPI.StoreI(proc, 1, dimensions);
            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);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, HTupleType.INTEGER, err1, out tuple);
            int    err3       = HTuple.LoadNew(proc, 1, HTupleType.INTEGER, err2, out boxIdx);
            int    err4       = HTuple.LoadNew(proc, 2, HTupleType.INTEGER, err3, out boxLowerBound);
            int    err5       = HTuple.LoadNew(proc, 3, HTupleType.INTEGER, err4, out boxHigherBound);
            int    err6       = HTuple.LoadNew(proc, 4, HTupleType.INTEGER, err5, out boxNumSamplesTrain);
            int    procResult = HTuple.LoadNew(proc, 5, HTupleType.INTEGER, err6, out boxNumSamplesWrong);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
예제 #16
0
        /// <summary>
        ///   Return the parameters of a Gaussian Mixture Model.
        ///   Instance represents: GMM handle.
        /// </summary>
        /// <param name="numClasses">Number of classes of the GMM.</param>
        /// <param name="minCenters">Minimum number of centers per GMM class.</param>
        /// <param name="maxCenters">Maximum number of centers per GMM class.</param>
        /// <param name="covarType">Type of the covariance matrices.</param>
        /// <returns>Number of dimensions of the feature space.</returns>
        public int GetParamsClassGmm(
            out int numClasses,
            out HTuple minCenters,
            out HTuple maxCenters,
            out string covarType)
        {
            IntPtr proc = HalconAPI.PreCall(1839);

            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.LoadI(proc, 1, err2, out numClasses);
            int err4       = HTuple.LoadNew(proc, 2, HTupleType.INTEGER, err3, out minCenters);
            int err5       = HTuple.LoadNew(proc, 3, HTupleType.INTEGER, err4, out maxCenters);
            int procResult = HalconAPI.LoadS(proc, 4, err5, out covarType);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(intValue);
        }
예제 #17
0
        /// <summary>
        ///   Selects an optimal subset from a set of features to solve a certain  classification problem.
        ///   Modified instance represents: A trained k-NN classifier using only the selected  features.
        /// </summary>
        /// <param name="classTrainDataHandle">Handle of the training data.</param>
        /// <param name="selectionMethod">Method to perform the selection. Default: "greedy"</param>
        /// <param name="genParamName">Names of generic parameters to configure the selection process and the classifier. Default: []</param>
        /// <param name="genParamValue">Values of generic parameters to configure the  selection process and the classifier. Default: []</param>
        /// <param name="score">The achieved score using two-fold cross-validation.</param>
        /// <returns>The selected feature set, contains  indices or names.</returns>
        public HTuple SelectFeatureSetKnn(
            HClassTrainData classTrainDataHandle,
            string selectionMethod,
            string genParamName,
            double genParamValue,
            out HTuple score)
        {
            this.Dispose();
            IntPtr proc = HalconAPI.PreCall(1802);

            HalconAPI.Store(proc, 0, (HTool)classTrainDataHandle);
            HalconAPI.StoreS(proc, 1, selectionMethod);
            HalconAPI.StoreS(proc, 2, genParamName);
            HalconAPI.StoreD(proc, 3, genParamValue);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            int    err1 = HalconAPI.CallProcedure(proc);
            int    err2 = this.Load(proc, 0, err1);
            HTuple tuple;
            int    err3       = HTuple.LoadNew(proc, 1, err2, out tuple);
            int    procResult = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out score);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)classTrainDataHandle);
            return(tuple);
        }
예제 #18
0
        /// <summary>
        ///   Train a Gaussian Mixture Model.
        ///   Instance represents: GMM handle.
        /// </summary>
        /// <param name="maxIter">Maximum number of iterations of the expectation maximization algorithm Default: 100</param>
        /// <param name="threshold">Threshold for relative change of the error for the expectation maximization algorithm to terminate. Default: 0.001</param>
        /// <param name="classPriors">Mode to determine the a-priori probabilities of the classes Default: "training"</param>
        /// <param name="regularize">Regularization value for preventing covariance matrix singularity. Default: 0.0001</param>
        /// <param name="iter">Number of executed iterations per class</param>
        /// <returns>Number of found centers per class</returns>
        public HTuple TrainClassGmm(
            int maxIter,
            double threshold,
            string classPriors,
            double regularize,
            out HTuple iter)
        {
            IntPtr proc = HalconAPI.PreCall(1834);

            this.Store(proc, 0);
            HalconAPI.StoreI(proc, 1, maxIter);
            HalconAPI.StoreD(proc, 2, threshold);
            HalconAPI.StoreS(proc, 3, classPriors);
            HalconAPI.StoreD(proc, 4, regularize);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int    err1 = HalconAPI.CallProcedure(proc);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, HTupleType.INTEGER, err1, out tuple);
            int    procResult = HTuple.LoadNew(proc, 1, HTupleType.INTEGER, err2, out iter);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
예제 #19
0
        /// <summary>
        ///   Calculate the class of a feature vector by a Gaussian Mixture Model.
        ///   Instance represents: GMM handle.
        /// </summary>
        /// <param name="features">Feature vector.</param>
        /// <param name="num">Number of best classes to determine. Default: 1</param>
        /// <param name="classProb">A-posteriori probability of the classes.</param>
        /// <param name="density">Probability density of the feature vector.</param>
        /// <param name="KSigmaProb">Normalized k-sigma-probability for the feature vector.</param>
        /// <returns>Result of classifying the feature vector with the GMM.</returns>
        public HTuple ClassifyClassGmm(
            HTuple features,
            int num,
            out HTuple classProb,
            out HTuple density,
            out HTuple KSigmaProb)
        {
            IntPtr proc = HalconAPI.PreCall(1832);

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

            HalconAPI.UnpinTuple(features);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, HTupleType.INTEGER, err1, out tuple);
            int    err3       = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out classProb);
            int    err4       = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out density);
            int    procResult = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, err4, out KSigmaProb);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(tuple);
        }
예제 #20
0
        /// <summary>
        ///   Get the depth or the index of instances in a displayed 3D scene.
        ///   Instance represents: Handle of the 3D scene.
        /// </summary>
        /// <param name="windowHandle">Window handle.</param>
        /// <param name="row">Row coordinates.</param>
        /// <param name="column">Column coordinates.</param>
        /// <param name="information">Information. Default: "depth"</param>
        /// <returns>Indices or the depth of the objects at (Row,Column).</returns>
        public HTuple GetDisplayScene3dInfo(
            HWindow windowHandle,
            HTuple row,
            HTuple column,
            HTuple information)
        {
            IntPtr proc = HalconAPI.PreCall(1204);

            this.Store(proc, 1);
            HalconAPI.Store(proc, 0, (HTool)windowHandle);
            HalconAPI.Store(proc, 2, row);
            HalconAPI.Store(proc, 3, column);
            HalconAPI.Store(proc, 4, information);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

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

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)windowHandle);
            return(tuple);
        }
예제 #21
0
        /// <summary>
        ///   Asynchronous grab of images and preprocessed image data from the specified image acquisition device.
        ///   Instance represents: Handle of the acquisition device to be used.
        /// </summary>
        /// <param name="region">Pre-processed image regions.</param>
        /// <param name="contours">Pre-processed XLD contours.</param>
        /// <param name="maxDelay">Maximum tolerated delay between the start of the asynchronous grab and the delivery of the image [ms]. Default: -1.0</param>
        /// <param name="data">Pre-processed control data.</param>
        /// <returns>Grabbed image data.</returns>
        public HImage GrabDataAsync(
            out HRegion region,
            out HXLDCont contours,
            double maxDelay,
            out HTuple data)
        {
            IntPtr proc = HalconAPI.PreCall(2029);

            this.Store(proc, 0);
            HalconAPI.StoreD(proc, 1, maxDelay);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            HalconAPI.InitOCT(proc, 0);
            int    err1 = HalconAPI.CallProcedure(proc);
            HImage himage;
            int    err2       = HImage.LoadNew(proc, 1, err1, out himage);
            int    err3       = HRegion.LoadNew(proc, 2, err2, out region);
            int    err4       = HXLDCont.LoadNew(proc, 3, err3, out contours);
            int    procResult = HTuple.LoadNew(proc, 0, err4, out data);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(himage);
        }
예제 #22
0
        /// <summary>
        ///   Get point-based observation data from a calibration data model.
        ///   Instance represents: Handle of a calibration data model.
        /// </summary>
        /// <param name="cameraIdx">Index of the observing camera. Default: 0</param>
        /// <param name="calibObjIdx">Index of the observed calibration object. Default: 0</param>
        /// <param name="calibObjPoseIdx">Index of the observed calibration object pose. Default: 0</param>
        /// <param name="row">Row coordinates of the detected points.</param>
        /// <param name="column">Column coordinates of the detected points.</param>
        /// <param name="index">Correspondence of the detected points to the points of the observed calibration object.</param>
        /// <param name="pose">Roughly estimated pose of the observed calibration object relative to the observing camera.</param>
        public void GetCalibDataObservPoints(
            int cameraIdx,
            int calibObjIdx,
            int calibObjPoseIdx,
            out HTuple row,
            out HTuple column,
            out HTuple index,
            out HTuple pose)
        {
            IntPtr proc = HalconAPI.PreCall(1974);

            this.Store(proc, 0);
            HalconAPI.StoreI(proc, 1, cameraIdx);
            HalconAPI.StoreI(proc, 2, calibObjIdx);
            HalconAPI.StoreI(proc, 3, calibObjPoseIdx);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            HalconAPI.InitOCT(proc, 2);
            HalconAPI.InitOCT(proc, 3);
            int err1       = HalconAPI.CallProcedure(proc);
            int err2       = HTuple.LoadNew(proc, 0, err1, out row);
            int err3       = HTuple.LoadNew(proc, 1, err2, out column);
            int err4       = HTuple.LoadNew(proc, 2, err3, out index);
            int procResult = HTuple.LoadNew(proc, 3, err4, out pose);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
        }
예제 #23
0
        /// <summary>
        ///   Classify a related group of characters with an 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 k-NN.</returns>
        public HTuple DoOcrWordKnn(
            HRegion character,
            HImage image,
            string expression,
            int numAlternatives,
            int numCorrections,
            out HTuple confidence,
            out string word,
            out double score)
        {
            IntPtr proc = HalconAPI.PreCall(647);

            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);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, err1, out tuple);
            int    err3       = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, 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(tuple);
        }
        /// <summary>
        ///   Find the best match of a deformable surface model in a 3D scene.
        ///   Instance represents: Handle of the deformable surface model.
        /// </summary>
        /// <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>
        /// <param name="deformableSurfaceMatchingResult">Handle of the matching result.</param>
        /// <returns>Score of the found instances of the surface model.</returns>
        public HTuple FindDeformableSurfaceModel(
            HObjectModel3D objectModel3D,
            double relSamplingDistance,
            HTuple minScore,
            HTuple genParamName,
            HTuple genParamValue,
            out HDeformableSurfaceMatchingResult[] deformableSurfaceMatchingResult)
        {
            IntPtr proc = HalconAPI.PreCall(1027);

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

            HalconAPI.UnpinTuple(minScore);
            HalconAPI.UnpinTuple(genParamName);
            HalconAPI.UnpinTuple(genParamValue);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, err1, out tuple);
            int    procResult = HDeformableSurfaceMatchingResult.LoadNew(proc, 1, err2, out deformableSurfaceMatchingResult);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)objectModel3D);
            return(tuple);
        }
예제 #25
0
        /// <summary>
        ///   Classify a single character with an OCR classifier.
        ///   Instance represents: Handle of the k-NN classifier.
        /// </summary>
        /// <param name="character">Character to be recognized.</param>
        /// <param name="image">Gray values of the character.</param>
        /// <param name="numClasses">Number of maximal classes to determine. Default: 1</param>
        /// <param name="numNeighbors">Number of neighbors to consider. Default: 1</param>
        /// <param name="confidence">Confidence(s) of the class(es) of the character.</param>
        /// <returns>Results of classifying the character with the k-NN.</returns>
        public HTuple DoOcrSingleClassKnn(
            HRegion character,
            HImage image,
            HTuple numClasses,
            HTuple numNeighbors,
            out HTuple confidence)
        {
            IntPtr proc = HalconAPI.PreCall(659);

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

            HalconAPI.UnpinTuple(numClasses);
            HalconAPI.UnpinTuple(numNeighbors);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, err1, out tuple);
            int    procResult = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out confidence);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)character);
            GC.KeepAlive((object)image);
            return(tuple);
        }
예제 #26
0
        /// <summary>Query indexing structure of AOP information for operators. </summary>
        /// <param name="operatorName">Operator to get information for Default: ""</param>
        /// <param name="indexName">Further specific index Default: ""</param>
        /// <param name="indexValue">Further specific address Default: ""</param>
        /// <param name="value">Values of next index stage</param>
        /// <returns>Name of next index stage</returns>
        public static HTuple QueryAopInfo(
            HTuple operatorName,
            HTuple indexName,
            HTuple indexValue,
            out HTuple value)
        {
            IntPtr proc = HalconAPI.PreCall(568);

            HalconAPI.Store(proc, 0, operatorName);
            HalconAPI.Store(proc, 1, indexName);
            HalconAPI.Store(proc, 2, indexValue);
            HalconAPI.InitOCT(proc, 0);
            HalconAPI.InitOCT(proc, 1);
            int err1 = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(operatorName);
            HalconAPI.UnpinTuple(indexName);
            HalconAPI.UnpinTuple(indexValue);
            HTuple tuple;
            int    err2       = HTuple.LoadNew(proc, 0, err1, out tuple);
            int    procResult = HTuple.LoadNew(proc, 1, err2, out value);

            HalconAPI.PostCall(proc, procResult);
            return(tuple);
        }
예제 #27
0
        /// <summary>
        ///   Verification of a pattern using an OCV tool.
        ///   Instance represents: Handle of the OCV tool.
        /// </summary>
        /// <param name="pattern">Characters to be verified.</param>
        /// <param name="patternName">Name of the character. Default: "a"</param>
        /// <param name="adaptPos">Adaption to vertical and horizontal translation. Default: "true"</param>
        /// <param name="adaptSize">Adaption to vertical and horizontal scaling of the size. Default: "true"</param>
        /// <param name="adaptAngle">Adaption to changes of the orientation (not implemented). Default: "false"</param>
        /// <param name="adaptGray">Adaption to additive and scaling gray value changes. Default: "true"</param>
        /// <param name="threshold">Minimum difference between objects. Default: 10</param>
        /// <returns>Evaluation of the character.</returns>
        public HTuple DoOcvSimple(
            HImage pattern,
            HTuple patternName,
            string adaptPos,
            string adaptSize,
            string adaptAngle,
            string adaptGray,
            double threshold)
        {
            IntPtr proc = HalconAPI.PreCall(638);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)pattern);
            HalconAPI.Store(proc, 1, patternName);
            HalconAPI.StoreS(proc, 2, adaptPos);
            HalconAPI.StoreS(proc, 3, adaptSize);
            HalconAPI.StoreS(proc, 4, adaptAngle);
            HalconAPI.StoreS(proc, 5, adaptGray);
            HalconAPI.StoreD(proc, 6, threshold);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

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

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)pattern);
            return(tuple);
        }
예제 #28
0
        /// <summary>
        ///   Detect and read 2D data code symbols in an image or train the 2D data code model.
        ///   Instance represents: Handle of the 2D data code model.
        /// </summary>
        /// <param name="image">Input image. If the image has a reduced domain, the data code search is reduced to that domain. This usually reduces the runtime of the operator. However, if the datacode is not fully inside the domain, the datacode might not be found correctly. In rare cases, data codes may be found outside the domain. If these results  are undesirable, they have to be subsequently eliminated. </param>
        /// <param name="genParamName">Names of (optional) parameters for controlling the behavior of the operator. Default: []</param>
        /// <param name="genParamValue">Values of the optional generic parameters. Default: []</param>
        /// <param name="resultHandles">Handles of all successfully decoded 2D data code symbols.</param>
        /// <param name="decodedDataStrings">Decoded data strings of all detected 2D data code symbols in the image.</param>
        /// <returns>XLD contours that surround the successfully decoded data code symbols. The order of the contour points reflects the orientation of the detected symbols. The contours begin in the top left corner (see 'orientation' at get_data_code_2d_results) and continue clockwise.  Alignment{left} Figure[1][1][60]{get_data_code_2d_results-xld_qrcode} Order of points of SymbolXLDs Figure Alignment @f$ </returns>
        public HXLDCont FindDataCode2d(
            HImage image,
            HTuple genParamName,
            HTuple genParamValue,
            out HTuple resultHandles,
            out HTuple decodedDataStrings)
        {
            IntPtr proc = HalconAPI.PreCall(1768);

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

            HalconAPI.UnpinTuple(genParamName);
            HalconAPI.UnpinTuple(genParamValue);
            HXLDCont hxldCont;
            int      err2       = HXLDCont.LoadNew(proc, 1, err1, out hxldCont);
            int      err3       = HTuple.LoadNew(proc, 0, HTupleType.INTEGER, err2, out resultHandles);
            int      procResult = HTuple.LoadNew(proc, 1, err3, out decodedDataStrings);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)image);
            return(hxldCont);
        }
예제 #29
0
        /// <summary>
        ///   Return the parameters of a descriptor model.
        ///   Instance represents: The object handle to the descriptor model.
        /// </summary>
        /// <param name="detectorParamName">The detectors parameter names.</param>
        /// <param name="detectorParamValue">Values of the detectors parameters.</param>
        /// <param name="descriptorParamName">The descriptors parameter names.</param>
        /// <param name="descriptorParamValue">Values of the descriptors parameters.</param>
        /// <returns>The type of the detector.</returns>
        public string GetDescriptorModelParams(
            out HTuple detectorParamName,
            out HTuple detectorParamValue,
            out HTuple descriptorParamName,
            out HTuple descriptorParamValue)
        {
            IntPtr proc = HalconAPI.PreCall(951);

            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);
            string stringValue;
            int    err2       = HalconAPI.LoadS(proc, 0, err1, out stringValue);
            int    err3       = HTuple.LoadNew(proc, 1, err2, out detectorParamName);
            int    err4       = HTuple.LoadNew(proc, 2, err3, out detectorParamValue);
            int    err5       = HTuple.LoadNew(proc, 3, err4, out descriptorParamName);
            int    procResult = HTuple.LoadNew(proc, 4, err5, out descriptorParamValue);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(stringValue);
        }
예제 #30
0
        /// <summary>
        ///   Extract straight edge pairs perpendicular to a rectangle or an annular arc.
        ///   Instance represents: Measure object handle.
        /// </summary>
        /// <param name="image">Input image.</param>
        /// <param name="sigma">Sigma of Gaussian smoothing. Default: 1.0</param>
        /// <param name="ampThresh">Minimum edge amplitude. Default: 30.0</param>
        /// <param name="fuzzyThresh">Minimum fuzzy value. Default: 0.5</param>
        /// <param name="transition">Select the first gray value transition of the edge pairs. Default: "all"</param>
        /// <param name="pairing">Constraint of pairing. Default: "no_restriction"</param>
        /// <param name="numPairs">Number of edge pairs. Default: 10</param>
        /// <param name="rowEdgeFirst">Row coordinate of the first edge.</param>
        /// <param name="columnEdgeFirst">Column coordinate of the first edge.</param>
        /// <param name="amplitudeFirst">Edge amplitude of the first edge (with sign).</param>
        /// <param name="rowEdgeSecond">Row coordinate of the second edge.</param>
        /// <param name="columnEdgeSecond">Column coordinate of the second edge.</param>
        /// <param name="amplitudeSecond">Edge amplitude of the second edge (with sign).</param>
        /// <param name="rowPairCenter">Row coordinate of the center of the edge pair.</param>
        /// <param name="columnPairCenter">Column coordinate of the center of the edge pair.</param>
        /// <param name="fuzzyScore">Fuzzy evaluation of the edge pair.</param>
        /// <param name="intraDistance">Distance between the edges of the edge pair.</param>
        public void FuzzyMeasurePairing(
            HImage image,
            double sigma,
            double ampThresh,
            double fuzzyThresh,
            string transition,
            string pairing,
            int numPairs,
            out HTuple rowEdgeFirst,
            out HTuple columnEdgeFirst,
            out HTuple amplitudeFirst,
            out HTuple rowEdgeSecond,
            out HTuple columnEdgeSecond,
            out HTuple amplitudeSecond,
            out HTuple rowPairCenter,
            out HTuple columnPairCenter,
            out HTuple fuzzyScore,
            out HTuple intraDistance)
        {
            IntPtr proc = HalconAPI.PreCall(832);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HObjectBase)image);
            HalconAPI.StoreD(proc, 1, sigma);
            HalconAPI.StoreD(proc, 2, ampThresh);
            HalconAPI.StoreD(proc, 3, fuzzyThresh);
            HalconAPI.StoreS(proc, 4, transition);
            HalconAPI.StoreS(proc, 5, pairing);
            HalconAPI.StoreI(proc, 6, numPairs);
            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);
            int err2       = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, err1, out rowEdgeFirst);
            int err3       = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out columnEdgeFirst);
            int err4       = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out amplitudeFirst);
            int err5       = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, err4, out rowEdgeSecond);
            int err6       = HTuple.LoadNew(proc, 4, HTupleType.DOUBLE, err5, out columnEdgeSecond);
            int err7       = HTuple.LoadNew(proc, 5, HTupleType.DOUBLE, err6, out amplitudeSecond);
            int err8       = HTuple.LoadNew(proc, 6, HTupleType.DOUBLE, err7, out rowPairCenter);
            int err9       = HTuple.LoadNew(proc, 7, HTupleType.DOUBLE, err8, out columnPairCenter);
            int err10      = HTuple.LoadNew(proc, 8, HTupleType.DOUBLE, err9, out fuzzyScore);
            int procResult = HTuple.LoadNew(proc, 9, HTupleType.DOUBLE, err10, out intraDistance);

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