Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool EmguBool(Image<Bgr, byte> source, string picture, out Point found, bool screenshot = false)
- {
- string file = @"C:\tmp\search\" + picture;
- if (!File.Exists(file))
- {
- Console.WriteLine("picture not found {0}", picture);
- found = Point.Empty;
- return false;
- }
- var template = new Image<Bgr, byte>(file); // Image A
- var imageToShow = source.Copy();
- using (Image<Gray, float> result = source.MatchTemplate(template, global::Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed))
- {
- double[] minValues, maxValues;
- Point[] minLocations, maxLocations;
- result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations);
- if (screenshot)
- {
- if (maxValues[0] > 0.9)
- {
- // This is a match. Do something with it, for example draw a rectangle around it.
- Rectangle match = new Rectangle(maxLocations[0], template.Size);
- imageToShow.Draw(match, new Bgr(Color.Red), 3);
- imageToShow.Save(@"C:\tmp\getset.jpg");
- }
- }
- if (maxValues[0] < 0.9)
- {
- found = Point.Empty;
- return false;
- }
- found = new Point(maxLocations[0].X, maxLocations[0].Y);
- return true;
- }
- }
- public static void OpenCapsules()
- {
- var screenshot = EmguCv.QueryFrame();
- if (EmguBool(screenshot, "disenchant_fail.png", out Point disenchant_fail))
- {
- MouseMove(disenchant_fail.X + 55, disenchant_fail.Y + 47);
- Console.WriteLine("disenchant_fail.png");
- LeftClick();
- return;
- }
- if (EmguBool(screenshot, "close.png", out Point close))
- {
- MouseMove(close.X + 22, close.Y + 20);
- Console.WriteLine("close.png");
- LeftClick();
- return;
- }
- if (EmguBool(screenshot, "unlock_permanent.png", out Point unlock_permanent))
- {
- MouseMove(unlock_permanent.X, unlock_permanent.Y);
- Console.WriteLine("unlock_permanent.png");
- LeftClick();
- return;
- }
- if (EmguBool(screenshot, "add_to_loot.png", out Point add_to_loot))
- {
- MouseMove(add_to_loot.X, add_to_loot.Y);
- Console.WriteLine("add_to_loot.png");
- LeftClick();
- return;
- }
- if (EmguBool(screenshot, "open.png", out Point open))
- {
- MouseMove(open.X, open.Y);
- Console.WriteLine("open.png");
- LeftClick();
- return;
- }
- if (EmguBool(screenshot, "capsules_V_2.png", out Point capsules_V_2))
- {
- MouseMove(capsules_V_2.X, capsules_V_2.Y);
- Console.WriteLine("capsules_V_2.png");
- LeftClick();
- return;
- }
- if (EmguBool(screenshot, "capsules.png", out Point capsules))
- {
- MouseMove(capsules.X, capsules.Y);
- Console.WriteLine("capsules.png");
- LeftClick();
- return;
- }
- disenchantChampionShards();
- }
- public static void disenchantChampionShards()
- {
- var screenshot = EmguCv.QueryFrame();
- if (EmguBool(screenshot, "disenchant.png", out Point disenchant))
- {
- MouseMove(disenchant.X, disenchant.Y);
- Console.WriteLine("disenchant.png");
- LeftClick();
- return;
- }
- if (EmguBool(screenshot, "disenchant_into.png", out Point disenchant_into))
- {
- MouseMove(disenchant_into.X, disenchant_into.Y);
- Console.WriteLine("disenchant_into.png");
- LeftClick();
- return;
- }
- if (EmguBool(screenshot, "champions.png", out Point champions))
- {
- if (EmguBool(screenshot, "skins.png", out Point skins) || !EmguBool(screenshot, "skins.png", out Point skins2))
- {
- if (skins.Y - champions.Y > 70 || skins == Point.Empty)
- {
- MouseMove(champions.X + 40, champions.Y + 70);
- Console.WriteLine("skinshard.png");
- LeftClick();
- return;
- }
- if (skins.Y - champions.Y < 70)
- {
- Console.WriteLine("finish");
- Console.ReadKey();
- }
- return;
- }
- return;
- }
- Console.WriteLine("finish");
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement