public override void DoFrameAction() { foreach (Hotspot Hotspot in this.Hotspots) { Hotspot.SetCaptureRect(Hotspot.SettingHotspot.CaptureRect); Hotspot.SetCastableDetectionArea(Hotspot.SettingHotspot.CastableDetectionArea); Hotspot.SetCastableDetectionColors(Hotspot.SettingHotspot.CastableDetectionColors); Hotspot.BorderCut = Hotspot.SettingHotspot.BorderCut; Mat HotspotMat = new Mat(this.CaptureResult, Hotspot.CaptureRect); Hotspot.CaptureSource = HotspotMat; Hotspot.CreateFilteredMat(); Hotspot.DoBeforeFrameAction(); Hotspot.Tick(); Hotspot.DoFrameAction(); Hotspot.DoAfterFrameAction(); foreach (SettingLedChain LedChain in Hotspot.SettingHotspot.LedChains) { List <LedResults.Color> colors = Hotspot.getCurrentColors(LedChain.LedIdNames); int colorIndex = 0; foreach (string LedIdName in LedChain.LedIdNames) { CorsairLedId ledId = (CorsairLedId)Enum.Parse(typeof(CorsairLedId), LedIdName); int curColorIndex = colorIndex % LedChain.LedIdNames.Count; LedResults.Color CurColor = colors.ElementAt(curColorIndex); GetICueBridge().GetDevice(LedChain.DeviceType).SetLedColor(ledId, CurColor); colorIndex++; } } } GetICueBridge().Keyboard.sendToHardware(); GetICueBridge().LedStrip.sendToHardware(); this.DrawFPS(); /* * var ledResult = new LedResult(); * var indexer = mat.GetGenericIndexer<OpenCvSharp.Vec3b>(); * int getX = 60; * int getY = 50; * for (int i = 0; i < 4; i++) * { * OpenCvSharp.Vec3b color = indexer[getY, getX + i]; * ledResult.setSkill(i, new LedResults.Color(color.Item2, color.Item1, color.Item0)); * } * iCueBridge.SetResult(ledResult); * * mat.Rectangle(new OpenCvSharp.Point(getX - 1, getY - 1), new OpenCvSharp.Point(getX + 5, getY + 1), new OpenCvSharp.Scalar(164, 196, 215, 255)); */ }
public virtual void SetLedColor(CorsairLedId ledId, LedResults.Color color) { CorsairLedColor CorsairColor = new CorsairLedColor { ledId = (int)ledId, r = (int)color.R, g = (int)color.G, b = (int)color.B }; int existsIndex = this.Colors.FindIndex(ind => ind.ledId == CorsairColor.ledId); if (existsIndex == -1) { this.Colors.Add(CorsairColor); } else { this.Colors[existsIndex] = CorsairColor; } }