이미지 파일 출력

remotes/origin/master
syneffort 3 years ago
parent 352e3c2235
commit 397bae85a7
  1. 21
      OpenCV/Form1.Designer.cs
  2. 30
      OpenCV/Form1.cs
  3. 3
      OpenCV/Form1.resx

@ -29,10 +29,7 @@ namespace OpenCV
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.pictureBoxIpl1 = new OpenCvSharp.UserInterface.PictureBoxIpl();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label1 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxIpl1)).BeginInit();
this.SuspendLayout();
//
@ -45,26 +42,11 @@ namespace OpenCV
this.pictureBoxIpl1.TabIndex = 0;
this.pictureBoxIpl1.TabStop = false;
//
// timer1
//
this.timer1.Interval = 33;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(20, 20);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(38, 12);
this.label1.TabIndex = 1;
this.label1.Text = "label1";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(662, 503);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBoxIpl1);
this.Name = "Form1";
this.Text = "Form1";
@ -72,15 +54,12 @@ namespace OpenCV
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxIpl1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private OpenCvSharp.UserInterface.PictureBoxIpl pictureBoxIpl1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label label1;
}
}

@ -6,11 +6,9 @@ namespace OpenCV
{
public partial class Form1 : Form
{
CvCapture capture;
IplImage src;
string filePath;
int frameCount = 0;
string fileName;
public Form1()
{
@ -33,37 +31,19 @@ namespace OpenCV
{
try
{
//capture = CvCapture.FromCamera(CaptureDevice.DShow, 0);
//capture.SetCaptureProperty(CaptureProperty.FrameWidth, 640);
//capture.SetCaptureProperty(CaptureProperty.FrameHeight, 480);
filePath = FindFileName();
if (String.IsNullOrEmpty(filePath))
fileName = FindFileName();
if (String.IsNullOrEmpty(fileName))
return;
capture = CvCapture.FromFile(filePath);
timer1.Enabled = true;
src = new IplImage(fileName);
pictureBoxIpl1.ImageIpl = src;
}
catch (Exception ex)
{
timer1.Enabled = false;
MessageBox.Show(ex.Message);
}
}
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;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Cv.ReleaseImage(src);

@ -117,7 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
Loading…
Cancel
Save