0
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.Util;
namespace ImageCapture
{
public partial class Form1 : Form
{
private Capture capture;
private bool captureInProgress;
public Form1()
{
private void ProcessFrame(object sender, EventArgs arg)
{
Image<Bgr, Byte> ImageFrame = capture.QueryFrame();
CamImageBox.Image = ImageFrame;
}
private void strat_Click(object sender, EventArgs e)
{
#region if capture is not created, create it now
if (capture == null)
{
try
{
capture = new Capture();
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
#endregion
if (capture != null)
{
if (captureInProgress)
{
btnStart.Text = "Start!";
Application.Idle -= ProcessFrame;
}
else
{
btnStart.Text = "Stop";
Application.Idle += ProcessFrame;
}
captureInProgress = !captureInProgress;
}
}
private void ReleaseData()
{
if (capture != null)
capture.Dispose();
}
}
}
}
이 코드는 카메라를 통해 그림을 캡처 할 수 없도록하는 "형식 또는 네임 스페이스 정의 또는 예상 파일 끝내기"오류를 실행하지 않습니다. 이 코드는 opencv를 사용하는 C# windows 응용 프로그램으로 작성되었습니다.형식 또는 네임 스페이스 정의 또는 파일 끝이 예상 됨
귀하의 생성자를 ('를 Form1()가 ...'공공) 닫는 중괄호가 없습니다, 당신은 너무 많은 일이 파일의 끝에있는 중괄호를 닫습니다. –
돌아가서 코드를 들여 쓰면 문제가 발생할 가능성이 높습니다. –
@ Saba-Ch는 항상 코드를 들여 쓰기 때문에 중괄호를 열고 닫는 데 실수를해서는 안됩니다. 대부분의 편집기 (Visual Studio 포함)에는 사용할 수있는 자동 서식 지정 기능이 있습니다. –