[程式] EmguCV 更新video frame 問題
環境: EmguCV 2.4
IDE: VC# 2012
原本沒有寫在WPF中;跑出來正常的例子是。
這是視窗左邊 這是右邊
影片(load 進來的) | 一張圖片
然後就是影片會一直跑 這樣子~
片段程式碼(這是ok的):
Capture capture = new Capture("影片的位置");
ImageViewer viewer = new ImageViewer();
Application.Idle += new EventHandler(delegate(object sender,
EventArgs e)
{
Image<Bgr, byte> frame = capture.QueryFrame();
viewer.Image = DrawMatches.Draw( "12.png", frame, out
matchTime);
});
viewer.ShowDialog();
但我要寫在可以加入button的視窗,所以我就改成如下
Capture capture = new Capture("影片的位置");
Image<Bgr, Byte> resultImage;
Application.Idle += new EventHandler(delegate(object sender,
EventArgs e)
{
Image<Bgr, byte> frame = capture.QueryFrame();
resultImage = DrawMatches.Draw("12.png", frame, out
matchTime);
});
showImage.Source = ToBitmapSource(resultImage); //ToBitmapSource是轉型
showImage是xaml的框框
這邊會錯的的地方在於 "resultImage" 會不認識Application.Idle裡面的東西。
會有錯誤顯示 "使用了沒宣告的 resultImage"。
簡單來說 就是 resultImage = DrawMatches.Draw 根本看不到。
請問我要怎麼改呢???
只要不加入Application.Idle 影片就只會一直停在第一個Frame。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.106.98
※ 編輯: coal511464 來自: 140.123.106.98 (03/21 17:58)
※ 編輯: coal511464 來自: 140.123.106.98 (03/21 17:58)
※ 編輯: coal511464 來自: 140.123.106.98 (03/21 17:59)
※ 編輯: coal511464 來自: 140.123.106.98 (03/21 18:00)
※ 編輯: coal511464 來自: 140.123.106.98 (03/21 18:02)
→
03/22 19:04, , 1F
03/22 19:04, 1F
→
03/22 19:07, , 2F
03/22 19:07, 2F
→
03/22 19:07, , 3F
03/22 19:07, 3F
→
03/22 19:08, , 4F
03/22 19:08, 4F
→
03/22 19:08, , 5F
03/22 19:08, 5F
→
03/22 19:09, , 6F
03/22 19:09, 6F
→
03/24 01:23, , 7F
03/24 01:23, 7F
→
03/24 01:25, , 8F
03/24 01:25, 8F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章