Exemplo n.º 1
0
        void camera_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs)
        {
            globFrameCount++;
            DateTime   captureTime = DateTime.Now;
            Bitmap     frame       = eventArgs.Frame;
            BitmapData bmpData     = frame.LockBits(new Rectangle(0, 0, frame.Width, frame.Height), ImageLockMode.ReadWrite,
                                                    frame.PixelFormat);
            Image <Bgr, byte> image = new Image <Bgr, byte>(frame.Width, frame.Height, bmpData.Stride, bmpData.Scan0);
            //to prevent any corrupted memory errors that crop up for some reason
            Image <Bgr, byte> image2 = image.Clone();

            //dispose all unused image data to prevent memory leaks
            image.Dispose();
            frame.UnlockBits(bmpData);
            frame.Dispose();
            eventArgs.Frame.Dispose();
            CapturedImage capturedImage = new CapturedImage(image2, captureTime);

            MostRecentImage = capturedImage;
            _logic.UpdateAndPredictNotes(capturedImage);
            TimeSpan timeElapsed = DateTime.Now - captureTime;

            if (timeElapsed.TotalMilliseconds > 45)
            {
                Debug.WriteLine("WARNING: Capture took {0} ms.", timeElapsed.TotalMilliseconds);
            }
            ImageQueue.Enqueue(capturedImage);
        }
Exemplo n.º 2
0
        private void ReloadTracks()
        {
            logic.CurrentNotes.Clear();
            if (firstImage != null)
            {
                firstImage.Dispose();
            }
            if (secondImage != null)
            {
                secondImage.Dispose();
            }

            firstImage  = new CapturedImage(new Image <Bgr, byte>(@"D:\drumbot\panic attack partial\" + "000475.bmp"), DateTime.Now);
            secondImage = new CapturedImage(new Image <Bgr, byte>(@"D:\drumbot\panic attack partial\" + "000476.bmp"),
                                            firstImage.CaptureTime.AddMilliseconds(40));
            MostRecentImage = firstImage;
            logic.UpdateAndPredictNotes(MostRecentImage);
            MostRecentImage = secondImage;
            logic.UpdateAndPredictNotes(MostRecentImage);
            DrawBigPicture();
        }
Exemplo n.º 3
0
        private void ReloadTracks()
        {
            _fakeOutput.ResetHitIndicators();
            logic.CurrentNotes.Clear();
            if (previousImage != null)
            {
                previousImage.Dispose();
            }
            if (currentImage != null)
            {
                currentImage.Dispose();
            }



            previousImage   = new CapturedImage(new Image <Bgr, byte>(_imageFileList[0]), DateTime.Now);
            currentImage    = new CapturedImage(new Image <Bgr, byte>(_imageFileList[1]), previousImage.CaptureTime.AddMilliseconds(40));
            nextImageIndex  = 2;
            MostRecentImage = previousImage;
            logic.UpdateAndPredictNotes(MostRecentImage);
            MostRecentImage = currentImage;
            logic.UpdateAndPredictNotes(MostRecentImage);
            DrawBigPicture();
            if (_fakeOutput.RedHit)
            {
                redButton.BackColor = Color.Red;
            }
            else
            {
                redButton.BackColor = Color.Gray;
            }
            if (_fakeOutput.YellowHit)
            {
                yellowButton.BackColor = Color.Yellow;
            }
            else
            {
                yellowButton.BackColor = Color.Gray;
            }
            if (_fakeOutput.BlueHit)
            {
                blueButton.BackColor = Color.Blue;
            }
            else
            {
                blueButton.BackColor = Color.Gray;
            }
            if (_fakeOutput.GreenHit)
            {
                greenButton.BackColor = Color.LawnGreen;
            }
            else
            {
                greenButton.BackColor = Color.Gray;
            }
            if (_fakeOutput.OrangeHit)
            {
                orangeButton.BackColor = Color.Orange;
            }
            else
            {
                orangeButton.BackColor = Color.Gray;
            }
        }