public Mat GetBufferBgrSingle(Size size, int index) { if (_bgrSingleBuffers == null) { _bgrSingleBuffers = new ImageBufferFactory <Mat>(s => new Mat(s.Height, s.Width, DepthType.Cv8U, 3)); } return(_bgrSingleBuffers.GetBuffer(size, index)); }
public Mat GetBufferGray(Size size, int index) { if (_grayBuffers == null) { _grayBuffers = new ImageBufferFactory <Mat>(s => new Mat(s.Height, s.Width, DepthType.Cv8U, 1)); } return(_grayBuffers.GetBuffer(size, index)); }
protected override void OnDraw(Android.Graphics.Canvas canvas) { base.OnDraw(canvas); lock (this) { Image <Bgr, byte> image = _bgrBuffers.GetBuffer(0); if (image != null && !_imageSize.IsEmpty && canvas != null) { Stopwatch w = Stopwatch.StartNew(); if ((_bmpImage != null) && (!_imageSize.Equals(_bmpImage.Size))) { _bmpImage.Dispose(); _bmpImage = null; _bmp.Dispose(); _bmp = null; } if (_bmpImage == null) { _bmp = Android.Graphics.Bitmap.CreateBitmap(_imageSize.Width, _imageSize.Height, Android.Graphics.Bitmap.Config.Rgb565); _bmpImage = new BitmapRgb565Image(_bmp); } _bmpImage.ConvertFrom(image); canvas.DrawBitmap(_bmp, 0, 0, _paint); w.Stop(); _watch.Stop(); #if DEBUG canvas.DrawText(String.Format("{0:F2} FPS; {1}x{2}; Render Time: {3} ms", 1.0 / _watch.ElapsedMilliseconds * 1000, _imageSize.Width, _imageSize.Height, w.ElapsedMilliseconds), 20, 20, _paint); #endif _watch.Reset(); _watch.Start(); } } }