示例#1
0
 /// <summary>
 /// Handles the Click event of the Button3 control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
 private void Button3_Click(object sender, RoutedEventArgs e)
 {
     if (this.buffer1 != null && this.buffer2 != null)
     {
         double result = BitmapCompare.Compare(this.buffer1, this.buffer2);
         this.textBlock1.Text = result.ToString();
     }
 }
示例#2
0
        /// <summary>
        /// Pumps the preview frames.
        /// </summary>
        private void PumpPreviewFrames()
        {
            this.buffer1       = this.buffer1 ?? new byte[(int)this.camera.PreviewResolution.Width * (int)this.camera.PreviewResolution.Height];
            this.buffer2       = this.buffer2 ?? new byte[(int)this.camera.PreviewResolution.Width * (int)this.camera.PreviewResolution.Height];
            this.currentBuffer = this.buffer1;

            try
            {
                while (this.pumpPreviewFrames)
                {
                    this.camera.GetPreviewBufferY(this.currentBuffer);
                    double result = BitmapCompare.Compare(this.buffer1, this.buffer2);

                    this.Dispatcher.BeginInvoke(() =>
                    {
                        this.textBlock1.Text = result.ToString();
                        if (result < CompareDifferentPrecent)
                        {
                            this.ellipse1.Fill = new SolidColorBrush(Colors.Red);
                        }
                        else
                        {
                            this.ellipse1.Fill = new SolidColorBrush(Colors.Green);
                        }
                    });

                    this.currentBuffer = (this.currentBuffer == this.buffer1) ? this.buffer2 : this.buffer1;

                    Thread.Sleep(500);
                }
            }
            catch (Exception e)
            {
                this.Dispatcher.BeginInvoke(() =>
                {
                    this.textBlock1.Text = e.Message;
                });
            }
        }