1. To draw video on PictureBox you need to add control to the form. Set BackColor property to Black and SizeMode property to StretchImage.
2. Add bool class member called applyingPictureBoxImage. On Start button code set applyingPictureBoxImage to false before starting capture or playback.
3. Implement OnVideoFrameBitmap event to draw frame.
private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { if (applyingPictureBoxImage) { return; } applyingPictureBoxImage = true; var image = pictureBox1.Image; pictureBox1.Image = new Bitmap(e.Frame); image?.Dispose(); applyingPictureBoxImage = false; }
4. Add PictureBox clearing to Stop button code. Code should be called after SDK control Stop method call.
while (applyingPictureBoxImage) { Thread.Sleep(50); } pictureBox1.Image?.Dispose(); pictureBox1.Image = null;