Skip to content

Commit

Permalink
catch if resolution is not supported by OCR.
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Jun 7, 2016
1 parent bcf4a86 commit 3876400
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions ARKBreedingStats/ArkOCR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public static ArkOCR OCR
}
}

public void calibrate(Bitmap screenshot)
public bool calibrate(Bitmap screenshot)
{
if (screenshot.Width == calibrationResolution[0] && screenshot.Height == calibrationResolution[1])
return;
return true;

//debugPanel.Controls.Clear();
alphabet = new Bitmap[255];
Expand All @@ -70,7 +70,7 @@ public void calibrate(Bitmap screenshot)
res.bottom = screenshot.Height;
}
else
return; // error
return false; // error

if (res.Width == 1920 && res.Height == 1080)
resolution = 0;
Expand All @@ -79,7 +79,10 @@ public void calibrate(Bitmap screenshot)
else if (res.Width == 1600 && res.Height == 900)
resolution = 2;
else
{
resolution = -1;
return false; // no supported resolution
}


switch (resolution)
Expand Down Expand Up @@ -175,6 +178,8 @@ public void calibrate(Bitmap screenshot)

foreach (char a in ":0123456789.%/")
reducedAlphabet[a] = alphabet[a];

return true;
}

private PictureBox AddBitmapToDebug(Bitmap bmp)
Expand Down Expand Up @@ -461,7 +466,11 @@ public float[] doOCR(out string OCRText, out string dinoName, string useImageFil
OCRText = "Error: no image for OCR. Is ARK running?";
return finalValues;
}
calibrate(screenshotbmp);
if (!calibrate(screenshotbmp))
{
OCRText = "Error while calibrating: probably game-resolution is not supported by this OCR";
return finalValues;
}
finalValues = new float[statPositions.Count];

AddBitmapToDebug(screenshotbmp);
Expand Down Expand Up @@ -518,7 +527,6 @@ public float[] doOCR(out string OCRText, out string dinoName, string useImageFil
dinoName = testStatName;
// TODO: test here that the read stat name corresponds to the stat supposed to be read
finalValues[count] = v;

}

OCRText = finishedText;
Expand Down

0 comments on commit 3876400

Please sign in to comment.