이미지 파일 출력

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> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container();
this.pictureBoxIpl1 = new OpenCvSharp.UserInterface.PictureBoxIpl(); 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(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxIpl1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -45,26 +42,11 @@ namespace OpenCV
this.pictureBoxIpl1.TabIndex = 0; this.pictureBoxIpl1.TabIndex = 0;
this.pictureBoxIpl1.TabStop = false; 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 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(662, 503); this.ClientSize = new System.Drawing.Size(662, 503);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBoxIpl1); this.Controls.Add(this.pictureBoxIpl1);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Form1"; this.Text = "Form1";
@ -72,15 +54,12 @@ namespace OpenCV
this.Load += new System.EventHandler(this.Form1_Load); this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxIpl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxIpl1)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
private OpenCvSharp.UserInterface.PictureBoxIpl pictureBoxIpl1; 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 public partial class Form1 : Form
{ {
CvCapture capture;
IplImage src; IplImage src;
string filePath; string fileName;
int frameCount = 0;
public Form1() public Form1()
{ {
@ -33,37 +31,19 @@ namespace OpenCV
{ {
try try
{ {
//capture = CvCapture.FromCamera(CaptureDevice.DShow, 0); fileName = FindFileName();
//capture.SetCaptureProperty(CaptureProperty.FrameWidth, 640); if (String.IsNullOrEmpty(fileName))
//capture.SetCaptureProperty(CaptureProperty.FrameHeight, 480);
filePath = FindFileName();
if (String.IsNullOrEmpty(filePath))
return; return;
capture = CvCapture.FromFile(filePath); src = new IplImage(fileName);
timer1.Enabled = true; pictureBoxIpl1.ImageIpl = src;
} }
catch (Exception ex) catch (Exception ex)
{ {
timer1.Enabled = false;
MessageBox.Show(ex.Message); 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) private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{ {
Cv.ReleaseImage(src); Cv.ReleaseImage(src);

@ -117,7 +117,4 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </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> </root>
Loading…
Cancel
Save