protected void ScanActionSlot(FastBitmapHSV bitmap, Rectangle bounds, ActionData actionData, int slotIdx) { for (int idxY = 0; idxY < rectActionAvail.Height; idxY++) { for (int idxX = 0; idxX < rectActionAvail.Width; idxX++) { FastPixelHSV testPx = bitmap.GetPixel(bounds.X + rectActionAvail.X + idxX, bounds.Y + rectActionAvail.Y + idxY); bool match = matchActionAvail.IsMatching(testPx); if (match) { actionData.isValid = true; break; } } } if (actionData.isValid) { float[] pixelInput = ExtractActionSlotWeaponData(bitmap, slotIdx); actionData.weaponClass = (EWeaponType)classifierWeapon.Calculate(pixelInput, out float dummyPct); actionData.element = ScanElementType(bitmap, bounds); actionData.hasBoost = HasElemBoost(bitmap, slotIdx); } if (DebugLevel >= EDebugLevel.Simple) { Console.WriteLine("{0} Action[{1}]: valid:{2}, class:{3}, elem: {4}", ScannerName, slotIdx, actionData.isValid, actionData.weaponClass, actionData.element); } if (DebugLevel >= EDebugLevel.Verbose) { var minMono = 255; var maxMono = 0; for (int idxY = 0; idxY < rectActionAvail.Height; idxY++) { for (int idxX = 0; idxX < rectActionAvail.Width; idxX++) { FastPixelHSV testPx = bitmap.GetPixel(bounds.X + rectActionAvail.X + idxX, bounds.Y + rectActionAvail.Y + idxY); minMono = Math.Min(minMono, testPx.GetMonochrome()); maxMono = Math.Max(maxMono, testPx.GetMonochrome()); } } Console.WriteLine(">> avail M:{0}..{1} (x:{2},y:{3},w:{4},h:{5})", minMono, maxMono, bounds.X + rectActionAvail.X, bounds.Y + rectActionAvail.Y, rectActionAvail.Width, rectActionAvail.Height); } }
public float[] ExtractHeaderPatternData(FastBitmapHSV bitmap, int patternIdx) { // scan area: 20x8 float[] values = new float[20 * 8]; for (int idx = 0; idx < values.Length; idx++) { values[idx] = 0.0f; } const int monoSteps = 16; const float monoScale = 1.0f / monoSteps; for (int idxY = 0; idxY < 8; idxY++) { for (int idxX = 0; idxX < 20; idxX++) { FastPixelHSV pixel = bitmap.GetPixel(posHeaderPattern[patternIdx].X + idxX, posHeaderPattern[patternIdx].Y + idxY); int monoV = pixel.GetMonochrome() / (256 / monoSteps); values[idxX + (idxY * 20)] = monoV * monoScale; } } return(values); }
public float[] ExtractActionSlotWeaponData(FastBitmapHSV bitmap, int slotIdx) { // scan area: 10x10 (rectActionIcon) float[] values = new float[10 * 10]; for (int idx = 0; idx < values.Length; idx++) { values[idx] = 0.0f; } const int monoSteps = 16; const float monoScale = 1.0f / monoSteps; Point slotPos = rectActionSlots[slotIdx].Location; for (int idxY = 0; idxY < 10; idxY++) { for (int idxX = 0; idxX < 10; idxX++) { FastPixelHSV pixel = bitmap.GetPixel(slotPos.X + rectActionIcon.X + idxX, slotPos.Y + rectActionIcon.Y + idxY); int monoV = pixel.GetMonochrome() / (256 / monoSteps); values[idxX + (idxY * 10)] = monoV * monoScale; } } return(values); }
public float[] ExtractButtonData(FastBitmapHSV bitmap, int slotIdx) { // scan area: 16x8 (rectButtonText scaled down) float[] values = new float[16 * 8]; for (int idx = 0; idx < values.Length; idx++) { values[idx] = 0.0f; } const int monoSteps = 16; const float monoScale = 1.0f / monoSteps; Point slotPos = rectButtonPos[slotIdx].Location; slotPos.X += rectButtonText.Location.X; slotPos.Y += rectButtonText.Location.Y; for (int idxY = 0; idxY < 16; idxY++) { for (int idxX = 0; idxX < 32; idxX++) { FastPixelHSV pixel = bitmap.GetPixel(slotPos.X + idxX, slotPos.Y + idxY); int monoV = pixel.GetMonochrome() / (256 / monoSteps); values[(idxX / 2) + ((idxY / 2) * 16)] += monoV * monoScale * 0.25f; } } return(values); }
public float[] ExtractDemonTypeData(FastBitmapHSV bitmap) { // scan area: 10x10 (rectActionIcon) float[] values = new float[10 * 10]; for (int idx = 0; idx < values.Length; idx++) { values[idx] = 0.0f; } const int monoSteps = 16; const float monoScale = 1.0f / monoSteps; for (int idxY = 0; idxY < 10; idxY++) { for (int idxX = 0; idxX < 10; idxX++) { FastPixelHSV pixel = bitmap.GetPixel(rectDemonType.X + idxX, rectDemonType.Y + idxY); int monoV = pixel.GetMonochrome() / (256 / monoSteps); values[idxX + (idxY * 10)] = monoV * monoScale; } } return(values); }
private void ScanBurst(FastBitmapHSV bitmap, ScreenData screenData) { float monoAcc = 0.0f; for (int idxY = 0; idxY < rectBurstActive.Height; idxY++) { for (int idxX = 0; idxX < rectBurstActive.Width; idxX++) { FastPixelHSV testPx = bitmap.GetPixel(rectBurstActive.X + idxX, rectBurstActive.Y + idxY); monoAcc += testPx.GetMonochrome(); } } float monoAvg = monoAcc / (rectBurstActive.Width * rectBurstActive.Height); float centerFillPct = 0; if (monoAvg < 15) { screenData.BurstState = EBurstState.Active; } else { centerFillPct = ScreenshotUtilities.CountFillPct(bitmap, rectBurstCenter, matchBurstCenter); if (centerFillPct > 0.75f) { screenData.BurstState = EBurstState.ReadyAndCenter; screenData.BurstMarkerPctX = 0.5f; screenData.BurstMarkerPctY = 0.5f; if (DebugLevel >= EDebugLevel.Verbose) { Rectangle box = GetSpecialActionBox((int)ESpecialBox.BurstCenter); DrawRectangle(bitmap, box.X, box.Y, box.Width, box.Height, 255); } } else { ScanBurstPosition(bitmap, screenData); if (DebugLevel >= EDebugLevel.Verbose && screenData.BurstState == EBurstState.Ready) { Rectangle box = GetSpecialActionBox((int)ESpecialBox.BurstReady); DrawRectangle(bitmap, box.X, box.Y, box.Width, box.Height, 255); } } } if (DebugLevel >= EDebugLevel.Simple) { Console.WriteLine("{0} ScanBurst: {1}", ScannerName, screenData.BurstState); } if (DebugLevel >= EDebugLevel.Verbose) { Console.WriteLine(">> monoAvg: {0}, centerFillPct: {1}", monoAvg, centerFillPct); } }
private float GetActionSlotPixelValue(FastPixelHSV pixel) { const int hueSteps = 16; const int monoSteps = 16; const float monoScale = 1.0f / monoSteps; const float hueScale = monoScale / hueSteps; int hueV = pixel.GetHue() / (360 / hueSteps); int monoV = pixel.GetMonochrome() / (256 / monoSteps); float pixelV = (hueV * hueScale) + (monoV * monoScale); return(pixelV); }
protected float[] ExtractStatData(FastBitmapHSV bitmap, Point[] playerPos, int playerIdx, int statIdx) { // scan area: (9+1)x7 float[] values = new float[(11 + 1) * 9]; int writeIdx = 0; for (int idxY = 0; idxY < 9; idxY++) { float accHueLine = 0.0f; for (int idxX = 0; idxX < 11; idxX++) { FastPixelHSV pixel = bitmap.GetPixel(playerPos[playerIdx].X + posStatOffset[statIdx].X + idxX - 1, playerPos[playerIdx].Y + posStatOffset[statIdx].Y + idxY - 1); values[writeIdx] = pixel.GetMonochrome() / 255.0f; accHueLine += pixel.GetHue() / 360.0f; writeIdx++; } values[writeIdx] = accHueLine / 11; writeIdx++; } return(values); }
protected EElementType ScanElementType(FastBitmapHSV bitmap, Rectangle bounds) { EElementType element = EElementType.Unknown; int countElemR = 0; int countElemG = 0; int countElemB = 0; int countTotal = 0; const int hueDrift = 30; const int hueB = 180; const int hueG = 130; const int hueR = 15; foreach (var sampleBounds in rectActionElements) { for (int idxY = 0; idxY < sampleBounds.Height; idxY++) { for (int idxX = 0; idxX < sampleBounds.Width; idxX++) { FastPixelHSV testPx = bitmap.GetPixel(bounds.X + sampleBounds.X + idxX, bounds.Y + sampleBounds.Y + idxY); countTotal++; int testMono = testPx.GetMonochrome(); if (testMono < 210) { int testHue = testPx.GetHue(); countElemR += ((testHue > (hueR + 360 - hueDrift)) || (testHue < (hueR + hueDrift))) ? 1 : 0; countElemG += ((testHue > (hueG - hueDrift)) && (testHue < (hueG + hueDrift))) ? 1 : 0; countElemB += ((testHue > (hueB - hueDrift)) && (testHue < (hueB + hueDrift))) ? 1 : 0; } } } } int minThr = countTotal * 30 / 100; if ((countElemR > minThr) && (countElemR > countElemG) && (countElemR > countElemB)) { element = EElementType.Fire; } else if ((countElemG > minThr) && (countElemG > countElemR) && (countElemG > countElemB)) { element = EElementType.Wind; } else if ((countElemB > minThr) && (countElemB > countElemR) && (countElemB > countElemG)) { element = EElementType.Water; } if (element == EElementType.Unknown) { countElemR = 0; countElemG = 0; countElemB = 0; for (int idxY = 0; idxY < bounds.Height; idxY++) { for (int idxX = 0; idxX < bounds.Width; idxX++) { FastPixelHSV testPx = bitmap.GetPixel(bounds.X + idxX, bounds.Y + idxY); int testMono = testPx.GetMonochrome(); if (testMono < 210) { int testHue = testPx.GetHue(); countElemR += ((testHue > (hueR + 360 - hueDrift)) || (testHue < (hueR + hueDrift))) ? 1 : 0; countElemG += ((testHue > (hueG - hueDrift)) && (testHue < (hueG + hueDrift))) ? 1 : 0; countElemB += ((testHue > (hueB - hueDrift)) && (testHue < (hueB + hueDrift))) ? 1 : 0; } } } countTotal = bounds.Width * bounds.Height; minThr = countTotal * 30 / 100; if ((countElemR > minThr) && (countElemR > countElemG) && (countElemR > countElemB)) { element = EElementType.Fire; } else if ((countElemG > minThr) && (countElemG > countElemR) && (countElemG > countElemB)) { element = EElementType.Wind; } else if ((countElemB > minThr) && (countElemB > countElemR) && (countElemB > countElemG)) { element = EElementType.Water; } } if (DebugLevel >= EDebugLevel.Verbose) { Console.WriteLine(">> elem counters: R:{0}, G:{1}, B:{2} => {3}", countElemR, countElemG, countElemB, element); } return(element); }