Ejemplo n.º 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.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));
        }
Ejemplo n.º 2
0
 public bool Equals(Scew other)
 {
     return(this.confidence == other.confidence && this.angle == other.angle);
 }
Ejemplo n.º 3
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="redSearch">The reduction factor used by the binary search, can be 1, 2, or 4.</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(int redSearch, out Scew scew)
 {
     return(Deskew(ScewSweep.Default, redSearch, DefaultBinaryThreshold, out scew));
 }
Ejemplo n.º 4
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="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(out Scew scew)
 {
     return(Deskew(DefaultBinarySearchReduction, out scew));
 }