Esempio n. 1
0
        // dewarp4.c (1094, 1)
        // dewarpShowResults(dewa, sa, boxa, firstpage, lastpage, pdfout) as int
        // dewarpShowResults(L_DEWARPA *, SARRAY *, BOXA *, l_int32, l_int32, const char *) as l_ok
        ///  <summary>
        /// (1) This generates a pdf of image pairs (before, after) for
        /// the designated set of input pages.<para/>
        ///
        /// (2) If the boxa exists, its elements are aligned with numbers
        /// in the filenames in %sa.  It is used to crop the input images.
        /// It is assumed that the dewa was generated from the cropped
        /// images.  No undercropping is applied before rendering.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpShowResults/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="sa">[in] - of indexed input images</param>
        ///  <param name="boxa">[in] - crop boxes for input images can be null</param>
        ///  <param name="firstpage">[in] - </param>
        ///  <param name="lastpage">[in] - </param>
        ///  <param name="pdfout">[in] - filename</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpShowResults(
            L_Dewarpa dewa,
            Sarray sa,
            Boxa boxa,
            int firstpage,
            int lastpage,
            String pdfout)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

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

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

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

            int _Result = Natives.dewarpShowResults(dewa.Pointer, sa.Pointer, boxa.Pointer, firstpage, lastpage, pdfout);

            return(_Result);
        }
Esempio n. 2
0
        // dewarp3.c (114, 1)
        // dewarpaApplyDisparity(dewa, pageno, pixs, grayin, x, y, ppixd, debugfile) as int
        // dewarpaApplyDisparity(L_DEWARPA *, l_int32, PIX *, l_int32, l_int32, l_int32, PIX **, const char *) as l_ok
        ///  <summary>
        /// (1) This applies the disparity arrays to the specified image.<para/>
        ///
        /// (2) Specify gray color for pixels brought in from the outside:
        /// 0 is black, 255 is white.  Use -1 to select pixels from the
        /// boundary of the source image.<para/>
        ///
        /// (3) If the models and ref models have not been validated, this
        /// will do so by calling dewarpaInsertRefModels().<para/>
        ///
        /// (4) This works with both stripped and full resolution page models.
        /// If the full res disparity array(s) are missing, they are remade.<para/>
        ///
        /// (5) The caller must handle errors that are returned because there
        /// are no valid models or ref models for the page -- typically
        /// by using the input pixs.<para/>
        ///
        /// (6) If there is no model for %pageno, this will use the model for
        /// 'refpage' and put the result in the dew for %pageno.<para/>
        ///
        /// (7) This populates the full resolution disparity arrays if
        /// necessary.  If x and/or y are positive, they are used,
        /// in conjunction with pixs, to determine the required
        /// slope-based extension of the full resolution disparity
        /// arrays in each direction.  When (x,y) == (0,0), all
        /// extension is to the right and down.  Nonzero values of (x,y)
        /// are useful for dewarping when pixs is deliberately undercropped.<para/>
        ///
        /// (8) Important: when applying disparity to a number of images,
        /// after calling this function and saving the resulting pixd,
        /// you should call dewarpMinimize(dew) on the dew for %pageno.
        /// This will remove pixs and pixd (or their clones) stored in dew,
        /// as well as the full resolution disparity arrays.  Together,
        /// these hold approximately 16 bytes for each pixel in pixs.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaApplyDisparity/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="pageno">[in] - of page model to be used may be a ref model</param>
        ///  <param name="pixs">[in] - image to be modified can be 1, 8 or 32 bpp</param>
        ///  <param name="grayin">[in] - gray value, from 0 to 255, for pixels brought in use -1 to use pixels on the boundary of pixs</param>
        ///  <param name="x">[in] - origin for generation of disparity arrays</param>
        ///  <param name="y">[in] - origin for generation of disparity arrays</param>
        ///  <param name="ppixd">[out] - disparity corrected image</param>
        ///  <param name="debugfile">[in]use NULL to skip - writing this</param>
        ///   <returns>0 if OK, 1 on error no models or ref models available</returns>
        public static int dewarpaApplyDisparity(
            L_Dewarpa dewa,
            int pageno,
            Pix pixs,
            int grayin,
            int x,
            int y,
            out Pix ppixd,
            String debugfile = "")
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

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

            IntPtr ppixdPtr = IntPtr.Zero;
            int    _Result  = Natives.dewarpaApplyDisparity(dewa.Pointer, pageno, pixs.Pointer, grayin, x, y, out ppixdPtr, debugfile);

            if (ppixdPtr == IntPtr.Zero)
            {
                ppixd = null;
            }
            else
            {
                ppixd = new Pix(ppixdPtr);
            };

            return(_Result);
        }
