private void QueryRawFrame() { byte[] image = camera.CaptureImageBytes(); MemoryStream memStream = new MemoryStream(image); Bitmap bmp = null; try { bmp = (Bitmap)Image.FromStream(memStream); } catch (System.ArgumentException)//图片格式出错 { return; } Frame f = new Frame(); f.timeStamp = DateTime.Now.Ticks; f.image = IntPtr.Zero; f.cameraID = 2; IplImage ipl = BitmapConverter.ToIplImage(bmp); ipl.IsEnabledDispose = false; f.image = ipl.CvPtr; lock (this.rawFrameLocker) rawFrames.Enqueue(f); goDetectMotion.Set(); }
private void QueryRawFrame() { if (this.cpuOverLoaded()) { return; } byte[] image = null; lock (this.camLocker) { image = camera.CaptureImageBytes(); } MemoryStream memStream = new MemoryStream(image); Bitmap bmp = null; try { bmp = (Bitmap)Image.FromStream(memStream); } catch (System.ArgumentException)//图片格式出错 { MessageBox.Show("获取摄像头图片错误"); return; } if (ImageCaptured != null) { ImageCapturedEventArgs args = new ImageCapturedEventArgs() { ImageCaptured = bmp }; ImageCaptured(this, args); } Frame f = new Frame(); f.timeStamp = DateTime.Now.Ticks; f.cameraID = 2; IplImage ipl = BitmapConverter.ToIplImage(bmp); ipl.IsEnabledDispose = false; f.image = ipl; lock (this.rawFrameLocker) rawFrames.Enqueue(f); goDetectMotion.Set(); }