主題: C# 程式請教
瀏覽單個文章
bibo987
Power Member
 

加入日期: Nov 2016
文章: 617
C# 程式請教

最近在學寫C#,請教個弱弱的問題
我想按BUTTON1,執行另一個類別的邊緣偵測,把處理後的結果畫面
顯示在Form1的picturebox1.

目前我只能在類別mycv, 開一個新form2,
加入picturebox,顯示邊緣偵測結果
但這樣開新的form 使用上不靈活,想要在類別之間直接傳影像處理結果


namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
mycv test = new mycv();
test.edge();
}
}

public class mycv
{
public void edge()
{

Image<Bgr, Byte> scr1 = new Image<Bgr, Byte>(new Bitmap(@"D:\C# PROJECT\邊緣與輪廓\WindowsFormsApp1/pic01.jpg"));
Form form2 = new Form();
form2.Size = new Size(1400, 800);
form2.Show();

PictureBox image1 = new PictureBox();
image1.Size = new Size(500, 500);
image1.SizeMode = PictureBoxSizeMode.Zoom;
image1.Image = scr1.Bitmap;
form2.Controls.Add(image1);

PictureBox image2= new PictureBox();
image2.Location = new Point (600, 1);
image2.Size = new Size(500, 500);
image2.SizeMode = PictureBoxSizeMode.Normal;
image2.Image = scr1.Bitmap;
form2.Controls.Add(image2);

Mat dst = new Mat();
CvInvoke.Laplacian(scr1, dst,
Emgu.CV.CvEnum.DepthType.Default, 1);//邊緣偵測
image2.Image = dst.Bitmap;
}
}
}
     
      
舊 2021-10-28, 10:58 AM #1
回應時引用此文章
bibo987離線中