Esempio n. 3
0
        public static int dewarpaSetMaxDistance(this L_Dewarpa dewa, int maxdist)
        {
            if (null == dewa)
            {
                throw new ArgumentNullException("dewa cannot be null.");
            }

            return(Native.DllImports.dewarpaSetMaxDistance((HandleRef)dewa, maxdist));
        }
Esempio n. 4
0
        public static int dewarpaSetCheckColumns(this L_Dewarpa dewa, int check_columns)
        {
            if (null == dewa)
            {
                throw new ArgumentNullException("dewa cannot be null.");
            }

            return(Native.DllImports.dewarpaSetCheckColumns((HandleRef)dewa, check_columns));
        }
Esempio n. 5
0
        public static int dewarpaUseBothArrays(this L_Dewarpa dewa, int useboth)
        {
            if (null == dewa)
            {
                throw new ArgumentNullException("dewa cannot be null.");
            }

            return(Native.DllImports.dewarpaUseBothArrays((HandleRef)dewa, useboth));
        }
Esempio n. 6
0
        // Setting parameters to control rendering from the model
        public static int dewarpaSetCurvatures(this L_Dewarpa dewa, int max_linecurv, int min_diff_linecurv, int max_diff_linecurv, int max_edgecurv, int max_diff_edgecurv, int max_edgeslope)
        {
            if (null == dewa)
            {
                throw new ArgumentNullException("dewa cannot be null.");
            }

            return(Native.DllImports.dewarpaSetCurvatures((HandleRef)dewa, max_linecurv, min_diff_linecurv, max_diff_linecurv, max_edgecurv, max_diff_edgecurv, max_edgeslope));
        }
Esempio n. 7
0
        public static int dewarpaWriteMem(out IntPtr pdata, IntPtr psize, L_Dewarpa dewa)
        {
            if (IntPtr.Zero == psize ||
                null == dewa)
            {
                throw new ArgumentNullException("psize, dewa cannot be null.");
            }

            return(Native.DllImports.dewarpaWriteMem(out pdata, psize, (HandleRef)dewa));
        }
Esempio n. 8
0
        public static int dewarpaWriteStream(IntPtr fp, L_Dewarpa dewa)
        {
            if (IntPtr.Zero == fp ||
                null == dewa)
            {
                throw new ArgumentNullException("fp, dewa cannot be null.");
            }

            return(Native.DllImports.dewarpaWriteStream(fp, (HandleRef)dewa));
        }
Esempio n. 9
0
        public static int dewarpaWrite(string filename, L_Dewarpa dewa)
        {
            if (null == dewa ||
                string.IsNullOrWhiteSpace(filename))
            {
                throw new ArgumentNullException("filename, dewa cannot be null.");
            }

            return(Native.DllImports.dewarpaWrite(filename, (HandleRef)dewa));
        }
Esempio n. 10
0
        public static int dewarpaDestroyDewarp(this L_Dewarpa dewa, int pageno)
        {
            if (null == dewa)
            {
                throw new ArgumentNullException("dewa cannot be null");
            }

            var pointer = (IntPtr)dewa;

            return(Native.DllImports.dewarpaDestroyDewarp(ref pointer, pageno));
        }
Esempio n. 11
0
        public static void dewarpaDestroy(this L_Dewarpa pdewa)
        {
            if (null == pdewa)
            {
                throw new ArgumentNullException("pdewa cannot be null");
            }

            var pointer = (IntPtr)pdewa;

            Native.DllImports.dewarpaDestroy(ref pointer);
        }
Esempio n. 12
0
        // Dewarpa insertion/extraction
        public static int dewarpaInsertDewarp(this L_Dewarpa dewa, L_Dewarp dew)
        {
            if (null == dewa ||
                null == dew)
            {
                throw new ArgumentNullException("dewa, dew cannot be null");
            }

            var pointer = (IntPtr)dewa;

            return(Native.DllImports.dewarpaInsertDewarp((HandleRef)dewa, (HandleRef)dew));
        }
