using System; using System.Collections.Generic; using System.Text; using System.ServiceModel; using Emgu.CV; using Emgu.CV.Structure; namespace Webservice_Host { [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] public class ImageService : IImageService, IDisposable { private Capture capture; private bool disposed = false; public ImageService() { this.capture = new Capture(); } ~ImageService() { Dispose(false); } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } public Image GrabFrame() { Image img = capture.QueryFrame(); return img; } protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { this.capture.Dispose(); this.capture = null; } disposed = true; } } } }