Skip to content

Instantly share code, notes, and snippets.

@elbruno
Last active November 15, 2020 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbruno/a29fa7479b323e8cc996a6568801c7b9 to your computer and use it in GitHub Desktop.
Save elbruno/a29fa7479b323e8cc996a6568801c7b9 to your computer and use it in GitHub Desktop.
net5opencvtakephoto.cs
using System;
using System.Windows.Forms;
using OpenCvSharp;
namespace Demo03_WinForm
{
public partial class Form1 : Form
{
private VideoCapture _capture;
private Mat _image;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
_capture = new VideoCapture(0);
_image = new Mat();
}
private void button1_Click(object sender, EventArgs e)
{
_capture.Read(_image);
if (_image.Empty()) return;
pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(_image);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment