// new frame protected void OnNewFrame(Bitmap image) { evt = new CameraEventArgs(image); //framesReceived++; if ((!stopEvent.WaitOne(0, true)) && (NewFrame != null)) { NewFrame(this, evt); } }
void source_NewFrame(object sender, CameraEventArgs e) { if (!bgGround) { // lock Monitor.Enter(this); // dispose old frame if (newFrame != null) { newFrame.Dispose(); } //frame laden newFrame = (Bitmap)e.Bitmap.Clone(); //background bijstellen indien nodig if (!bgGround) { if (frames++ < aFrames) bgFrame.EditBackground(newFrame, false); else { bgFrame.EditBackground(newFrame, true); bgGround = bgFrame.BackgroundCheck(); if (bgGround) background = newFrame; } } // unlock Monitor.Exit(this); } else //background is gemaakt, nu de frame doorsturen if (frame != null) frame((Bitmap)e.Bitmap.Clone()); }
// On new frame private void video_NewFrame( object sender, CameraEventArgs e ) { try { // lock Monitor.Enter( this ); // dispose old frame if ( lastFrame != null ) { lastFrame.Dispose( ); } lastFrame = (Bitmap) e.Bitmap.Clone( ); // apply motion detector if ( motionDetecotor != null ) { motionDetecotor.ProcessFrame( ref lastFrame ); // check motion level if ( ( motionDetecotor.MotionLevel >= alarmLevel ) && ( Alarm != null ) ) { Alarm( this, new EventArgs( ) ); } } // image dimension width = lastFrame.Width; height = lastFrame.Height; } catch ( Exception ) { } finally { // unlock Monitor.Exit( this ); } // notify client if ( NewFrame != null ) NewFrame( this, new EventArgs( ) ); }
// On new frame private void video_NewFrame( object sender, CameraEventArgs e ) { try { // lock Monitor.Enter( this ); // dispose old frame if ( lastFrame != null ) { lastFrame.Dispose( ); } lastFrame = (Bitmap) e.Bitmap.Clone( ); // image dimension width = lastFrame.Width; height = lastFrame.Height; } catch ( Exception ) { } finally { // unlock Monitor.Exit( this ); } // notify client if ( NewFrame != null ) NewFrame( this, new EventArgs( ) ); }