我有一個事件線程,當從USB攝像頭收到圖像時會觸發事件線程。這很好。如何使用EMGUcv ImageBox控件顯示來自單獨圖像捕獲事件線程的圖像
但是,在同一事件捕獲線程中,我希望在具有emgu ImageBox
控件的UI窗體中顯示該圖像。我無法直接對ImageBox1.Image = capturedImage
進行編碼,因爲ImageBox
位於UI窗體而不在OnImageEvent
線程中。
我在這裏使用某種類型的Invoke/Delegate來跳轉線程嗎? (我仍然在學習使用這些)
但我找不到任何對emgu ImageBox
控件的調用的引用。有沒有人有任何使用emgu Imagebox
在這種交叉類型的應用程序的經驗?
當前代碼:
' This method defines an image event. In it, the image that
' triggered the event is converted and saved before incrementing
' the count. Please see Acquisition_CSharp example for more
' in-depth comments on the acquisition of images.
Protected Overrides Sub OnImageEvent(capturedImage As ManagedImage)
Console.WriteLine("Image event occurred...")
ImageBox2.Image = ConvertToOpenCVMat(capturedImage)
.
.
.
使用[**線程安全方法調用**](http://stackoverflow.com/documentation/vb.net/1913/threading/6235/performing-thread-safe-calls-using-control-invoke# T = 201704262256035702174)。 –
似乎沒有一個emgu ImageBox。任何人都可以證實這一點 – TomG
你可以調用任何控件,它不一定是你要修改的那個控件。重要的是你調用到UI線程。 - 由於EmguCV的'ImageBox'似乎沒有'Invoke'方法,所以你可以直接調用_ **表單本身** _替代:'Me.Invoke()'或者:' .Invoke() '。 –