Ejemplo n.º 1
0
        // recogident.c (401, 1)
        // recogCorrelationBestRow(recog, pixs, pboxa, pnascore, pnaindex, psachar, debug) as int
        // recogCorrelationBestRow(L_RECOG *, PIX *, BOXA **, NUMA **, NUMA **, SARRAY **, l_int32) as l_ok
        ///  <summary>
        /// (1) Supervises character matching for (in general) a c.c with
        /// multiple touching characters.  Finds the best match greedily.
        /// Rejects small parts that are left over after splitting.<para/>
        ///
        /// (2) Matching is to the average, and without character scaling.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogCorrelationBestRow/*"/>
        ///  <param name="recog">[in] - with LUT's pre-computed</param>
        ///  <param name="pixs">[in] - typically of multiple touching characters, 1 bpp</param>
        ///  <param name="pboxa">[out] - bounding boxs of best fit character</param>
        ///  <param name="pnascore">[out][optional] - correlation scores</param>
        ///  <param name="pnaindex">[out][optional] - indices of classes</param>
        ///  <param name="psachar">[out][optional] - array of character strings</param>
        ///  <param name="debug">[in] - 1 for results written to pixadb_split</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogCorrelationBestRow(
            L_Recog recog,
            Pix pixs,
            out Boxa pboxa,
            out Numa pnascore,
            out Numa pnaindex,
            out Sarray psachar,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr pboxaPtr    = IntPtr.Zero;
            IntPtr pnascorePtr = IntPtr.Zero;
            IntPtr pnaindexPtr = IntPtr.Zero;
            IntPtr psacharPtr  = IntPtr.Zero;
            int    _Result     = Natives.recogCorrelationBestRow(recog.Pointer, pixs.Pointer, out pboxaPtr, out pnascorePtr, out pnaindexPtr, out psacharPtr, (int)debug);

            if (pboxaPtr == IntPtr.Zero)
            {
                pboxa = null;
            }
            else
            {
                pboxa = new Boxa(pboxaPtr);
            };
            if (pnascorePtr == IntPtr.Zero)
            {
                pnascore = null;
            }
            else
            {
                pnascore = new Numa(pnascorePtr);
            };
            if (pnaindexPtr == IntPtr.Zero)
            {
                pnaindex = null;
            }
            else
            {
                pnaindex = new Numa(pnaindexPtr);
            };
            if (psacharPtr == IntPtr.Zero)
            {
                psachar = null;
            }
            else
            {
                psachar = new Sarray(psacharPtr);
            };

            return(_Result);
        }
Ejemplo n.º 2
0
        // recogtrain.c (212, 1)
        // recogTrainLabeled(recog, pixs, box, text, debug) as int
        // recogTrainLabeled(L_RECOG *, PIX *, BOX *, char *, l_int32) as l_ok
        ///  <summary>
        /// (1) Training is restricted to the addition of a single
        /// character in an arbitrary (e.g., UTF8) charset<para/>
        ///
        /// (2) If box != null, it should represent the location in %pixs
        /// of the character image.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogTrainLabeled/*"/>
        ///  <param name="recog">[in] - in training mode</param>
        ///  <param name="pixs">[in] - if depth  is greater  1, will be thresholded to 1 bpp</param>
        ///  <param name="box">[in][optional] - cropping box</param>
        ///  <param name="text">[in][optional] - if null, use text field in pix</param>
        ///  <param name="debug">[in] - 1 to display images of samples not captured</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogTrainLabeled(
            L_Recog recog,
            Pix pixs,
            Box box     = null,
            String text = "",
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr boxPtr = IntPtr.Zero;    if (box != null)
            {
                boxPtr = box.Pointer;
            }
            int _Result = Natives.recogTrainLabeled(recog.Pointer, pixs.Pointer, boxPtr, text, (int)debug);

            return(_Result);
        }
Ejemplo n.º 3
0
        // recogtrain.c (2405, 1)
        // recogShowMatch(recog, pix1, pix2, box, index, score) as Pix
        // recogShowMatch(L_RECOG *, PIX *, PIX *, BOX *, l_int32, l_float32) as PIX *
        ///  <summary>
        /// (1) pix1 can be one of these:
        /// (a) The input pix alone, which can be either a single character
        /// (box == NULL) or several characters that need to be
        /// segmented.  If more than character is present, the box
        /// region is displayed with an outline.
        /// (b) Both the input pix and the matching template.  In this case,
        /// pix2 and box will both be null.<para/>
        ///
        /// (2) If the bmf has been made (by a call to recogMakeBmf())
        /// and the index greater or equal 0, the text field, match score and index
        /// will be rendered otherwise their values will be ignored.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogShowMatch/*"/>
        ///  <param name="recog">[in] - </param>
        ///  <param name="pix1">[in] - input pix several possibilities</param>
        ///  <param name="pix2">[in][optional] - matching template</param>
        ///  <param name="box">[in][optional] - region in pix1 for which pix2 matches</param>
        ///  <param name="index">[in] - index of matching template use -1 to disable printing</param>
        ///  <param name="score">[in] - score of match</param>
        ///   <returns>pixd pair of images, showing input pix and best template, optionally with matching information, or NULL on error.</returns>
        public static Pix recogShowMatch(
            L_Recog recog,
            Pix pix1,
            Pix pix2,
            Box box,
            int index,
            Single score)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pix1 == null)
            {
                throw new ArgumentNullException("pix1 cannot be Nothing");
            }

            IntPtr pix2Ptr = IntPtr.Zero;   if (pix2 != null)
            {
                pix2Ptr = pix2.Pointer;
            }
            IntPtr boxPtr = IntPtr.Zero;    if (box != null)
            {
                boxPtr = box.Pointer;
            }
            IntPtr _Result = Natives.recogShowMatch(recog.Pointer, pix1.Pointer, pix2Ptr, boxPtr, index, score);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pix(_Result));
        }
