카메라 출력
This commit is contained in:
46
OpenCV/Form1.cs
Normal file
46
OpenCV/Form1.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace OpenCV
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
CvCapture capture;
|
||||
IplImage src;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
capture = CvCapture.FromCamera(CaptureDevice.DShow, 0);
|
||||
capture.SetCaptureProperty(CaptureProperty.FrameWidth, 640);
|
||||
capture.SetCaptureProperty(CaptureProperty.FrameHeight, 480);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
timer1.Enabled = false;
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
src = capture.QueryFrame();
|
||||
pictureBoxIpl1.ImageIpl = src;
|
||||
}
|
||||
|
||||
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
Cv.ReleaseImage(src);
|
||||
if (src != null)
|
||||
src.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user