Example #1
0
        /// <summary>
        /// Determines the scew angle and if confidence is high enough returns the descewed image as the result, otherwise returns clone of original image.
        /// </summary>
        /// <remarks>
        /// This binarizes if necessary and finds the skew angle.  If the
        /// angle is large enough and there is sufficient confidence,
        /// it returns a deskewed image; otherwise, it returns a clone.
        /// </remarks>
        /// <param name="sweep">linear sweep parameters</param>
        /// <param name="redSearch">The reduction factor used by the binary search, can be 1, 2, or 4.</param>
        /// <param name="thresh">The threshold value used for binarizing the image.</param>
        /// <param name="scew">The scew angle and confidence</param>
        /// <returns>Returns deskewed image if confidence was high enough, otherwise returns clone of original pix.</returns>
        public Pix Deskew(ScewSweep sweep, int redSearch, int thresh, out Scew scew)
        {
            float pAngle, pConf;
            var   resultPixHandle = Interop.LeptonicaApi.pixDeskewGeneral(handle, sweep.Reduction, sweep.Range, sweep.Delta, redSearch, thresh, out pAngle, out pConf);

            if (resultPixHandle == IntPtr.Zero)
            {
                throw new TesseractException("Failed to deskew image.");
            }
            scew = new Scew(pAngle, pConf);
            return(new Pix(resultPixHandle));
        }
Example #2
0
 /// <summary>
 /// Determines the scew angle and if confidence is high enough returns the descewed image as the result, otherwise returns clone of original image.
 /// </summary>
 /// <remarks>
 /// This binarizes if necessary and finds the skew angle.  If the
 /// angle is large enough and there is sufficient confidence,
 /// it returns a deskewed image; otherwise, it returns a clone.
 /// </remarks>
 /// <param name="sweep">linear sweep parameters</param>
 /// <param name="redSearch">The reduction factor used by the binary search, can be 1, 2, or 4.</param>
 /// <param name="thresh">The threshold value used for binarizing the image.</param>
 /// <param name="scew">The scew angle and confidence</param>
 /// <returns>Returns deskewed image if confidence was high enough, otherwise returns clone of original pix.</returns>
 public Pix Deskew(ScewSweep sweep, int redSearch, int thresh, out Scew scew)
 {
     float pAngle, pConf;
     var resultPixHandle = Interop.LeptonicaApi.Native.pixDeskewGeneral(handle, sweep.Reduction, sweep.Range, sweep.Delta, redSearch, thresh, out pAngle, out pConf);
     if (resultPixHandle == IntPtr.Zero) throw new TesseractException("Failed to deskew image.");
     scew = new Scew(pAngle, pConf);
     return new Pix(resultPixHandle);
 }