Ejemplo n.º 4
0
        // recogtrain.c (1488, 1)
        // recogTrainFromBoot(recogboot, pixas, minscore, threshold, debug) as Pixa
        // recogTrainFromBoot(L_RECOG *, PIXA *, l_float32, l_int32, l_int32) as PIXA *
        ///  <summary>
        /// (1) This takes %pixas of unscaled single characters and %recboot,
        /// a bootstrep recognizer (BSR) that has been set up with parameters
        /// scaleh: scale all templates to this height
        /// linew: width of normalized strokes, or 0 if using
        /// the input image
        /// It modifies the pix in %pixas accordingly and correlates
        /// with the templates in the BSR.  It returns those input
        /// images in %pixas whose best correlation with the BSR is at
        /// or above %minscore.  The returned pix have added text labels
        /// for the text string of the class to which the best
        /// correlated template belongs.<para/>
        ///
        /// (2) Identification occurs in scaled mode (typically with h = 40),
        /// optionally using a width-normalized line images derived
        /// from those in %pixas.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogTrainFromBoot/*"/>
        ///  <param name="recogboot">[in] - labeled boot recognizer</param>
        ///  <param name="pixas">[in] - set of unlabeled input characters</param>
        ///  <param name="minscore">[in] - min score for accepting the example e.g., 0.75</param>
        ///  <param name="threshold">[in] - for binarization, if needed</param>
        ///  <param name="debug">[in] - 1 for debug output saved to recogboot 0 otherwise</param>
        ///   <returns>pixad   labeled version of input pixas, trained on a BSR, or NULL on error</returns>
        public static Pixa recogTrainFromBoot(
            L_Recog recogboot,
            Pixa pixas,
            Single minscore,
            int threshold,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (recogboot == null)
            {
                throw new ArgumentNullException("recogboot cannot be Nothing");
            }

            if (pixas == null)
            {
                throw new ArgumentNullException("pixas cannot be Nothing");
            }

            IntPtr _Result = Natives.recogTrainFromBoot(recogboot.Pointer, pixas.Pointer, minscore, threshold, (int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pixa(_Result));
        }
Ejemplo n.º 5
0
        // recogident.c (971, 1)
        // recogIdentifyPix(recog, pixs, ppixdb) as int
        // recogIdentifyPix(L_RECOG *, PIX *, PIX **) as l_ok
        ///  <summary>
        /// (1) Basic recognition function for a single character.<para/>
        ///
        /// (2) If templ_use == L_USE_ALL_TEMPLATES, which is the default
        /// situation, matching is attempted to every bitmap in the recog,
        /// and the identify of the best match is returned.<para/>
        ///
        /// (3) For finding outliers, templ_use == L_USE_AVERAGE_TEMPLATES, and
        /// matching is only attemplted to the averaged bitmaps.  For this
        /// case, the index of the bestsample is meaningless (0 is returned
        /// if requested).<para/>
        ///
        /// (4) The score is related to the confidence (probability of correct
        /// identification), in that a higher score is correlated with
        /// a higher probability.  However, the actual relation between
        /// the correlation (score) and the probability is not known
        /// we call this a "score" because "confidence" can be misinterpreted
        /// as an actual probability.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogIdentifyPix/*"/>
        ///  <param name="recog">[in] - with LUT's pre-computed</param>
        ///  <param name="pixs">[in] - of a single character, 1 bpp</param>
        ///  <param name="ppixdb">[out][optional] - debug pix showing input and best fit</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogIdentifyPix(
            L_Recog recog,
            Pix pixs,
            out Pix ppixdb)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr ppixdbPtr = IntPtr.Zero;
            int    _Result   = Natives.recogIdentifyPix(recog.Pointer, pixs.Pointer, out ppixdbPtr);

            if (ppixdbPtr == IntPtr.Zero)
            {
                ppixdb = null;
            }
            else
            {
                ppixdb = new Pix(ppixdbPtr);
            };

            return(_Result);
        }
Ejemplo n.º 6
0
        // recogdid.c (215, 1)
        // recogDecode(recog, pixs, nlevels, ppixdb) as Boxa
        // recogDecode(L_RECOG *, PIX *, l_int32, PIX **) as BOXA *
        ///  <summary>
        /// (1) The input pixs has been filtered so that it is likely to be
        /// composed of more than one touching character.  Specifically,
        /// its height can only slightly exceed that of the tallest
        /// unscaled template, the width is somewhat larger than the
        /// width of the widest unscaled template, and the w/h aspect ratio
        /// is bounded by max_wh_ratio.<para/>
        ///
        /// (2) This uses the DID mechanism with labeled templates to
        /// segment the input %pixs.  The resulting segmentation is
        /// returned.  (It is given by didtoboxa).<para/>
        ///
        /// (3) In debug mode, the Viterbi path is rescored based on all
        /// the templates.  In non-debug mode, the same procedure is
        /// carried out by recogIdentifyPix() on the result of the
        /// segmentation.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogDecode/*"/>
        ///  <param name="recog">[in] - with LUT's pre-computed</param>
        ///  <param name="pixs">[in] - typically of multiple touching characters, 1 bpp</param>
        ///  <param name="nlevels">[in] - of templates 2 for now</param>
        ///  <param name="ppixdb">[out][optional] - debug result can be null</param>
        ///   <returns>boxa  segmentation of pixs into characters, or NULL on error</returns>
        public static Boxa recogDecode(
            L_Recog recog,
            Pix pixs,
            int nlevels,
            out Pix ppixdb)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr ppixdbPtr = IntPtr.Zero;
            IntPtr _Result   = Natives.recogDecode(recog.Pointer, pixs.Pointer, nlevels, out ppixdbPtr);

            if (ppixdbPtr == IntPtr.Zero)
            {
                ppixdb = null;
            }
            else
            {
                ppixdb = new Pix(ppixdbPtr);
            };

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Boxa(_Result));
        }
