private bool SetImageLocal(Tesseract ocr, IInputArray image) { var success = true; ImageLock.EnterReadLock(); try { ocr.SetImage(image); } catch { success = false; } finally { ImageLock.ExitReadLock(); } return(success); }
public bool SetImageGlobal(Image <Bgra, byte> image) { var success = true; ImageLock.EnterWriteLock(); try { ImageCv = image; } catch { success = false; } finally { ImageLock.ExitWriteLock(); } return(success); }
public ImageData Lock(Rectangle lockRectangle, ImageLock lockType) { IWICBitmapLock imageLock; WICBitmapLockFlags flags; var rect = new WICRect { X = lockRectangle.X, Y = lockRectangle.Y, Width = lockRectangle.Width, Height = lockRectangle.Height }; switch(lockType) { case ImageLock.Read: flags = WICBitmapLockFlags.WICBitmapLockRead; break; case ImageLock.Write: flags = WICBitmapLockFlags.WICBitmapLockWrite; break; case ImageLock.ReadWrite: flags = WICBitmapLockFlags.WICBitmapLockRead | WICBitmapLockFlags.WICBitmapLockWrite; break; default: throw new ArgumentOutOfRangeException("lockType"); } int hr = m_internalBitmap.Lock(ref rect, flags, out imageLock); if (hr != 0) throw new Exception("Could not lock the image"); return new ImageData(imageLock); }
public ImageData Lock(ImageLock lockType) { return Lock(new Rectangle(0, 0, Width, Height), lockType); }