Esempio n. 13
0
        // dewarp4.c (619, 1)
        // dewarpaRestoreModels(dewa) as int
        // dewarpaRestoreModels(L_DEWARPA *) as l_ok
        ///  <summary>
        /// (1) This puts all real models (and only real models) in the
        /// primary dewarpa array.  First remove all dewarps that are
        /// only references to other page models.  Then move all models
        /// that had been cached back into the primary dewarp array.<para/>
        ///
        /// (2) After this is done, we still need to recompute and insert
        /// the reference models before dewatomodelsready is true.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaRestoreModels/*"/>
        ///  <param name="dewa">[in] - populated with dewarp structs for pages</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaRestoreModels(
            L_Dewarpa dewa)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            int _Result = Natives.dewarpaRestoreModels(dewa.Pointer);

            return(_Result);
        }
Esempio n. 14
0
        // dewarp1.c (1030, 1)
        // dewarpaUseBothArrays(dewa, useboth) as int
        // dewarpaUseBothArrays(L_DEWARPA *, l_int32) as l_ok
        ///  <summary>
        /// (1) This sets the useboth field.  If set, this will attempt
        /// to apply both vertical and horizontal disparity arrays.
        /// Note that a model with only a vertical disparity array will
        /// always be valid.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaUseBothArrays/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="useboth">[in] - 0 for false, 1 for true</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaUseBothArrays(
            L_Dewarpa dewa,
            int useboth)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            int _Result = Natives.dewarpaUseBothArrays(dewa.Pointer, useboth);

            return(_Result);
        }
Esempio n. 15
0
        // dewarp1.c (762, 1)
        // dewarpaDestroyDewarp(dewa, pageno) as int
        // dewarpaDestroyDewarp(L_DEWARPA *, l_int32) as l_ok
        ///  <summary>
        /// dewarpaDestroyDewarp()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaDestroyDewarp/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="pageno">[in] - of dew to be destroyed</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaDestroyDewarp(
            L_Dewarpa dewa,
            int pageno)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            int _Result = Natives.dewarpaDestroyDewarp(dewa.Pointer, pageno);

            return(_Result);
        }
Esempio n. 16
0
        // dewarp1.c (1095, 1)
        // dewarpaSetMaxDistance(dewa, maxdist) as int
        // dewarpaSetMaxDistance(L_DEWARPA *, l_int32) as l_ok
        ///  <summary>
        /// (1) This sets the maxdist field.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaSetMaxDistance/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="maxdist">[in] - for using ref models</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaSetMaxDistance(
            L_Dewarpa dewa,
            int maxdist)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            int _Result = Natives.dewarpaSetMaxDistance(dewa.Pointer, maxdist);

            return(_Result);
        }
Esempio n. 17
0
        // dewarp1.c (1069, 1)
        // dewarpaSetCheckColumns(dewa, check_columns) as int
        // dewarpaSetCheckColumns(L_DEWARPA *, l_int32) as l_ok
        ///  <summary>
        /// (1) This sets the 'check_columns" field.  If set, and if
        /// 'useboth' is set, this will count the number of text
        /// columns.  If the number is larger than 1, this will
        /// prevent the application of horizontal disparity arrays
        /// if they exist.  Note that the default value of check_columns
        /// if 0 (FALSE).<para/>
        ///
        /// (2) This field is set to 0 by default.  For horizontal disparity
        /// correction to take place on a single column of text, you must have:
        /// - a valid horizontal disparity array
        /// - useboth = 1 (TRUE)
        /// If there are multiple columns, additionally
        /// - check_columns = 0 (FALSE)
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaSetCheckColumns/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="check_columns">[in] - 0 for false, 1 for true</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaSetCheckColumns(
            L_Dewarpa dewa,
            int check_columns)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            int _Result = Natives.dewarpaSetCheckColumns(dewa.Pointer, check_columns);

            return(_Result);
        }
