【发布时间】:2012-04-13 07:03:04
【问题描述】:
我正在尝试为我的网络摄像头的帧选择像素颜色。所以我捕获帧然后在 ImageBox 中显示,没有任何问题。但是,当我双击 ImageBox 时尝试访问存储在 ImageBox 上的图像时,我得到了 CvException。当我尝试获取图像的像素时弹出异常。
OpenCV:无法识别或不支持的数组类型
这就是我捕获帧的方式:
// On Form Load
Application.Idle += ProcessFrame;
private void ProcessFrame(object sender, EventArgs arg)
{
if (cap != null)
{
using (Image<Bgr, byte> frame = cap.QueryFrame())
{
if (frame != null)
{
imageFrame = frame;
imageBoxFrame.Image = imageFrame;
Bgr color = imageFrame[50, 100];
}
}
}
}
在 DoubleClick 事件中:
private void imageBoxFrame_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (treeViewObjects.SelectedNode is ColorNode && !isTracking)
{
if (imageFrame == null)
return;
Emgu.CV.UI.ImageBox imageBox = (Emgu.CV.UI.ImageBox)sender;
Image<Bgr, byte> image = (Image<Bgr, byte>)imageBox.Image;
Bgr color = image[e.X, e.Y]; // This line causes the Exception
}
}
显然图像不为空。 我做错了什么?也许是线程的东西?
【问题讨论】:
-
已经有一段时间了,但您应该回答您自己的问题,这样它才会出现在“未决问题”队列中。