【发布时间】:2017-09-24 10:30:17
【问题描述】:
我有一个从 USB 摄像头接收到图像时触发的事件线程。这很好用。
但是,在同一个事件捕获线程中,我想在具有 emgu ImageBox 控件的 UI 表单中显示该图像。我无法直接对ImageBox1.Image = capturedImage 编码,因为ImageBox 在UI 表单中而不是在OnImageEvent 线程中。
我是否在此处使用某种类型的 Invoke/Delegate 来跳转线程? (我还在学习使用这些)
但我在 emgu ImageBox 控件上找不到对 Invoke 的任何引用。有没有人有在这种交叉踩踏类型的应用程序中使用 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)
.
.
.
【问题讨论】:
-
emgu ImageBox 似乎没有。任何人都可以确认这一点
-
您可以调用任何控件,它不一定是您要修改的那个。重要的是您调用 UI 线程。 -- 由于 EmguCV 的
ImageBox似乎没有Invoke方法,您可以直接调用 表单本身:Me.Invoke(<stuff here>)或:<target form>.Invoke(<stuff here>)。