Esempio n. 18
0
        // dewarp4.c (447, 1)
        // dewarpaInsertRefModels(dewa, notests, debug) as int
        // dewarpaInsertRefModels(L_DEWARPA *, l_int32, l_int32) as l_ok
        ///  <summary>
        /// (1) This destroys all dewarp models that are invalid, and then
        /// inserts reference models where possible.<para/>
        ///
        /// (2) If %notests == 1, this ignores the curvature constraints
        /// and assumes that all successfully built models are valid.<para/>
        ///
        /// (3) If useboth == 0, it uses the closest valid model within the
        /// distance and parity constraints.  If useboth == 1, it tries
        /// to use the closest allowed hvalid model if it doesn't find
        /// an hvalid model, it uses the closest valid model.<para/>
        ///
        /// (4) For all pages without a model, this clears out any existing
        /// invalid and reference dewarps, finds the nearest valid model
        /// with the same parity, and inserts an empty dewarp with the
        /// reference page.<para/>
        ///
        /// (5) Then if it is requested to use both vertical and horizontal
        /// disparity arrays (useboth == 1), it tries to replace any
        /// hvalid == 0 model or reference with an hvalid == 1 reference.<para/>
        ///
        /// (6) The distance constraint is that any reference model must
        /// be within maxdist.  Note that with the parity constraint,
        /// no reference models will be used if maxdist  is smaller 2.<para/>
        ///
        /// (7) This function must be called, even if reference models will
        /// not be used.  It should be called after building models on all
        /// available pages, and after setting the rendering parameters.<para/>
        ///
        /// (8) If the dewa has been serialized, this function is called by
        /// dewarpaRead() when it is read back.  It is also called
        /// any time the rendering parameters are changed.<para/>
        ///
        /// (9) Note: if this has been called with useboth == 1, and useboth
        /// is reset to 0, you should first call dewarpaRestoreModels()
        /// to bring real models from the cache back to the primary array.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaInsertRefModels/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="notests">[in] - if 1, ignore curvature constraints on model</param>
        ///  <param name="debug">[in] - 1 to output information on invalid page models</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaInsertRefModels(
            L_Dewarpa dewa,
            int notests,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            int _Result = Natives.dewarpaInsertRefModels(dewa.Pointer, notests, (int)debug);

            return(_Result);
        }
Esempio n. 19
0
        // dewarp2.c (1790, 1)
        // dewarpaModelStatus(dewa, pageno, pvsuccess, phsuccess) as int
        // dewarpaModelStatus(L_DEWARPA *, l_int32, l_int32 *, l_int32 *) as l_ok
        ///  <summary>
        /// (1) This tests if a model has been built, not if it is valid.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaModelStatus/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="pageno">[in] - </param>
        ///  <param name="pvsuccess">[out][optional] - 1 on success</param>
        ///  <param name="phsuccess">[out][optional] - 1 on success</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaModelStatus(
            L_Dewarpa dewa,
            int pageno,
            out int pvsuccess,
            out int phsuccess)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            int _Result = Natives.dewarpaModelStatus(dewa.Pointer, pageno, out pvsuccess, out phsuccess);

            return(_Result);
        }
Esempio n. 20
0
        // dewarp4.c (912, 1)
        // dewarpaShowArrays(dewa, scalefact, first, last) as int
        // dewarpaShowArrays(L_DEWARPA *, l_float32, l_int32, l_int32) as l_ok
        ///  <summary>
        /// (1) Generates a pdf of contour plots of the disparity arrays.<para/>
        ///
        /// (2) This only shows actual models not ref models
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaShowArrays/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="scalefact">[in] - on contour images typ. 0.5</param>
        ///  <param name="first">[in] - first page model to render</param>
        ///  <param name="last">[in] - last page model to render use 0 to go to end</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaShowArrays(
            L_Dewarpa dewa,
            Single scalefact,
            int first,
            int last)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            int _Result = Natives.dewarpaShowArrays(dewa.Pointer, scalefact, first, last);

            return(_Result);
        }
