大家好 初来乍到 最近在研究opencv 刚刚起步 遇到了一些问题 特来求助
我把系统变量等都配置好之后,在工程中也添加了引用
程序如下:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;//PS:调用的Emgu dll
using Emgu.CV.Structure;
using Emgu.Util;
using System.Threading;namespace WindowsFormsApplication13
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Capture capture;
private bool captureinprocess;//判断摄像头的状态 private void button1_Click(object sender, EventArgs e)
{
if (capture != null)//摄像头不为空
{
if (captureinprocess)
{
Application.Idle -= new EventHandler(processfram);
button1.Text = "Stop!";
}
else
{
Application.Idle += new EventHandler(processfram);
button1.Text = "Start!";
}
captureinprocess = !captureinprocess;
}
else//摄像头为空则通过Capture()方法调用
{
try
{
capture = new Capture();
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
} private void processfram(object sender, EventArgs arg)
{
Image<Bgr, Byte> frame = capture.QueryFrame();
imageBox1.Image = frame;
}
}
}
报错的地方为imageBox1.Image = frame;
错与原因如下
错误 1 无法将类型“Emgu.CV.Image<Emgu.CV.Structure.Bgr,byte>”隐式转换为“System.Drawing.Image” C:\Users\Admin\Documents\Visual Studio 2008\Projects\WindowsFormsApplication13\WindowsFormsApplication13\Form1.cs 57 31 WindowsFormsApplication13这该咋整呢?辛苦各位大大~~~
我把系统变量等都配置好之后,在工程中也添加了引用
程序如下:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;//PS:调用的Emgu dll
using Emgu.CV.Structure;
using Emgu.Util;
using System.Threading;namespace WindowsFormsApplication13
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Capture capture;
private bool captureinprocess;//判断摄像头的状态 private void button1_Click(object sender, EventArgs e)
{
if (capture != null)//摄像头不为空
{
if (captureinprocess)
{
Application.Idle -= new EventHandler(processfram);
button1.Text = "Stop!";
}
else
{
Application.Idle += new EventHandler(processfram);
button1.Text = "Start!";
}
captureinprocess = !captureinprocess;
}
else//摄像头为空则通过Capture()方法调用
{
try
{
capture = new Capture();
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
} private void processfram(object sender, EventArgs arg)
{
Image<Bgr, Byte> frame = capture.QueryFrame();
imageBox1.Image = frame;
}
}
}
报错的地方为imageBox1.Image = frame;
错与原因如下
错误 1 无法将类型“Emgu.CV.Image<Emgu.CV.Structure.Bgr,byte>”隐式转换为“System.Drawing.Image” C:\Users\Admin\Documents\Visual Studio 2008\Projects\WindowsFormsApplication13\WindowsFormsApplication13\Form1.cs 57 31 WindowsFormsApplication13这该咋整呢?辛苦各位大大~~~
解决方案 »
- 怎么在statusStrip所在窗口的最右边显示文字信息
- 怎么实现A事件里面写代码执行方法B,执行B的时间为A事件完全执行完毕后
- 我不可以这样检测输入符?while循环问题
- 求教:进来看看(分不够了 呵呵 就还20了)
- 如何比较两个DataSet是否相等
- 322E2E2A 明文是 http 这个是什么编码啊
- 使用StreamWriter写文件时如何回到首行?
- C# 如何将一个字符串的第一个字母转成大写?
- c#与plc通讯的问题
- 《SqlServer日志清除专家 v2.0》最新发布,请大家及时更新! up有分!
- comboBox控件怎么设置成不能写入?
- Winform关于跨线程问题变量.请以代码见真章.
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;//PS:调用的Emgu dll
using Emgu.CV.Structure;
using Emgu.Util;
using System.Threading;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Emgu.CV.UI.ImageBox imageBox1 = new Emgu.CV.UI.ImageBox();
float xfactor;
float yfactor;
Dictionary<string, Rectangle> foundPeople = new Dictionary<string, Rectangle>();
//[DllImport("facecom.dll")]
//public static extern int fnfacecom();
public Form1()
{
InitializeComponent();
}
private Capture capture;
private bool captureinprocess;//判断摄像头的状态
private void button1_Click(object sender, EventArgs e)
{
if (capture != null)//摄像头不为空
{
if (captureinprocess)
{
Application.Idle -= new EventHandler(processfram); button1.Text = "Stop!";
}
else
{
Application.Idle += new EventHandler(processfram);
button1.Text = "Start!";
}
captureinprocess = !captureinprocess;
}
else//摄像头为空则通过Capture()方法调用
{
try
{
capture = new Capture();
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
}
private void processfram(object sender, EventArgs arg)
{
Image<Bgr, Byte> frame = capture.QueryFrame();
imageBox1.Image = frame; }
private void Form1_Load(object sender, EventArgs e)
{
imageBox1.Size = new Size(this.Size.Height, this.Size.Width);
imageBox1.BackColor = Color.Black;
this.Controls.Add(imageBox1);
}
}
}
这个是可以用的