Example #1
0
        // gplot.c (779, 1)
        // gplotSimpleXYN(nax, naay, plotstyle, outformat, outroot, title) as int
        // gplotSimpleXYN(NUMA *, NUMAA *, l_int32, l_int32, const char *, const char *) as l_ok
        ///  <summary>
        /// (1) This gives plots of each Numa in %naa against nax,
        /// generated in the specified output format.  The title is optional.<para/>
        ///
        /// (2) Use 0 for default plotstyle (lines).<para/>
        ///
        /// (3) %nax is optional.  If NULL, each Numa array is plotted against
        /// the array index.<para/>
        ///
        /// (4) When calling these simple plot functions more than once, use
        /// different %outroot to avoid overwriting the output files.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/gplotSimpleXYN/*"/>
        ///  <param name="nax">[in][optional] - can be NULL</param>
        ///  <param name="naay">[in] - numaa of arrays to plot against %nax</param>
        ///  <param name="plotstyle">[in] - GPLOT_LINES, GPLOT_POINTS, GPLOT_IMPULSES, GPLOT_LINESPOINTS, GPLOT_DOTS</param>
        ///  <param name="outformat">[in] - GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_LATEX</param>
        ///  <param name="outroot">[in] - root of output files</param>
        ///  <param name="title">[in][optional] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int gplotSimpleXYN(
            Numa nax,
            Numaa naay,
            int plotstyle,
            int outformat,
            String outroot,
            String title = "")
        {
            if (naay == null)
            {
                throw new ArgumentNullException("naay cannot be Nothing");
            }

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

            IntPtr naxPtr = IntPtr.Zero;    if (nax != null)
            {
                naxPtr = nax.Pointer;
            }
            int _Result = Natives.gplotSimpleXYN(naxPtr, naay.Pointer, plotstyle, outformat, outroot, title);

            return(_Result);
        }
