Beispiel #1
0
        static void MonitorScreenshotsByAdb()
        {
            var outDir = @"t:\Data\Gumball\Screenshots";
            var device = "emulator-5554";

            //using (var client = new AdbClient("emulator-5554"))
            if (true)
            {
                var hashes = new Dictionary <Shipwreck.Phash.Digest, int>(new DigestComparer());
                Shipwreck.Phash.Digest prevHash = null;

                for (var i = 0; ; i++)
                {
                    var screenshot = AdbScreenCapture(device);

                    var hash = ComputeDigest(screenshot);
                    //var isOther = prevHash == null || Shipwreck.Phash.ImagePhash.GetCrossCorrelation(prevHash, hash) < 1;
                    var isOther = prevHash == null || hashes.Keys.All(_hash => ImagePhash.GetCrossCorrelation(_hash, hash) < 1);
                    if (isOther)
                    {
                        screenshot.Save(System.IO.Path.Combine(outDir, $"{DateTime.UtcNow:yyMMdd.HHmmss}.png"));
                    }
                    //System.IO.File.WriteAllBytes(System.IO.Path.Combine(outDir, $"{DateTime.UtcNow:yyMMdd.HHmmss}.png"), stream.ToArray());
                    Console.WriteLine($"{i:d4} {hash} - {(isOther ? "saved" : "skipped")}");
                    prevHash     = hash;
                    hashes[hash] = (hashes.ContainsKey(hash) ? hashes[hash] : 0) + 1;

                    System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.1));
                }
            }
        }
Beispiel #2
0
        static void MonitorScreenshots()
        {
            var outDir = @"t:\Data\Gumball\Screenshots";


            var vm_title = "BlueStacks";

            var handle = DirectGamer.FindWindow(null, vm_title);

            if (handle == IntPtr.Zero)
            {
                throw new Exception("Окно не найдено");
            }

            DirectGamer.RECT rect;
            DirectGamer.GetWindowRect(handle, out rect);
            Console.WriteLine($"{rect.Right - rect.Left} {rect.Bottom - rect.Top}");

            var hashes = new Dictionary <Shipwreck.Phash.Digest, int>(new DigestComparer());

            Shipwreck.Phash.Digest prevHash = null;

            for (var i = 0; ; i++)
            {
                var screenshot = DirectGamer.GetScreenImage(new System.Drawing.Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top));

                var hash = ComputeDigest(screenshot);
                //var isOther = prevHash == null || Shipwreck.Phash.ImagePhash.GetCrossCorrelation(prevHash, hash) < 1;
                var isOther = prevHash == null || hashes.Keys.All(_hash => ImagePhash.GetCrossCorrelation(_hash, hash) < 1);
                if (isOther)
                {
                    screenshot.Save(System.IO.Path.Combine(outDir, $"{DateTime.UtcNow:yyMMdd.HHmmss}.png"));
                }
                //System.IO.File.WriteAllBytes(System.IO.Path.Combine(outDir, $"{DateTime.UtcNow:yyMMdd.HHmmss}.png"), stream.ToArray());
                Console.WriteLine($"{i:d4} {hash} - {(isOther ? "saved" : "skipped")}");
                prevHash     = hash;
                hashes[hash] = (hashes.ContainsKey(hash) ? hashes[hash] : 0) + 1;

                System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.1));
            }
        }
Beispiel #3
0
 /// <summary>
 /// cross correlation for 2 series. Compute the cross correlation of two series vectors
 /// </summary>
 /// <param name="x">Digest struct</param>
 /// <param name="y">Digest struct</param>
 /// <returns>double value the peak of cross correlation</returns>
 public static float GetCrossCorrelation(Digest x, Digest y)
 => GetCrossCorrelation(x.Coefficients, y.Coefficients);
Beispiel #4
0
 /// <summary>
 /// cross correlation for 2 series. Compute the cross correlation of two series vectors
 /// </summary>
 /// <param name="x">Digest struct</param>
 /// <param name="y">Digest struct</param>
 /// <returns>double value the peak of cross correlation</returns>
 public static double GetCrossCorrelation(Digest x, Digest y)
 => GetCrossCorrelation(x.Coefficents, y.Coefficents);