Ejemplo n.º 7
0
        // recogtrain.c (261, 1)
        // recogProcessLabeled(recog, pixs, box, text, ppix) as int
        // recogProcessLabeled(L_RECOG *, PIX *, BOX *, char *, PIX **) as l_ok
        ///  <summary>
        /// (1) This crops and binarizes the input image, generating a pix
        /// of one character where the charval is inserted into the pix.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogProcessLabeled/*"/>
        ///  <param name="recog">[in] - in training mode</param>
        ///  <param name="pixs">[in] - if depth  is greater  1, will be thresholded to 1 bpp</param>
        ///  <param name="box">[in][optional] - cropping box</param>
        ///  <param name="text">[in][optional] - if null, use text field in pix</param>
        ///  <param name="ppix">[out] - addr of pix, 1 bpp, labeled</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogProcessLabeled(
            L_Recog recog,
            Pix pixs,
            Box box,
            String text,
            out Pix ppix)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr boxPtr = IntPtr.Zero;    if (box != null)
            {
                boxPtr = box.Pointer;
            }
            IntPtr ppixPtr = IntPtr.Zero;
            int    _Result = Natives.recogProcessLabeled(recog.Pointer, pixs.Pointer, boxPtr, text, out ppixPtr);

            if (ppixPtr == IntPtr.Zero)
            {
                ppix = null;
            }
            else
            {
                ppix = new Pix(ppixPtr);
            };

            return(_Result);
        }
Ejemplo n.º 8
0
        // recogdid.c (874, 1)
        // recogDidExists(recog) as int
        // recogDidExists(L_RECOG *) as l_int32
        ///  <summary>
        /// recogDidExists()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogDidExists/*"/>
        ///  <param name="recog">[in] - </param>
        ///   <returns>1 if recogtodid exists 0 if not or on error.</returns>
        public static int recogDidExists(
            L_Recog recog)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            int _Result = Natives.recogDidExists(recog.Pointer);

            return(_Result);
        }
Ejemplo n.º 9
0
        // recogident.c (158, 1)
        // recogIdentifyMultiple(recog, pixs, minh, skipsplit, pboxa, ppixa, ppixdb, debugsplit) as int
        // recogIdentifyMultiple(L_RECOG *, PIX *, l_int32, l_int32, BOXA **, PIXA **, PIX **, l_int32) as l_ok
        ///  <summary>
        /// (1) This filters the input pixa and calls recogIdentifyPixa()<para/>
        ///
        /// (2) Splitting is relatively slow, because it tries to match all
        /// character templates to all locations.  This step can be skipped.<para/>
        ///
        /// (3) An attempt is made to order the (optionally) returned images
        /// and boxes in 2-dimensional sorted order.  These can then
        /// be used to aggregate identified characters into numbers or words.
        /// One typically wants the pixa, which contains a boxa of the
        /// extracted subimages.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogIdentifyMultiple/*"/>
        ///  <param name="recog">[in] - with training finished</param>
        ///  <param name="pixs">[in] - containing typically a small number of characters</param>
        ///  <param name="minh">[in] - remove shorter components use 0 for default</param>
        ///  <param name="skipsplit">[in] - 1 to skip the splitting step</param>
        ///  <param name="pboxa">[out][optional] - locations of identified components</param>
        ///  <param name="ppixa">[out][optional] - images of identified components</param>
        ///  <param name="ppixdb">[out][optional] - debug pix: inputs and best fits</param>
        ///  <param name="debugsplit">[in] - 1 returns pix split debugging images</param>
        ///   <returns>0 if OK 1 if nothing is found 2 for other errors.</returns>
        public static int recogIdentifyMultiple(
            L_Recog recog,
            Pix pixs,
            int minh,
            int skipsplit,
            out Boxa pboxa,
            out Pixa ppixa,
            out Pix ppixdb,
            int debugsplit)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr pboxaPtr  = IntPtr.Zero;
            IntPtr ppixaPtr  = IntPtr.Zero;
            IntPtr ppixdbPtr = IntPtr.Zero;
            int    _Result   = Natives.recogIdentifyMultiple(recog.Pointer, pixs.Pointer, minh, skipsplit, out pboxaPtr, out ppixaPtr, out ppixdbPtr, debugsplit);

            if (pboxaPtr == IntPtr.Zero)
            {
                pboxa = null;
            }
            else
            {
                pboxa = new Boxa(pboxaPtr);
            };
            if (ppixaPtr == IntPtr.Zero)
            {
                ppixa = null;
            }
            else
            {
                ppixa = new Pixa(ppixaPtr);
            };
            if (ppixdbPtr == IntPtr.Zero)
            {
                ppixdb = null;
            }
            else
            {
                ppixdb = new Pix(ppixdbPtr);
            };

            return(_Result);
        }
