ARKBreedingStats.Form1.doOCR C# (CSharp) Method

doOCR() public method

public doOCR ( string imageFilePath = "", bool manuallyTriggered = true ) : void
imageFilePath string
manuallyTriggered bool
return void
        public void doOCR(string imageFilePath = "", bool manuallyTriggered = true)
        {
            String debugText;
            String dinoName;
            float[] OCRvalues = ArkOCR.OCR.doOCR(out debugText, out dinoName, imageFilePath, manuallyTriggered);
            txtOCROutput.Text = debugText;
            if (OCRvalues.Length <= 1)
                return;
            if ((decimal)OCRvalues[0] <= numericUpDownLevel.Maximum)
                numericUpDownLevel.Value = (decimal)OCRvalues[0];

            for (int i = 0; i < 8; i++)
            {
                if (statIOs[i].percent)
                    statIOs[i].Input = OCRvalues[i + 1] / 100.0;
                else
                    statIOs[i].Input = OCRvalues[i + 1];
            }
            txtOCROutput.Text = debugText;
            creatureInfoInputExtractor.CreatureName = dinoName;

            List<int> possibleDinos = determineDinoRaceFromStats(OCRvalues, dinoName);

            if (possibleDinos.Count == 0)
                extractLevels(); // only one possible dino, use that one
            else
            {
                bool sameValues = true;

                if (lastOCRValues != null)
                    for (int i = 0; i < 9; i++)
                        if (OCRvalues[i] != lastOCRValues[i])
                        {
                            sameValues = false;
                            break;
                        }

                // if there's more than one option, on manual we cycle through the options if we're trying multiple times
                // on automated, we take the first one that yields an error-free level extraction
                if (manuallyTriggered && sameValues)
                {
                    int newindex = (possibleDinos.IndexOf(lastOCRSpecies) + 1) % possibleDinos.Count;
                    comboBoxSpeciesExtractor.SelectedIndex = possibleDinos[newindex];
                    lastOCRSpecies = possibleDinos[newindex];
                    lastOCRValues = OCRvalues;
                    extractLevels();
                }
                else
                { // automated, or first manual attempt at new values
                    bool foundPossiblyGood = false;
                    for (int dinooption = 0; dinooption < possibleDinos.Count() && foundPossiblyGood == false; dinooption++)
                    {
                        // if the last OCR'ed values are the same as this one, the user may not be happy with the dino species selection and want another one
                        // so we'll cycle to the next one, but only if the OCR is manually triggered, on autotrigger (ie, overlay), don't change
                        comboBoxSpeciesExtractor.SelectedIndex = possibleDinos[dinooption];
                        lastOCRSpecies = possibleDinos[dinooption];
                        lastOCRValues = OCRvalues;
                        foundPossiblyGood = extractLevels();
                    }
                }
            }

            lastOCRValues = OCRvalues;
            tabControlMain.SelectedTab = tabPageExtractor;
        }

Usage Example

Example #1
0
 void inventoryCheckTimer_Tick(object sender, EventArgs e)
 {
     if (OCRing == true)
     {
         return;
     }
     lblStatus.Text = "..";
     Application.DoEvents();
     OCRing = true;
     if (!ArkOCR.OCR.isDinoInventoryVisible())
     {
         for (int i = 0; i < labels.Count(); i++)
         {
             if (labels[i] != null)
             {
                 labels[i].Text = "";
             }
         }
     }
     else
     {
         lblStatus.Text = "Reading Values";
         Application.DoEvents();
         if (ExtractorForm != null)
         {
             ExtractorForm.doOCR("", false);
         }
     }
     OCRing         = false;
     lblStatus.Text = "";
     Application.DoEvents();
     return;
 }
All Usage Examples Of ARKBreedingStats.Form1::doOCR
Form1