2016-08-16 10 views
0

Здравствуйте, когда я запускаю этот код на C# с emgucv увидеть живую IP-камеру в PictureBox он показывает мне ошибку в этой части:потока IP-камеры emgucv

Mat frame = new Mat(); 
_capture.Retrieve(frame, 0); 
captureImageBox.Image = frame; 

ошибка упоминает

Невозможно преобразовать тип emgu.cv.mat в emgu.cv.imag ...

Какие строки кода мне нужно изменить, чтобы правильно запустить его ....

функции

  • Visual Studio 2015
  • emgucv v3.1 x64

    public partial class Form1 : Form 
    { 
    private Capture _capture = null; 
    private bool _captureInProgress; 
    public Form1() 
    { 
        InitializeComponent(); 
        CvInvoke.UseOpenCL = false; 
        try 
        { 
         _capture = new Capture("http://webcam.st-malo.com/axis-cgi/mjpg/video.cgi?"); 
         _capture.ImageGrabbed += ProcessFrame; 
        } 
        catch (NullReferenceException excpt) 
        { 
         MessageBox.Show(excpt.Message); 
        } 
    } 
    
    private void ProcessFrame(object sender, EventArgs arg) 
    { 
        Mat frame = new Mat(); 
        _capture.Retrieve(frame, 0); 
    
        captureImageBox.Image = frame; 
    
    } 
    
    private void captureButton_Click(object sender, EventArgs e) 
    { 
        if (_capture != null) 
        { 
         if (_captureInProgress) 
         { //stop the capture 
          captureButton.Text = "Start Capture"; 
          _capture.Pause(); 
         } 
         else 
         { 
          //start the capture 
          captureButton.Text = "Stop"; 
          _capture.Start(); 
         } 
    
         _captureInProgress = !_captureInProgress; 
        } 
    } 
    

    }

+0

Вы должны преобразовать 'Mat' к типу данных' '' image' использованием ToImage' (http://www.emgu.com/wiki/files/3.1.0/document/html/8e55d304- 16cb-c8a1-bb1b-702cb567a069.htm) – Ash

ответ

0

Попробуйте разборе Mat изображения с помощью этого

Mat frame = new Mat(); 
_capture.Retrieve(frame, 0); 

captureImageBox.Image = frame.ToImage<Bgr, Byte>();