Esempio n. 21
0
        // dewarp1.c (966, 1)
        // dewarpaSetCurvatures(dewa, max_linecurv, min_diff_linecurv, max_diff_linecurv, max_edgecurv, max_diff_edgecurv, max_edgeslope) as int
        // dewarpaSetCurvatures(L_DEWARPA *, l_int32, l_int32, l_int32, l_int32, l_int32, l_int32) as l_ok
        ///  <summary>
        /// (1) Approximating the line by a quadratic, the coefficient
        /// of the quadratic term is the curvature, and distance
        /// units are in pixels (of course).  The curvature is very
        /// small, so we multiply by 10^6 and express the constraints
        /// on the model curvatures in micro-units.<para/>
        ///
        /// (2) This sets five curvature thresholds and a slope threshold:
        /// the maximum absolute value of the vertical disparity
        /// line curvatures
        /// the minimum absolute value of the largest difference in
        /// vertical disparity line curvatures (Use a value of 0
        /// to accept all models.)
        /// the maximum absolute value of the largest difference in
        /// vertical disparity line curvatures
        /// the maximum absolute value of the left and right edge
        /// curvature for the horizontal disparity
        /// the maximum absolute value of the difference between
        /// left and right edge curvature for the horizontal disparity
        /// all in micro-units, for dewarping to take place.
        /// Use -1 for default values.<para/>
        ///
        /// (3) An image with a line curvature less than about 0.00001
        /// has fairly straight textlines.  This is 10 micro-units.<para/>
        ///
        /// (4) For example, if %max_linecurv == 100, this would prevent dewarping
        /// if any of the lines has a curvature exceeding 100 micro-units.
        /// A model having maximum line curvature larger than about 150
        /// micro-units should probably not be used.<para/>
        ///
        /// (5) A model having a left or right edge curvature larger than
        /// about 100 micro-units should probably not be used.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaSetCurvatures/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="max_linecurv">[in] - -1 for default</param>
        ///  <param name="min_diff_linecurv">[in] - -1 for default 0 to accept all models</param>
        ///  <param name="max_diff_linecurv">[in] - -1 for default</param>
        ///  <param name="max_edgecurv">[in] - -1 for default</param>
        ///  <param name="max_diff_edgecurv">[in] - -1 for default</param>
        ///  <param name="max_edgeslope">[in] - -1 for default</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaSetCurvatures(
            L_Dewarpa dewa,
            int max_linecurv,
            int min_diff_linecurv,
            int max_diff_linecurv,
            int max_edgecurv,
            int max_diff_edgecurv,
            int max_edgeslope)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            int _Result = Natives.dewarpaSetCurvatures(dewa.Pointer, max_linecurv, min_diff_linecurv, max_diff_linecurv, max_edgecurv, max_diff_edgecurv, max_edgeslope);

            return(_Result);
        }
Esempio n. 22
0
        // dewarp1.c (805, 1)
        // dewarpaInsertDewarp(dewa, dew) as int
        // dewarpaInsertDewarp(L_DEWARPA *, L_DEWARP *) as l_ok
        ///  <summary>
        /// (1) This inserts the dewarp into the array, which now owns it.
        /// It also keeps track of the largest page number stored.
        /// It must be done before the disparity model is built.<para/>
        ///
        /// (2) Note that this differs from the usual method of filling out
        /// arrays in leptonica, where the arrays are compact and
        /// new elements are typically added to the end.  Here,
        /// the dewarp can be added anywhere, even beyond the initial
        /// allocation.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaInsertDewarp/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="dew">[in] - to be added</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaInsertDewarp(
            L_Dewarpa dewa,
            L_Dewarp dew)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

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

            int _Result = Natives.dewarpaInsertDewarp(dewa.Pointer, dew.Pointer);

            return(_Result);
        }
Esempio n. 23
0
        public static L_Dewarp dewarpaGetDewarp(this L_Dewarpa dewa, int index)
        {
            if (null == dewa)
            {
                throw new ArgumentNullException("dewa cannot be null.");
            }

            var pointer = Native.DllImports.dewarpaGetDewarp((HandleRef)dewa, index);

            if (IntPtr.Zero == pointer)
            {
                return(null);
            }
            else
            {
                return(new L_Dewarp(pointer));
            }
        }
Esempio n. 24
0
        // dewarp1.c (902, 1)
        // dewarpaGetDewarp(dewa, index) as L_Dewarp
        // dewarpaGetDewarp(L_DEWARPA *, l_int32) as L_DEWARP *
        ///  <summary>
        /// dewarpaGetDewarp()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaGetDewarp/*"/>
        ///  <param name="dewa">[in] - populated with dewarp structs for pages</param>
        ///  <param name="index">[in] - into dewa: this is the pageno</param>
        ///   <returns>dew handle still owned by dewa, or NULL on error</returns>
        public static L_Dewarp dewarpaGetDewarp(
            L_Dewarpa dewa,
            int index)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            IntPtr _Result = Natives.dewarpaGetDewarp(dewa.Pointer, index);

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

            return(new L_Dewarp(_Result));
        }
