PCDVD數位科技討論區
(https://www.pcdvd.com.tw/index.php)
- 疑難雜症區
(https://www.pcdvd.com.tw/forumdisplay.php?f=34)
- - C# 程式請教
(https://www.pcdvd.com.tw/showthread.php?t=1190402)
|
---|
C# 程式請教
最近在學寫C#,請教個弱弱的問題 :ase
我想按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; } } } |
不用特別宣告form2吧, 直接用this就可以在Form1加入Controls.
或者到Form1的設計layout, 加入兩個PictureBox的Control, 在類別裡也可以直接access到他們. |
不是很懂.net
不過CvInvoke.Laplacian的參數並沒有PictureBox 如果只是單純處理或傳送資料而不顯示的話應該是直接操作Image本身就好 不用new一個Form再放PictureBox |
所有的時間均為GMT +8。 現在的時間是01:32 AM. |
vBulletin Version 3.0.1
powered_by_vbulletin 2024。