當前位置: 首頁>>代碼示例>>C#>>正文


C# Image.AddWeighted方法代碼示例

本文整理匯總了C#中System.Drawing.Image.AddWeighted方法的典型用法代碼示例。如果您正苦於以下問題:C# Image.AddWeighted方法的具體用法?C# Image.AddWeighted怎麽用?C# Image.AddWeighted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.Image的用法示例。


在下文中一共展示了Image.AddWeighted方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PreProcess

        public override IDataContainer PreProcess(IDataContainer dataContainer)
        {
            _debugOutputImage = new Image<Rgb, byte>(Width, Height);

            var rgbImage = dataContainer.OfType<RgbImageData>().ToArray();

            if (!rgbImage.Any()) return null;

            _debugOutputImage += rgbImage.First().Image.Copy();

            var devices = dataContainer.OfType<Device>().ToArray();
            //var unknownDevices = dataContainer.OfType<Device>().Where(d => !d.IsIdentified).ToArray();
            var hands = dataContainer.OfType<Hand>().ToArray();

            foreach (var device in devices)
            {
                var polyline = new List<Point>();
                foreach (var point in device.Shape.Points)
                {
                    var x = point.X * Width;
                    var y = point.Y * Height;

                    polyline.Add(new Point((int)x, (int)y));
                }

                var centerX = (int)(device.SmoothedCenter.X / 320 * Width);
                var centerY = (int)(device.SmoothedCenter.Y / 240 * Height);

                _debugOutputImage.DrawPolyline(polyline.ToArray(), true, device.IsIdentified ? Rgbs.Red : Rgbs.White, 5);

                if (device.IsIdentified)
                    _debugOutputImage.Draw(string.Format("Id {0}", device.DeviceId), ref EmguFontBig, new Point(centerX, centerY), Rgbs.Red);
            }

            foreach (var hand in hands)
            {
                var resizedHandSegment = hand.Segment.Resize(_debugOutputImage.Width, _debugOutputImage.Height, INTER.CV_INTER_CUBIC).Mul(255);

                //_debugOutputImage = _debugOutputImage.Copy(resizedHandSegment.Not());
                _debugOutputImage = _debugOutputImage.AddWeighted(resizedHandSegment.Convert<Rgb, byte>(), 1.0, 0.5, 0.0);

                resizedHandSegment.Dispose();

                var point = new Point((int)(hand.RelativeCenter.X * Width), (int)(hand.RelativeCenter.Y * Height));
                var labelPoint = new Point((int)(hand.RelativeCenter.X * Width + 30), (int)(hand.RelativeCenter.Y * Height));

                _debugOutputImage.Draw(new CircleF(point, 10), Rgbs.Red, 6);
                _debugOutputImage.Draw(string.Format("Id {0} (d={1:F0})", hand.Id, hand.Depth), ref EmguFontBig, labelPoint, Rgbs.Red);
            }

            var debugOutputImageCopy = _debugOutputImage.Copy();
            Task.Factory.StartNew(() =>
            {
                var bitmapSource = debugOutputImageCopy.ToBitmapSource(true);
                debugOutputImageCopy.Dispose();
                return bitmapSource;
            }).ContinueWith(t => DebugOutputBitmapSource = t.Result);

            Stage(new RgbImageData(this, "DataRenderer", _debugOutputImage.Copy()));

            if (_videoWriter != null)
                _videoWriter.WriteFrame(_debugOutputImage.Convert<Bgr, byte>());

            _debugOutputImage.Dispose();

            Push();

            return base.PreProcess(dataContainer);
        }
開發者ID:AlternateIf,項目名稱:huddle-engine,代碼行數:69,代碼來源:DataRenderer.cs


注:本文中的System.Drawing.Image.AddWeighted方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。