Esempio n. 25
0
        // dewarp4.c (756, 1)
        // dewarpaModelStats(dewa, pnnone, pnvsuccess, pnvvalid, pnhsuccess, pnhvalid, pnref) as int
        // dewarpaModelStats(L_DEWARPA *, l_int32 *, l_int32 *, l_int32 *, l_int32 *, l_int32 *, l_int32 *) as l_ok
        ///  <summary>
        /// (1) A page without a model has no dew.  It most likely failed to
        /// generate a vertical model, and has not been assigned a ref
        /// model from a neighboring page with a valid vertical model.<para/>
        ///
        /// (2) A page has vsuccess == 1 if there is at least a model of the
        /// vertical disparity.  The model may be invalid, in which case
        /// dewarpaInsertRefModels() will stash it in the cache and
        /// attempt to replace it by a valid ref model.<para/>
        ///
        /// (3) A vvvalid model is a vertical disparity model whose parameters
        /// satisfy the constraints given in dewarpaSetValidModels().<para/>
        ///
        /// (4) A page has hsuccess == 1 if both the vertical and horizontal
        /// disparity arrays have been constructed.<para/>
        ///
        /// (5) An  hvalid model has vertical and horizontal disparity
        /// models whose parameters satisfy the constraints given
        /// in dewarpaSetValidModels().<para/>
        ///
        /// (6) A page has a ref model if it failed to generate a valid
        /// model but was assigned a vvalid or hvalid model on another
        /// page (within maxdist) by dewarpaInsertRefModel().<para/>
        ///
        /// (7) This calls dewarpaTestForValidModel() it ignores the vvalid
        /// and hvalid fields.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaModelStats/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="pnnone">[out][optional] - number without any model</param>
        ///  <param name="pnvsuccess">[out][optional] - number with a vert model</param>
        ///  <param name="pnvvalid">[out][optional] - number with a valid vert model</param>
        ///  <param name="pnhsuccess">[out][optional] - number with both models</param>
        ///  <param name="pnhvalid">[out][optional] - number with both models valid</param>
        ///  <param name="pnref">[out][optional] - number with a reference model</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaModelStats(
            L_Dewarpa dewa,
            out int pnnone,
            out int pnvsuccess,
            out int pnvvalid,
            out int pnhsuccess,
            out int pnhvalid,
            out int pnref)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            int _Result = Natives.dewarpaModelStats(dewa.Pointer, out pnnone, out pnvsuccess, out pnvvalid, out pnhsuccess, out pnhvalid, out pnref);

            return(_Result);
        }
Esempio n. 26
0
        // dewarp1.c (1573, 1)
        // dewarpaWrite(filename, dewa) as int
        // dewarpaWrite(const char *, L_DEWARPA *) as l_ok
        ///  <summary>
        /// dewarpaWrite()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaWrite/*"/>
        ///  <param name="filename">[in] - </param>
        ///  <param name="dewa">[in] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaWrite(
            String filename,
            L_Dewarpa dewa)
        {
            if (filename == null)
            {
                throw new ArgumentNullException("filename cannot be Nothing");
            }

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

            int _Result = Natives.dewarpaWrite(filename, dewa.Pointer);

            return(_Result);
        }
Esempio n. 27
0
        // dewarp1.c (1604, 1)
        // dewarpaWriteStream(fp, dewa) as int
        // dewarpaWriteStream(FILE *, L_DEWARPA *) as l_ok
        ///  <summary>
        /// dewarpaWriteStream()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaWriteStream/*"/>
        ///  <param name="fp">[in] - file stream opened for "wb"</param>
        ///  <param name="dewa">[in] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaWriteStream(
            FILE fp,
            L_Dewarpa dewa)
        {
            if (fp == null)
            {
                throw new ArgumentNullException("fp cannot be Nothing");
            }

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

            int _Result = Natives.dewarpaWriteStream(fp.Pointer, dewa.Pointer);

            return(_Result);
        }
Esempio n. 28
0
        // dewarp1.c (722, 1)
        // dewarpaDestroy(pdewa) as Object
        // dewarpaDestroy(L_DEWARPA **) as void
        ///  <summary>
        /// dewarpaDestroy()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaDestroy/*"/>
        ///  <param name="pdewa">[in,out] - will be set to null before returning</param>
        public static void dewarpaDestroy(
            ref L_Dewarpa pdewa)
        {
            IntPtr pdewaPtr = IntPtr.Zero;  if (pdewa != null)

            {
                pdewaPtr = pdewa.Pointer;
            }

            Natives.dewarpaDestroy(ref pdewaPtr);
            if (pdewaPtr == IntPtr.Zero)
            {
                pdewa = null;
            }
            else
            {
                pdewa = new L_Dewarpa(pdewaPtr);
            };
        }
