예제 #1
0
        /// <summary>
        /// Captures the Killmessage and cleans it. Triggers OBS source based on the string information.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Worker_KillMessageCleaner_DoWork(object sender, DoWorkEventArgs e)
        {
            //Get 20 Killmessages or at least as long as kill is active.
            List <Bitmap> killmessages     = new List <Bitmap>();
            int           i                = 0;
            var           myUniqueFileName = $@"{DateTime.Now.Ticks}";

            while (!Worker_KillMessageCleaner.CancellationPending && i < 20)
            {
                Bitmap KillMessage = gcaptr.MakeScreenShot(rectKillMessage);
                killmessages.Add(KillMessage);
                i++;
                Thread.Sleep(10);
            }

            //Clean KillMessage
            Bitmap CleanedKillMessage = helpers.MakeDarkestImage(killmessages, whiteReference);

            CleanedKillMessage.Save(@"./learning/KillMessages/" + myUniqueFileName + ".bmp");

            String OCRResult = helpers.OCRText(CleanedKillMessage);

            Worker_KillMessageCleaner.ReportProgress(0, OCRResult);
            e.Result = CleanedKillMessage;
        }
예제 #2
0
        /// <summary>
        /// Captures the Killmessage and cleans it. Triggers OBS source based on the string information.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Worker_KillMessageCleaner_DoWork(object sender, DoWorkEventArgs e)
        {
            //Acquire 30 Killmessages over 150ms.
            List <Bitmap> killmessages     = new List <Bitmap>();
            int           i                = 0;
            var           myUniqueFileName = $@"{DateTime.Now.Ticks}";

            while (!Worker_KillMessageCleaner.CancellationPending && i < 30)
            {
                Bitmap KillMessage = gcaptr.MakeScreenShot(rectKillMessage);
                killmessages.Add(KillMessage);
                i++;
                Thread.Sleep(5);
            }

            //Clean KillMessage
            Bitmap CleanedKillMessage = helpers.MakeDarkestImage(killmessages, whiteReference);

            //Save it for later improving the OCR
            CleanedKillMessage.Save(@"./learning/KillMessages/" + myUniqueFileName + ".bmp");

            String OCRResult = helpers.OCRText(CleanedKillMessage);

            Worker_KillMessageCleaner.ReportProgress(0, OCRResult);
            e.Result = CleanedKillMessage;
        }
예제 #3
0
        /// <summary>
        /// Start Button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnStart_Click(object sender, EventArgs e)
        {
            if (!Scanner_RedKill.IsBusy)
            {
                PeopleAlive     = 0;
                KillCount       = 0;
                tsLblAlive.Text = "Alive: 0";
                tsLblAlive.Text = "Kills: 0";

                WriteToLog("Scanning for kills...");
                btnStart.Text = "Stop";
                Scanner_RedKill.RunWorkerAsync();
                btnStart.BackColor          = Color.PaleVioletRed;
                toolStripProgressBar1.Style = ProgressBarStyle.Marquee;
                toolStripProgressBar1.MarqueeAnimationSpeed = 100;
            }
            else
            {
                WriteToLog("Stopped scanning for kills...");
                btnStart.Text = "Start";

                Scanner_RedKill.CancelAsync();
                Scanner_KillNumber.CancelAsync();
                Worker_KillMessageCleaner.CancelAsync();


                btnStart.BackColor = Color.LightGreen;

                toolStripProgressBar1.MarqueeAnimationSpeed = 0;
                toolStripProgressBar1.Style = ProgressBarStyle.Blocks;
                toolStripProgressBar1.Value = toolStripProgressBar1.Minimum;
            }
        }
예제 #4
0
        /// <summary>
        /// Progress of TopKillScanner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scanner_KillNumber_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            //If new KillNumber is bigger than the current Killcount and not bigger than the current Killcount+6, accept it as valid.
            if (e.ProgressPercentage > KillCount && e.ProgressPercentage < KillCount + 20)
            {
                KillCount = e.ProgressPercentage;
                WriteToLog("New Kill detected!" + e.ProgressPercentage);

                //Wait for KillMessageCleaner to end and start it again.
                while (Worker_KillMessageCleaner.IsBusy)
                {
                    Worker_KillMessageCleaner.CancelAsync();
                }
                Worker_KillMessageCleaner.RunWorkerAsync();

                tsLblKills.Text = "Kills: " + e.ProgressPercentage.ToString();
            }
        }