Ejemplo n.º 10
0
        // recogdid.c (1005, 1)
        // recogSetChannelParams(recog, nlevels) as int
        // recogSetChannelParams(L_RECOG *, l_int32) as l_ok
        ///  <summary>
        /// (1) This converts the independent bit-flip probabilities in the
        /// "channel" into log-likelihood coefficients on image sums.
        /// These coefficients are only defined for the non-background
        /// template levels.  Thus for nlevels = 2 (one fg, one bg),
        /// only beta[1] and gamma[1] are used.  For nlevels = 4 (three
        /// fg templates), we use beta[1-3] and gamma[1-3].
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogSetChannelParams/*"/>
        ///  <param name="recog">[in] - </param>
        ///  <param name="nlevels">[in] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogSetChannelParams(
            L_Recog recog,
            int nlevels)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            int _Result = Natives.recogSetChannelParams(recog.Pointer, nlevels);

            return(_Result);
        }
Ejemplo n.º 11
0
        // recogident.c (583, 1)
        // recogCorrelationBestChar(recog, pixs, pbox, pscore, pindex, pcharstr, ppixdb) as int
        // recogCorrelationBestChar(L_RECOG *, PIX *, BOX **, l_float32 *, l_int32 *, char **, PIX **) as l_ok
        ///  <summary>
        /// (1) Basic matching character splitter.  Finds the best match among
        /// all templates to some region of the image.  This can result
        /// in splitting the image into two parts.  This is "image decoding"
        /// without dynamic programming, because we don't use a setwidth
        /// and compute the best matching score for the entire image.<para/>
        ///
        /// (2) Matching is to the average templates, without character scaling.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogCorrelationBestChar/*"/>
        ///  <param name="recog">[in] - with LUT's pre-computed</param>
        ///  <param name="pixs">[in] - can be of multiple touching characters, 1 bpp</param>
        ///  <param name="pbox">[out] - bounding box of best fit character</param>
        ///  <param name="pscore">[out] - correlation score</param>
        ///  <param name="pindex">[out][optional] - index of class</param>
        ///  <param name="pcharstr">[out][optional] - character string of class</param>
        ///  <param name="ppixdb">[out][optional] - debug pix showing input and best fit</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogCorrelationBestChar(
            L_Recog recog,
            Pix pixs,
            out Box pbox,
            out Single pscore,
            out int pindex,
            out String[] pcharstr,
            out Pix ppixdb)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr pboxPtr     = IntPtr.Zero;
            IntPtr pcharstrPtr = IntPtr.Zero;
            IntPtr ppixdbPtr   = IntPtr.Zero;
            int    _Result     = Natives.recogCorrelationBestChar(recog.Pointer, pixs.Pointer, out pboxPtr, out pscore, out pindex, out pcharstrPtr, out ppixdbPtr);

            if (pboxPtr == IntPtr.Zero)
            {
                pbox = null;
            }
            else
            {
                pbox = new Box(pboxPtr);
            };
            if (pcharstrPtr == null)
            {
                pcharstr = null;
            }
            else
            {
                pcharstr = null;
            };
            if (ppixdbPtr == IntPtr.Zero)
            {
                ppixdb = null;
            }
            else
            {
                ppixdb = new Pix(ppixdbPtr);
            };

            return(_Result);
        }
Ejemplo n.º 12
0
        // recogbasic.c (567, 1)
        // recogSetParams(recog, type, min_nopad, max_wh_ratio, max_ht_ratio) as int
        // recogSetParams(L_RECOG *, l_int32, l_int32, l_float32, l_float32) as l_ok
        ///  <summary>
        /// (1) This is called when a recog is created.<para/>
        ///
        /// (2) Default %min_nopad value allows for some padding.
        /// To disable padding, set %min_nopad = 0.  To pad only when
        /// no samples are available for the class, set %min_nopad = 1.<para/>
        ///
        /// (3) The %max_wh_ratio limits the width/height ratio for components
        /// that we attempt to split.  Splitting long components is expensive.<para/>
        ///
        /// (4) The %max_ht_ratio is a quality requirement on the training data.
        /// The recognizer will not run if the averages are computed and
        /// the templates do not satisfy it.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogSetParams/*"/>
        ///  <param name="recog">[in] - to be padded, if necessary</param>
        ///  <param name="type">[in] - type of char set -1 for default see enum in recog.h</param>
        ///  <param name="min_nopad">[in] - min number in a class without padding use -1 for default</param>
        ///  <param name="max_wh_ratio">[in] - max width/height ratio allowed for splitting use -1.0 for default</param>
        ///  <param name="max_ht_ratio">[in] - max of max/min averaged template height ratio use -1.0 for default</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogSetParams(
            L_Recog recog,
            int type,
            int min_nopad,
            Single max_wh_ratio,
            Single max_ht_ratio)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            int _Result = Natives.recogSetParams(recog.Pointer, type, min_nopad, max_wh_ratio, max_ht_ratio);

            return(_Result);
        }
Ejemplo n.º 13
0
        // recogbasic.c (1114, 1)
        // recogExtractPixa(recog) as Pixa
        // recogExtractPixa(L_RECOG *) as PIXA *
        ///  <summary>
        /// (1) This generates a pixa of all the unscaled images in the
        /// recognizer, where each one has its character class label in
        /// the pix text field, by flattening pixaa_u to a pixa.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogExtractPixa/*"/>
        ///  <param name="recog">[in] - </param>
        ///   <returns>pixa if OK, NULL on error</returns>
        public static Pixa recogExtractPixa(
            L_Recog recog)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            IntPtr _Result = Natives.recogExtractPixa(recog.Pointer);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pixa(_Result));
        }
Ejemplo n.º 14
0
        // recogident.c (1628, 1)
        // recogExtractNumbers(recog, boxas, scorethresh, spacethresh, pbaa, pnaa) as Sarray
        // recogExtractNumbers(L_RECOG *, BOXA *, l_float32, l_int32, BOXAA **, NUMAA **) as SARRAY *
        ///  <summary>
        /// (1) This extracts digit data after recogaIdentifyMultiple() or
        /// lower-level identification has taken place.<para/>
        ///
        /// (2) Each string in the returned sa contains a sequence of ascii
        /// digits in a number.<para/>
        ///
        /// (3) The horizontal distance between boxes (limited by %spacethresh)
        /// is the negative of the horizontal overlap.<para/>
        ///
        /// (4) Components with a score less than %scorethresh, which may
        /// be hyphens or other small characters, will signal the
        /// end of the current sequence of digits in the number.  A typical
        /// value for %scorethresh is 0.60.<para/>
        ///
        /// (5) We allow two digits to be combined if these conditions apply:
        /// (a) the first is to the left of the second
        /// (b) the second has a horizontal separation less than %spacethresh
        /// (c) the vertical overlap greater or equal 0 (vertical separation  is smaller 0)
        /// (d) both have a score that exceeds %scorethresh<para/>
        ///
        /// (6) Each numa in the optionally returned naa contains the digit
        /// scores of a number.  Each boxa in the optionally returned baa
        /// contains the bounding boxes of the digits in the number.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogExtractNumbers/*"/>
        ///  <param name="recog">[in] - </param>
        ///  <param name="boxas">[in] - location of components</param>
        ///  <param name="scorethresh">[in] - min score for which we accept a component</param>
        ///  <param name="spacethresh">[in] - max horizontal distance allowed between digits, use -1 for default</param>
        ///  <param name="pbaa">[out][optional] - bounding boxes of identified numbers</param>
        ///  <param name="pnaa">[out][optional] - scores of identified digits</param>
        ///   <returns>sa of identified numbers, or NULL on error</returns>
        public static Sarray recogExtractNumbers(
            L_Recog recog,
            Boxa boxas,
            Single scorethresh,
            int spacethresh,
            out Boxaa pbaa,
            out Numaa pnaa)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (boxas == null)
            {
                throw new ArgumentNullException("boxas cannot be Nothing");
            }

            IntPtr pbaaPtr = IntPtr.Zero;
            IntPtr pnaaPtr = IntPtr.Zero;
            IntPtr _Result = Natives.recogExtractNumbers(recog.Pointer, boxas.Pointer, scorethresh, spacethresh, out pbaaPtr, out pnaaPtr);

            if (pbaaPtr == IntPtr.Zero)
            {
                pbaa = null;
            }
            else
            {
                pbaa = new Boxaa(pbaaPtr);
            };
            if (pnaaPtr == IntPtr.Zero)
            {
                pnaa = null;
            }
            else
            {
                pnaa = new Numaa(pnaaPtr);
            };

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Sarray(_Result));
        }
Ejemplo n.º 15
0
        // recogdid.c (896, 1)
        // recogGetDid(recog) as L_Rdid
        // recogGetDid(L_RECOG *) as L_RDID *
        ///  <summary>
        /// (1) This also makes sure the arrays are defined.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogGetDid/*"/>
        ///  <param name="recog">[in] - </param>
        ///   <returns>did still owned by the recog, or NULL on error</returns>
        public static L_Rdid recogGetDid(
            L_Recog recog)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            IntPtr _Result = Natives.recogGetDid(recog.Pointer);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new L_Rdid(_Result));
        }
Ejemplo n.º 16
0
        // recogbasic.c (1019, 1)
        // recogWriteStream(fp, recog) as int
        // recogWriteStream(FILE *, L_RECOG *) as l_ok
        ///  <summary>
        /// recogWriteStream()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogWriteStream/*"/>
        ///  <param name="fp">[in] - file stream opened for "wb"</param>
        ///  <param name="recog">[in] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogWriteStream(
            FILE fp,
            L_Recog recog)
        {
            if (fp == null)
            {
                throw new ArgumentNullException("fp cannot be Nothing");
            }

            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            int _Result = Natives.recogWriteStream(fp.Pointer, recog.Pointer);

            return(_Result);
        }
Ejemplo n.º 17
0
        // recogbasic.c (988, 1)
        // recogWrite(filename, recog) as int
        // recogWrite(const char *, L_RECOG *) as l_ok
        ///  <summary>
        /// (1) The pixaa of templates that is written is the modified one
        /// in the pixaa field. It is the pixaa that is actually used
        /// for correlation. This is not the unscaled array of labeled
        /// bitmaps, in pixaa_u, that was used to generate the recog in the
        /// first place.  See the notes in recogRead() for the rationale.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogWrite/*"/>
        ///  <param name="filename">[in] - </param>
        ///  <param name="recog">[in] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogWrite(
            String filename,
            L_Recog recog)
        {
            if (filename == null)
            {
                throw new ArgumentNullException("filename cannot be Nothing");
            }

            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            int _Result = Natives.recogWrite(filename, recog.Pointer);

            return(_Result);
        }
Ejemplo n.º 18
0
        // recogdid.c (747, 1)
        // recogCreateDid(recog, pixs) as int
        // recogCreateDid(L_RECOG *, PIX *) as l_ok
        ///  <summary>
        /// recogCreateDid()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogCreateDid/*"/>
        ///  <param name="recog">[in] - </param>
        ///  <param name="pixs">[in] - of 1 bpp image to match</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogCreateDid(
            L_Recog recog,
            Pix pixs)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            int _Result = Natives.recogCreateDid(recog.Pointer, pixs.Pointer);

            return(_Result);
        }
Ejemplo n.º 19
0
        // recogbasic.c (476, 1)
        // recogDestroy(precog) as Object
        // recogDestroy(L_RECOG **) as void
        ///  <summary>
        /// recogDestroy()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogDestroy/*"/>
        ///  <param name="precog">[in,out] - will be set to null before returning</param>
        public static void recogDestroy(
            ref L_Recog precog)
        {
            IntPtr precogPtr = IntPtr.Zero;         if (precog != null)

            {
                precogPtr = precog.Pointer;
            }

            Natives.recogDestroy(ref precogPtr);
            if (precogPtr == IntPtr.Zero)
            {
                precog = null;
            }
            else
            {
                precog = new L_Recog(precogPtr);
            };
        }
Ejemplo n.º 20
0
        // recogbasic.c (695, 1)
        // recogStringToIndex(recog, text, pindex) as int
        // recogStringToIndex(L_RECOG *, char *, l_int32 *) as l_ok
        ///  <summary>
        /// recogStringToIndex()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogStringToIndex/*"/>
        ///  <param name="recog">[in] - </param>
        ///  <param name="text">[in] - text string for some class</param>
        ///  <param name="pindex">[out] - index for that class -1 if not found</param>
        ///   <returns>0 if OK, 1 on error not finding the string is an error</returns>
        public static int recogStringToIndex(
            L_Recog recog,
            String text,
            out int pindex)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (text == null)
            {
                throw new ArgumentNullException("text cannot be Nothing");
            }

            int _Result = Natives.recogStringToIndex(recog.Pointer, text, out pindex);

            return(_Result);
        }
Ejemplo n.º 21
0
        // recogtrain.c (352, 1)
        // recogAddSample(recog, pix, debug) as int
        // recogAddSample(L_RECOG *, PIX *, l_int32) as l_ok
        ///  <summary>
        /// (1) The pix is 1 bpp, with the character string label embedded.<para/>
        ///
        /// (2) The pixaa_u array of the recog is initialized to accept
        /// up to 256 different classes.  When training is finished,
        /// the arrays are truncated to the actual number of classes.
        /// To pad an existing recog from the boot recognizers, training
        /// is started again if samples from a new class are added,
        /// the pixaa_u array is extended by adding a pixa to hold them.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogAddSample/*"/>
        ///  <param name="recog">[in] - </param>
        ///  <param name="pix">[in] - a single character, 1 bpp</param>
        ///  <param name="debug">[in] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogAddSample(
            L_Recog recog,
            Pix pix,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pix == null)
            {
                throw new ArgumentNullException("pix cannot be Nothing");
            }

            int _Result = Natives.recogAddSample(recog.Pointer, pix.Pointer, (int)debug);

            return(_Result);
        }
Ejemplo n.º 22
0
        // recogident.c (246, 1)
        // recogSplitIntoCharacters(recog, pixs, minh, skipsplit, pboxa, ppixa, debug) as int
        // recogSplitIntoCharacters(L_RECOG *, PIX *, l_int32, l_int32, BOXA **, PIXA **, l_int32) as l_ok
        ///  <summary>
        /// (1) This can be given an image that has an arbitrary number
        /// of text characters.  It optionally splits connected
        /// components based on document image decoding in recogDecode().
        /// The returned pixa includes the boxes from which the
        /// (possibly split) components are extracted.<para/>
        ///
        /// (2) After noise filtering, the resulting components are put in
        /// row-major (2D) order, and the smaller of overlapping
        /// components are removed if they satisfy conditions of
        /// relative size and fractional overlap.<para/>
        ///
        /// (3) Note that the splitting function uses unscaled templates
        /// and does not bother returning the class results and scores.
        /// These are more accurately found later using the scaled templates.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogSplitIntoCharacters/*"/>
        ///  <param name="recog">[in] - </param>
        ///  <param name="pixs">[in] - 1 bpp, contains only mostly deskewed text</param>
        ///  <param name="minh">[in] - remove shorter components use 0 for default</param>
        ///  <param name="skipsplit">[in] - 1 to skip the splitting step</param>
        ///  <param name="pboxa">[out] - character bounding boxes</param>
        ///  <param name="ppixa">[out] - character images</param>
        ///  <param name="debug">[in] - 1 for results written to pixadb_split</param>
        ///   <returns>0 if OK, 1 on error or if no components are returned</returns>
        public static int recogSplitIntoCharacters(
            L_Recog recog,
            Pix pixs,
            int minh,
            int skipsplit,
            out Boxa pboxa,
            out Pixa ppixa,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr pboxaPtr = IntPtr.Zero;
            IntPtr ppixaPtr = IntPtr.Zero;
            int    _Result  = Natives.recogSplitIntoCharacters(recog.Pointer, pixs.Pointer, minh, skipsplit, out pboxaPtr, out ppixaPtr, (int)debug);

            if (pboxaPtr == IntPtr.Zero)
            {
                pboxa = null;
            }
            else
            {
                pboxa = new Boxa(pboxaPtr);
            };
            if (ppixaPtr == IntPtr.Zero)
            {
                ppixa = null;
            }
            else
            {
                ppixa = new Pixa(ppixaPtr);
            };

            return(_Result);
        }
Ejemplo n.º 23
0
        // recogtrain.c (1962, 1)
        // recogShowContent(fp, recog, index, display) as int
        // recogShowContent(FILE *, L_RECOG *, l_int32, l_int32) as l_ok
        ///  <summary>
        /// recogShowContent()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogShowContent/*"/>
        ///  <param name="fp">[in] - file  stream</param>
        ///  <param name="recog">[in] - </param>
        ///  <param name="index">[in] - for naming of output files of template images</param>
        ///  <param name="display">[in] - 1 for showing template images, 0 otherwise</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogShowContent(
            FILE fp,
            L_Recog recog,
            int index,
            int display)
        {
            if (fp == null)
            {
                throw new ArgumentNullException("fp cannot be Nothing");
            }

            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            int _Result = Natives.recogShowContent(fp.Pointer, recog.Pointer, index, display);

            return(_Result);
        }
Ejemplo n.º 24
0
        // recogtrain.c (2311, 1)
        // recogShowMatchesInRange(recog, pixa, minscore, maxscore, display) as int
        // recogShowMatchesInRange(L_RECOG *, PIXA *, l_float32, l_float32, l_int32) as l_ok
        ///  <summary>
        /// (1) This gives a visual output of the best matches for a given
        /// range of scores.  Each pair of images can optionally be
        /// labeled with the index of the best match and the correlation.<para/>
        ///
        /// (2) To use this, save a set of 1 bpp images (labeled or
        /// unlabeled) that can be given to a recognizer in a pixa.
        /// Then call this function with the pixa and parameters
        /// to filter a range of scores.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogShowMatchesInRange/*"/>
        ///  <param name="recog">[in] - </param>
        ///  <param name="pixa">[in] - of 1 bpp images to match</param>
        ///  <param name="minscore">[in] - range to include output</param>
        ///  <param name="maxscore">[in] - range to include output</param>
        ///  <param name="display">[in] - to display the result</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogShowMatchesInRange(
            L_Recog recog,
            Pixa pixa,
            Single minscore,
            Single maxscore,
            int display)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixa == null)
            {
                throw new ArgumentNullException("pixa cannot be Nothing");
            }

            int _Result = Natives.recogShowMatchesInRange(recog.Pointer, pixa.Pointer, minscore, maxscore, display);

            return(_Result);
        }
Ejemplo n.º 25
0
        // recogtrain.c (486, 1)
        // recogAverageSamples(precog, debug) as int
        // recogAverageSamples(L_RECOG **, l_int32) as l_int32
        ///  <summary>
        /// (1) This is only called in two situations:
        /// (a) When splitting characters using either the DID method
        /// recogDecode() or the the greedy splitter
        /// recogCorrelationBestRow()
        /// (b) By a special recognizer that is used to remove outliers.
        /// Both unscaled and scaled inputs are averaged.<para/>
        ///
        /// (2) If the data in any class is nonexistent (no samples), or
        /// very bad (no fg pixels in the average), or if the ratio
        /// of max/min average unscaled class template heights is
        /// greater than max_ht_ratio, this destroys the recog.
        /// The caller must check the return value of the recog.<para/>
        ///
        /// (3) Set debug = 1 to view the resulting templates and their centroids.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogAverageSamples/*"/>
        ///  <param name="precog">[in] - addr of existing recog may be destroyed</param>
        ///  <param name="debug">[in] - </param>
        ///   <returns>0 on success, 1 on failure</returns>
        public static int recogAverageSamples(
            ref L_Recog precog,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            IntPtr precogPtr = IntPtr.Zero;         if (precog != null)
            {
                precogPtr = precog.Pointer;
            }
            int _Result = Natives.recogAverageSamples(ref precogPtr, (int)debug);

            if (precogPtr == IntPtr.Zero)
            {
                precog = null;
            }
            else
            {
                precog = new L_Recog(precogPtr);
            };

            return(_Result);
        }
Ejemplo n.º 26
0
        // recogbasic.c (232, 1)
        // recogCreateFromRecog(recs, scalew, scaleh, linew, threshold, maxyshift) as L_Recog
        // recogCreateFromRecog(L_RECOG *, l_int32, l_int32, l_int32, l_int32, l_int32) as L_RECOG *
        ///  <summary>
        /// (1) This is a convenience function that generates a recog using
        /// the unscaled training data in an existing recog.<para/>
        ///
        /// (2) It is recommended to use %maxyshift = 1 (the default value)<para/>
        ///
        /// (3) See recogCreate() for use of %scalew, %scaleh and %linew.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogCreateFromRecog/*"/>
        ///  <param name="recs">[in] - source recog with arbitrary input parameters</param>
        ///  <param name="scalew">[in] - scale all widths to this use 0 otherwise</param>
        ///  <param name="scaleh">[in] - scale all heights to this use 0 otherwise</param>
        ///  <param name="linew">[in] - width of normalized strokes use 0 to skip</param>
        ///  <param name="threshold">[in] - for binarization typically ~128</param>
        ///  <param name="maxyshift">[in] - from nominal centroid alignment default is 1</param>
        ///   <returns>recd, or NULL on error</returns>
        public static L_Recog recogCreateFromRecog(
            L_Recog recs,
            int scalew,
            int scaleh,
            int linew,
            int threshold,
            int maxyshift)
        {
            if (recs == null)
            {
                throw new ArgumentNullException("recs cannot be Nothing");
            }

            IntPtr _Result = Natives.recogCreateFromRecog(recs.Pointer, scalew, scaleh, linew, threshold, maxyshift);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new L_Recog(_Result));
        }
Ejemplo n.º 27
0
        // recogtrain.c (1592, 1)
        // recogPadDigitTrainingSet(precog, scaleh, linew) as int
        // recogPadDigitTrainingSet(L_RECOG **, l_int32, l_int32) as l_ok
        ///  <summary>
        /// (1) This is a no-op if padding is not needed.  However,
        /// if it is, this replaces the input recog with a new recog,
        /// padded appropriately with templates from a boot recognizer,
        /// and set up with correlation templates derived from
        /// %scaleh and %linew.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogPadDigitTrainingSet/*"/>
        ///  <param name="precog">[in,out] - trained if padding is needed, it is replaced by a a new padded recog</param>
        ///  <param name="scaleh">[in] - must be  is greater  0 suggest ~40.</param>
        ///  <param name="linew">[in] - use 0 for original scanned images</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogPadDigitTrainingSet(
            ref L_Recog precog,
            int scaleh,
            int linew)
        {
            IntPtr precogPtr = IntPtr.Zero;         if (precog != null)
            {
                precogPtr = precog.Pointer;
            }
            int _Result = Natives.recogPadDigitTrainingSet(ref precogPtr, scaleh, linew);

            if (precogPtr == IntPtr.Zero)
            {
                precog = null;
            }
            else
            {
                precog = new L_Recog(precogPtr);
            };

            return(_Result);
        }
Ejemplo n.º 28
0
        // recogtrain.c (783, 1)
        // recogTrainingFinished(precog, modifyflag, minsize, minfract) as int
        // recogTrainingFinished(L_RECOG **, l_int32, l_int32, l_float32) as l_ok
        ///  <summary>
        /// (1) This must be called after all training samples have been added.<para/>
        ///
        /// (2) If the templates are not good enough, the recog input is destroyed.<para/>
        ///
        /// (3) Usually, %modifyflag == 1, because we want to apply
        /// recogModifyTemplate() to generate the actual templates
        /// that will be used.  The one exception is when reading a
        /// serialized recog: there we want to put the same set of
        /// templates in both the unscaled and modified pixaa.
        /// See recogReadStream() to see why we do this.<para/>
        ///
        /// (4) See recogTemplatesAreOK() for %minsize and %minfract usage.<para/>
        ///
        /// (5) The following things are done here:
        /// (a) Allocate (or reallocate) storage for (possibly) modified
        /// bitmaps, centroids, and fg areas.
        /// (b) Generate the (possibly) modified bitmaps.
        /// (c) Compute centroid and fg area data for both unscaled and
        /// modified bitmaps.
        /// (d) Truncate the pixaa, ptaa and numaa arrays down from
        /// 256 to the actual size.<para/>
        ///
        /// (6) Putting these operations here makes it simple to recompute
        /// the recog with different modifications on the bitmaps.<para/>
        ///
        /// (7) Call recogShowContent() to display the templates, both
        /// unscaled and modified.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogTrainingFinished/*"/>
        ///  <param name="precog">[in] - addr of recog</param>
        ///  <param name="modifyflag">[in] - 1 to use recogModifyTemplate() 0 otherwise</param>
        ///  <param name="minsize">[in] - set to -1 for default</param>
        ///  <param name="minfract">[in] - set to -1.0 for default</param>
        ///   <returns>0 if OK, 1 on error (input recog will be destroyed)</returns>
        public static int recogTrainingFinished(
            ref L_Recog precog,
            int modifyflag,
            int minsize,
            Single minfract)
        {
            IntPtr precogPtr = IntPtr.Zero;         if (precog != null)
            {
                precogPtr = precog.Pointer;
            }
            int _Result = Natives.recogTrainingFinished(ref precogPtr, modifyflag, minsize, minfract);

            if (precogPtr == IntPtr.Zero)
            {
                precog = null;
            }
            else
            {
                precog = new L_Recog(precogPtr);
            };

            return(_Result);
        }
Ejemplo n.º 29
0
        // recogtrain.c (1768, 1)
        // recogAddDigitPadTemplates(recog, sa) as Pixa
        // recogAddDigitPadTemplates(L_RECOG *, SARRAY *) as PIXA *
        ///  <summary>
        /// (1) Call recogIsPaddingNeeded() first, which returns %sa of
        /// template text strings for classes where more templates
        /// are needed.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogAddDigitPadTemplates/*"/>
        ///  <param name="recog">[in] - trained</param>
        ///  <param name="sa">[in] - set of text strings that need to be padded</param>
        ///   <returns>pixa   of all templates from %recog and the additional pad templates from a boot recognizer or NULL on error</returns>
        public static Pixa recogAddDigitPadTemplates(
            L_Recog recog,
            Sarray sa)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (sa == null)
            {
                throw new ArgumentNullException("sa cannot be Nothing");
            }

            IntPtr _Result = Natives.recogAddDigitPadTemplates(recog.Pointer, sa.Pointer);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pixa(_Result));
        }
Ejemplo n.º 30
0
        // recogtrain.c (1650, 1)
        // recogIsPaddingNeeded(recog, psa) as int
        // recogIsPaddingNeeded(L_RECOG *, SARRAY **) as l_int32
        ///  <summary>
        /// (1) This returns a string array in [and]sa containing character values
        /// for which extra templates are needed this sarray is
        /// used by recogGetPadTemplates().  It returns NULL
        /// if no padding templates are needed.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogIsPaddingNeeded/*"/>
        ///  <param name="recog">[in] - trained</param>
        ///  <param name="psa">[out] - addr of returned string containing text value</param>
        ///   <returns>1 on error 0 if OK, whether or not additional padding templates are required.</returns>
        public static int recogIsPaddingNeeded(
            L_Recog recog,
            out Sarray psa)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            IntPtr psaPtr  = IntPtr.Zero;
            int    _Result = Natives.recogIsPaddingNeeded(recog.Pointer, out psaPtr);

            if (psaPtr == IntPtr.Zero)
            {
                psa = null;
            }
            else
            {
                psa = new Sarray(psaPtr);
            };

            return(_Result);
        }