Esempio n. 29
0
        // dewarp4.c (223, 1)
        // dewarpSinglePageRun(pixs, pixb, dewa, ppixd, debug) as int
        // dewarpSinglePageRun(PIX *, PIX *, L_DEWARPA *, PIX **, l_int32) as l_ok
        ///  <summary>
        /// (1) Dewarps pixs and returns the result in [and]pixd.<para/>
        ///
        /// (2) The 1 bpp version %pixb and %dewa are conveniently generated by
        /// dewarpSinglePageInit().<para/>
        ///
        /// (3) Non-default model parameters must be set before calling this.<para/>
        ///
        /// (4) If a model cannot be built, this returns a copy of pixs in [and]pixd.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpSinglePageRun/*"/>
        ///  <param name="pixs">[in] - any depth</param>
        ///  <param name="pixb">[in] - 1 bpp</param>
        ///  <param name="dewa">[in] - initialized</param>
        ///  <param name="ppixd">[out] - dewarped result</param>
        ///  <param name="debug">[in] - 1 for debugging output, 0 otherwise</param>
        ///   <returns>0 if OK, 1 on error list of page numbers, or NULL on error</returns>
        public static int dewarpSinglePageRun(
            Pix pixs,
            Pix pixb,
            L_Dewarpa dewa,
            out Pix ppixd,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

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

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

            if ((new List <int> {
                1
            }).Contains((int)pixb.d) == false)
            {
                throw new ArgumentException("1 bpp");
            }
            IntPtr ppixdPtr = IntPtr.Zero;
            int    _Result  = Natives.dewarpSinglePageRun(pixs.Pointer, pixb.Pointer, dewa.Pointer, out ppixdPtr, (int)debug);

            if (ppixdPtr == IntPtr.Zero)
            {
                ppixd = null;
            }
            else
            {
                ppixd = new Pix(ppixdPtr);
            };

            return(_Result);
        }
Esempio n. 30
0
        // dewarp3.c (537, 1)
        // dewarpaApplyDisparityBoxa(dewa, pageno, pixs, boxas, mapdir, x, y, pboxad, debugfile) as int
        // dewarpaApplyDisparityBoxa(L_DEWARPA *, l_int32, PIX *, BOXA *, l_int32, l_int32, l_int32, BOXA **, const char *) as l_ok
        ///  <summary>
        /// (1) This applies the disparity arrays in one of two mapping directions
        /// to the specified boxa.  It can be used in the backward direction
        /// to locate a box in the original coordinates that would have
        /// been dewarped to to the specified image.<para/>
        ///
        /// (2) If there is no model for %pageno, this will use the model for
        /// 'refpage' and put the result in the dew for %pageno.<para/>
        ///
        /// (3) This works with both stripped and full resolution page models.
        /// If the full res disparity array(s) are missing, they are remade.<para/>
        ///
        /// (4) If an error occurs, a copy of the input boxa is returned.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaApplyDisparityBoxa/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="pageno">[in] - of page model to be used may be a ref model</param>
        ///  <param name="pixs">[in] - initial pix reference for alignment and debugging</param>
        ///  <param name="boxas">[in] - boxa to be mapped</param>
        ///  <param name="mapdir">[in] - 1 if mapping forward from original to dewarped 0 if backward</param>
        ///  <param name="x">[in] - origin for generation of disparity arrays with respect to the source region</param>
        ///  <param name="y">[in] - origin for generation of disparity arrays with respect to the source region</param>
        ///  <param name="pboxad">[out] - disparity corrected boxa</param>
        ///  <param name="debugfile">[in]use NULL to skip - writing this</param>
        ///   <returns>0 if OK, 1 on error no models or ref models available</returns>
        public static int dewarpaApplyDisparityBoxa(
            L_Dewarpa dewa,
            int pageno,
            Pix pixs,
            Boxa boxas,
            int mapdir,
            int x,
            int y,
            out Boxa pboxad,
            String debugfile = "")
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

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

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

            IntPtr pboxadPtr = IntPtr.Zero;
            int    _Result   = Natives.dewarpaApplyDisparityBoxa(dewa.Pointer, pageno, pixs.Pointer, boxas.Pointer, mapdir, x, y, out pboxadPtr, debugfile);

            if (pboxadPtr == IntPtr.Zero)
            {
                pboxad = null;
            }
            else
            {
                pboxad = new Boxa(pboxadPtr);
            };

            return(_Result);
        }