예제 #1
0
 private void Processor_ClearScreen(object sender, VideoProcessor.ClearScreenEventArgs e)
 {
     if (Properties.Settings.Default.WarpWorldEnabled)
     {
         WarpWorld?.win();
     }
     SMMServer.BroadcastDataEvent("clear", e.clearTime);
     // TODO: Send WR/First Clear here also since we have that in the event
 }
예제 #2
0
        /// <summary>
        /// Event callback for the Clear Screen event generatead by the VideoProcessor
        /// </summary>
        private void VideoProcessor_ClearScreen(object sender, VideoProcessor.ClearScreenEventArgs e)
        {
            log.Debug("Detected Level Clear");

            Image <Gray, byte> grayscaleFrame = e.currentFrame.Mat.ToImage <Gray, byte>().Resize(640, 480, Inter.Cubic);
            //e.currentFrame.Save("clearmatch_" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".png");

            Dictionary <String, bool> events = new Dictionary <String, bool>
            {
                { "worldrecord", false },
                { "firstclear", false },
            };
            List <Rectangle> boundaries = new List <Rectangle>();

            foreach (EventTemplate tmpl in clearTemplates)
            {
                if (events[tmpl.eventType])
                {
                    continue;
                }
                Point loc = tmpl.getLocation(grayscaleFrame);
                if (!loc.IsEmpty)
                {
                    events[tmpl.eventType] = true;
                    boundaries.Add(ImageLibrary.ChangeSize(new Rectangle(loc.X, loc.Y, tmpl.template.Width, tmpl.template.Height), grayscaleFrame.Size, e.currentFrame.Size));
                    previewer.SetLastMatch(e.currentFrame, boundaries.ToArray());
                }
            }

            foreach (var evt in events)
            {
                if (evt.Value)
                {
                    log.Info(String.Format("Detected {0}.", evt.Key));
                    SMMServer.BroadcastEvent(evt.Key);
                }
            }

            if (Properties.Settings.Default.WarpWorldEnabled)
            {
                WarpWorld?.win();
            }

            // Read time from screen
            string clearTime = OCRLibrary.GetClearTimeFromFrame(e.currentFrame, e.commentsEnabled);

            SMMServer.BroadcastDataEvent("clear", clearTime);
        }