Example #2
0
        // classapp.c (603, 1)
        // numaaCompareImagesByBoxes(naa1, naa2, nperline, nreq, maxshiftx, maxshifty, delx, dely, psame, debugflag) as int
        // numaaCompareImagesByBoxes(NUMAA *, NUMAA *, l_int32, l_int32, l_int32, l_int32, l_int32, l_int32, l_int32 *, l_int32) as l_ok
        ///  <summary>
        /// (1) Each input numaa describes a set of sorted bounding boxes
        /// (sorted by textline and, within each textline, from
        /// left to right) in the images from which they are derived.
        /// See boxaExtractSortedPattern() for a description of the data
        /// format in each of the input numaa.<para/>
        ///
        /// (2) This function does an alignment between the input
        /// descriptions of bounding boxes for two images. The
        /// input parameter %nperline specifies the number of boxes
        /// to consider in each line when testing for a match, and
        /// %nreq is the required number of lines that must be well-aligned
        /// to get a match.<para/>
        ///
        /// (3) Testing by alignment has 3 steps:
        /// (a) Generating the location of word bounding boxes from the
        /// images (prior to calling this function).
        /// (b) Listing all possible pairs of aligned rows, based on
        /// tolerances in horizontal and vertical positions of
        /// the boxes.  Specifically, all pairs of rows are enumerated
        /// whose first %nperline boxes can be brought into close
        /// alignment, based on the delx parameter for boxes in the
        /// line and within the overall the %maxshiftx and %maxshifty
        /// constraints.
        /// (c) Each pair, starting with the first, is used to search
        /// for a set of %nreq - 1 other pairs that can all be aligned
        /// with a difference in global translation of not more
        /// than (%delx, %dely).
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/numaaCompareImagesByBoxes/*"/>
        ///  <param name="naa1">[in] - for image 1, formatted by boxaExtractSortedPattern()</param>
        ///  <param name="naa2">[in] - ditto for image 2</param>
        ///  <param name="nperline">[in] - number of box regions to be used in each textline</param>
        ///  <param name="nreq">[in] - number of complete row matches required</param>
        ///  <param name="maxshiftx">[in] - max allowed x shift between two patterns, in pixels</param>
        ///  <param name="maxshifty">[in] - max allowed y shift between two patterns, in pixels</param>
        ///  <param name="delx">[in] - max allowed difference in x data, after alignment</param>
        ///  <param name="dely">[in] - max allowed difference in y data, after alignment</param>
        ///  <param name="psame">[out] - 1 if %nreq row matches are found 0 otherwise</param>
        ///  <param name="debugflag">[in] - 1 for debug output</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int numaaCompareImagesByBoxes(
            Numaa naa1,
            Numaa naa2,
            int nperline,
            int nreq,
            int maxshiftx,
            int maxshifty,
            int delx,
            int dely,
            out int psame,
            int debugflag)
        {
            if (naa1 == null)
            {
                throw new ArgumentNullException("naa1 cannot be Nothing");
            }

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

            int _Result = Natives.numaaCompareImagesByBoxes(naa1.Pointer, naa2.Pointer, nperline, nreq, maxshiftx, maxshifty, delx, dely, out psame, debugflag);

            return(_Result);
        }
Example #3
0
        // boxfunc2.c (837, 1)
        // boxaSort2d(boxas, pnaad, delta1, delta2, minh1) as Boxaa
        // boxaSort2d(BOXA *, NUMAA **, l_int32, l_int32, l_int32) as BOXAA *
        ///  <summary>
        /// (1) The final result is a sort where the 'fast scan' direction is
        /// left to right, and the 'slow scan' direction is from top
        /// to bottom.  Each boxa in the baa represents a sorted set
        /// of boxes from left to right.<para/>
        ///
        /// (2) Three passes are used to aggregate the boxas, which can correspond
        /// to characters or words in a line of text.  In pass 1, only
        /// taller components, which correspond to xheight or larger,
        /// are permitted to start a new boxa.  In pass 2, the remaining
        /// vertically-challenged components are allowed to join an
        /// existing boxa or start a new one.  In pass 3, boxa whose extent
        /// is overlapping are joined.  After that, the boxes in each
        /// boxa are sorted horizontally, and finally the boxa are
        /// sorted vertically.<para/>
        ///
        /// (3) If delta1  is smaller 0, the first pass allows aggregation when
        /// boxes in the same boxa do not overlap vertically.
        /// The distance by which they can miss and still be aggregated
        /// is the absolute value |delta1|. Similar for delta2 on
        /// the second pass.<para/>
        ///
        /// (4) On the first pass, any component of height less than minh1
        /// cannot start a new boxa it's put aside for later insertion.<para/>
        ///
        /// (5) On the second pass, any small component that doesn't align
        /// with an existing boxa can start a new one.<para/>
        ///
        /// (6) This can be used to identify lines of text from
        /// character or word bounding boxes.<para/>
        ///
        /// (7) Typical values for the input parameters on 300 ppi text are:
        /// delta1 ~ 0
        /// delta2 ~ 0
        /// minh1 ~ 5
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/boxaSort2d/*"/>
        ///  <param name="boxas">[in] - </param>
        ///  <param name="pnaad">[out][optional] - numaa with sorted indices whose values are the indices of the input array</param>
        ///  <param name="delta1">[in] - min overlap that permits aggregation of a box onto a boxa of horizontally-aligned boxes pass 1</param>
        ///  <param name="delta2">[in] - min overlap that permits aggregation of a box onto a boxa of horizontally-aligned boxes pass 2</param>
        ///  <param name="minh1">[in] - components less than this height either join an existing boxa or are set aside for pass 2</param>
        ///   <returns>baa 2d sorted version of boxa, or NULL on error</returns>
        public static Boxaa boxaSort2d(
            Boxa boxas,
            out Numaa pnaad,
            int delta1,
            int delta2,
            int minh1)
        {
            if (boxas == null)
            {
                throw new ArgumentNullException("boxas cannot be Nothing");
            }

            IntPtr pnaadPtr = IntPtr.Zero;
            IntPtr _Result  = Natives.boxaSort2d(boxas.Pointer, out pnaadPtr, delta1, delta2, minh1);

            if (pnaadPtr == IntPtr.Zero)
            {
                pnaad = null;
            }
            else
            {
                pnaad = new Numaa(pnaadPtr);
            };

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

            return(new Boxaa(_Result));
        }
Example #4
0
        // recogident.c (1761, 1)
        // showExtractNumbers(pixs, sa, baa, naa, ppixdb) as Pixa
        // showExtractNumbers(PIX *, SARRAY *, BOXAA *, NUMAA *, PIX **) as PIXA *
        ///  <summary>
        /// (1) This is a debugging routine on digit identification e.g.:
        /// recogIdentifyMultiple(recog, pixs, 0, 1, [and]boxa, NULL, NULL, 0)
        /// sa = recogExtractNumbers(recog, boxa, 0.8, -1, [and]baa, [and]naa)
        /// pixa = showExtractNumbers(pixs, sa, baa, naa, NULL)
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/showExtractNumbers/*"/>
        ///  <param name="pixs">[in] - input 1 bpp image</param>
        ///  <param name="sa">[in] - recognized text strings</param>
        ///  <param name="baa">[in] - boxa array for location of characters in each string</param>
        ///  <param name="naa">[in] - numa array for scores of characters in each string</param>
        ///  <param name="ppixdb">[out][optional] - input pixs with identified chars outlined</param>
        ///   <returns>pixa   of identified strings with text and scores, or NULL on error</returns>
        public static Pixa showExtractNumbers(
            Pix pixs,
            Sarray sa,
            Boxaa baa,
            Numaa naa,
            out Pix ppixdb)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

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

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

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

            IntPtr ppixdbPtr = IntPtr.Zero;
            IntPtr _Result   = Natives.showExtractNumbers(pixs.Pointer, sa.Pointer, baa.Pointer, naa.Pointer, out ppixdbPtr);

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

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

            return(new Pixa(_Result));
        }
Example #5
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));
        }
Example #6
0
        // gplot.c (635, 1)
        // gplotSimpleN(naa, outformat, outroot, title) as int
        // gplotSimpleN(NUMAA *, l_int32, const char *, const char *) as l_ok
        ///  <summary>
        /// (1) This gives a line plot of all numas in a numaa (array of numa),
        /// where the array values are each plotted vs the array index.
        /// The plot is generated in the specified output format
        /// the title  is optional.<para/>
        ///
        /// (2) When calling these simple plot functions more than once, use
        /// different %outroot to avoid overwriting the output files.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/gplotSimpleN/*"/>
        ///  <param name="naa">[in] - numaa we plotted with Y_VS_I for each numa</param>
        ///  <param name="outformat">[in] - GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_LATEX</param>
        ///  <param name="outroot">[in] - root of output files</param>
        ///  <param name="title">[in][optional] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int gplotSimpleN(
            Numaa naa,
            int outformat,
            String outroot,
            String title = "")
        {
            if (naa == null)
            {
                throw new ArgumentNullException("naa cannot be Nothing");
            }

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

            int _Result = Natives.gplotSimpleN(naa.Pointer, outformat, outroot, title);

            return(_Result);
        }
Example #7
0
        // boxfunc2.c (1024, 1)
        // boxaSort2dByIndex(boxas, naa) as Boxaa
        // boxaSort2dByIndex(BOXA *, NUMAA *) as BOXAA *
        ///  <summary>
        /// boxaSort2dByIndex()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/boxaSort2dByIndex/*"/>
        ///  <param name="boxas">[in] - </param>
        ///  <param name="naa">[in] - numaa that maps from the new baa to the input boxa</param>
        ///   <returns>baa sorted boxaa, or NULL on error</returns>
        public static Boxaa boxaSort2dByIndex(
            Boxa boxas,
            Numaa naa)
        {
            if (boxas == null)
            {
                throw new ArgumentNullException("boxas cannot be Nothing");
            }

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

            IntPtr _Result = Natives.boxaSort2dByIndex(boxas.Pointer, naa.Pointer);

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

            return(new Boxaa(_Result));
        }