Algorithmix.Forensics.OCR.ParallelDetectOrientation C# (CSharp) Method

ParallelDetectOrientation() public static method

Parallelized OCR Orientation Confidence Detector, this method will run ocr on an image and its corresponding reversed images and return the confidence and both the ocrdata objects
public static ParallelDetectOrientation ( Bitmap regs, Bitmap revs, Accuracy mode = Accuracy.High, string lang = "eng", bool enableTimer = false ) : Tuple[]
regs System.Drawing.Bitmap Images with default regular orientation
revs System.Drawing.Bitmap Images with reversed orientation to default
mode Accuracy OCR accuracy mode
lang string OCR languages
enableTimer bool Enable timer for diagnostic purposes
return Tuple[]
        public static Tuple<long, OcrData, OcrData>[] ParallelDetectOrientation(
            Bitmap[] regs,
            Bitmap[] revs,
            Accuracy mode = Accuracy.High,
            string lang = "eng",
            bool enableTimer = false)
        {
            if (regs.Length != revs.Length)
            {
                throw new ArgumentException("Input Arrays must be same length!");
            }

            // create new array and copy over image references
            int pivot = regs.Length;
            Bitmap[] images = new Bitmap[regs.Length + revs.Length];
            Array.Copy(regs, images, pivot);
            Array.Copy(revs, 0, images, pivot, pivot);

            // Run Parallel Recognition on the arrays
            OcrData[] datas = ParallelRecognize(images, pivot + pivot, mode, lang, enableTimer);

            // Extract results and calculate confidence
            Tuple<long, OcrData, OcrData>[] results = new Tuple<long, OcrData, OcrData>[pivot];
            for (int ii = 0; ii < pivot; ii++)
            {
                OcrData reg = datas[ii];
                OcrData rev = datas[ii + pivot];

                // If postive we are confident about the current orientation
                // if negative we are not confident about the current orientation
                long confidence = rev.Cost - reg.Cost;
                results[ii] = new Tuple<long, OcrData, OcrData>(confidence, reg, rev);
            }
            return results;
        }