当前位置:编程学习 > C#/ASP.NET >>

大家好 我又来求助了 关键字:c# emgu(opencv)

大家好 初来乍到 最近在研究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

这该咋整呢?辛苦各位大大~~~ --------------------编程问答-------------------- 同样…… --------------------编程问答-------------------- imageBox1.Image = frame;
=>
imageBox1.Image = frame.ToImage();
--------------------编程问答-------------------- mark,也在研究摄像头,等有时间好好看看。 --------------------编程问答-------------------- Emgu的Image不能直接用,要Image.Bitmap一下。。

http://topic.csdn.net/u/20120507/11/699ae8ef-4197-4593-993a-b41d44899b63.html

http://topic.csdn.net/u/20120511/22/841bfe02-574f-484a-ae0a-774a8ed2fed2.html

http://topic.csdn.net/u/20120514/08/70fb7b80-8cbf-4907-be8e-fe01296b3bcc.html
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,