Junior Member
加入日期: Nov 2016
文章: 717
|
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:59 AM 被 bibo987 編輯. |
|||||||
2021-10-28, 10:58 AM
#1
|
Amateur Member
加入日期: Feb 2005
文章: 42
|
不用特別宣告form2吧, 直接用this就可以在Form1加入Controls.
或者到Form1的設計layout, 加入兩個PictureBox的Control, 在類別裡也可以直接access到他們. |
||
2021-10-28, 08:03 PM
#2
|
Senior Member
加入日期: Apr 2005
文章: 1,192
|
不是很懂.net
不過CvInvoke.Laplacian的參數並沒有PictureBox 如果只是單純處理或傳送資料而不顯示的話應該是直接操作Image本身就好 不用new一個Form再放PictureBox |
2021-10-29, 06:35 AM
#3
|