Last active
November 15, 2020 17:21
-
-
Save elbruno/a29fa7479b323e8cc996a6568801c7b9 to your computer and use it in GitHub Desktop.
net5opencvtakephoto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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