예제 #1
0
        private void ShowFrame(Filters.Frame frame)
        {
            using (var g = Graphics.FromImage(frame.Bitmap))
            {
                var white = new System.Drawing.Pen(System.Drawing.Color.White, 1);
                var black = new System.Drawing.Pen(System.Drawing.Color.Black, 1);

                if (FrameData.ContainsKey(frame.FrameIndex))
                {
                    FrameData[frame.FrameIndex].Select(p => p.Value).ToList().ForEach(p =>
                    {
                        if (p != null)
                        {
                            g.DrawEllipse(white, new RectangleF(p.Value.ToWindowsPoint().ToPointF(), new SizeF(1, 1)));
                            g.DrawEllipse(black, new RectangleF(p.Value.ToWindowsPoint().Moved(-1, -1).ToPointF(), new SizeF(3, 3)));
                        }
                    });
                }
            }


            if (canvasImage == null)
            {
                canvasImage        = new WriteableBitmap(frame.Width, frame.Height, 96, 96, PixelFormats.Bgr24, null);
                videoCanvas.Source = canvasImage;
            }

            frame.CopyToWriteableBitmap(canvasImage);

            videoCanvas_MouseMove(this, null);

            lblTime.Content           = currentFrame.FrameTime.ToString(@"mm\:ss") + " (" + currentFrame.FrameIndex + ")";
            _sliderValueChangedByCode = true;
            sliderTime.Value          = currentFrame.FrameIndex;
        }
        public void RefreshMostRecentFrame()
        {
            if (mostRecentFrame == null)
            {
                return;
            }

            //Prepare the temp frame for annotations
            if (tempFrame == null || !tempFrame.SameSizeAs(mostRecentFrame))
            {
                tempFrame = mostRecentFrame.Clone();
            }
            else
            {
                tempFrame.DrawFrame(mostRecentFrame);
            }

            tempFrame.FrameIndex      = mostRecentFrame.FrameIndex;
            tempFrame.ProcessorResult = mostRecentFrame.ProcessorResult;

            if (OnRefreshMostRecentFrame != null)
            {
                OnRefreshMostRecentFrame(tempFrame);
            }

            tempFrame.CopyToWriteableBitmap(canvasBuffer);
        }
예제 #3
0
        internal void Show(EfficientTipAndPERdetector.TipAndPERResult processorResult)
        {
            var width  = (int)image.Width;
            var height = (int)image.Height;

            //Create WriteableBitmap the first time
            if (canvasBuffer == null)
            {
                clearFrame = new Frame(width, height);

                canvasBuffer = new WriteableBitmap(width, height, 96, 96, PixelFormats.Bgr24, null);
                image.Source = canvasBuffer;
            }

            using (var gfx = Graphics.FromImage(clearFrame.Bitmap))
            {
                gfx.Clear(Color.White);
            }

            if (processorResult?.Left?.SectorCounts != null)
            {
                clearFrame.MarkSectors(
                    sectors: processorResult.Left.SectorCounts,
                    headCtrX: width / 2,
                    headCtrY: height / 2,
                    headHeight: height / 2,
                    headAngle: 0,
                    color: Color.Black,
                    isRight: false
                    );

                leftDomSec.Content  = processorResult.Left.DominantSector;
                leftSecMode.Content = processorResult.Left.TopAngle + "°";
            }
            else
            {
                leftDomSec.Content  = "-";
                leftSecMode.Content = "-";
            }



            if (processorResult?.Right?.SectorCounts != null)
            {
                clearFrame.MarkSectors(
                    sectors: processorResult.Right.SectorCounts,
                    headCtrX: width / 2,
                    headCtrY: height / 2,
                    headHeight: height / 2,
                    headAngle: 0,
                    color: Color.Black,
                    isRight: true
                    );

                rightDomSec.Content  = processorResult.Right.DominantSector;
                rightSecMode.Content = processorResult.Right.TopAngle + "°";
            }
            else
            {
                rightDomSec.Content  = "-";
                rightSecMode.Content = "-";
            }

            clearFrame.CopyToWriteableBitmap(canvasBuffer);
        }