동영상 파일 출력
This commit is contained in:
@@ -9,19 +9,39 @@ namespace OpenCV
|
||||
CvCapture capture;
|
||||
IplImage src;
|
||||
|
||||
string filePath;
|
||||
int frameCount = 0;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private string FindFileName()
|
||||
{
|
||||
string path = "";
|
||||
|
||||
OpenFileDialog dialog = new OpenFileDialog();
|
||||
DialogResult dialogResult = dialog.ShowDialog();
|
||||
if (dialogResult == DialogResult.OK)
|
||||
path = dialog.FileName;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
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);
|
||||
//capture = CvCapture.FromCamera(CaptureDevice.DShow, 0);
|
||||
//capture.SetCaptureProperty(CaptureProperty.FrameWidth, 640);
|
||||
//capture.SetCaptureProperty(CaptureProperty.FrameHeight, 480);
|
||||
filePath = FindFileName();
|
||||
if (String.IsNullOrEmpty(filePath))
|
||||
return;
|
||||
|
||||
capture = CvCapture.FromFile(filePath);
|
||||
timer1.Enabled = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -32,7 +52,15 @@ namespace OpenCV
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
frameCount++;
|
||||
label1.Text = $"Frame: {frameCount} / {capture.FrameCount}";
|
||||
src = capture.QueryFrame();
|
||||
if (frameCount == capture.FrameCount)
|
||||
{
|
||||
frameCount = 0;
|
||||
capture = CvCapture.FromFile(filePath);
|
||||
}
|
||||
|
||||
pictureBoxIpl1.ImageIpl = src;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user