Reputation: 1049
I can't play play video with Emgu CV
It's show error
Unable to create capture from 184.avi
Here is the code:
public partial class Form1 : Form
{
//Set the name of pop-up window
String winname = "First Window";
Timer My_Time = new Timer();
int FPS=30;
Capture _capture;
public Form1()
{
InitializeComponent();
//Frame Rate
My_Timer.Interval = 1000 / FPS;
My_Timer.Tick += new EventHandler(My_Timer_Tick);
My_Timer.Start();
_capture = new Capture("184.avi"); // Error this line
}
private void My_Timer_Tick(object sender, EventArgs e)
{
imageBox.Image = _capture.QueryFrame().ToBitmap();
}
I use windows 8 x64 and install emgucv-windows-universal-cuda 2.4.10.1940
It have no opencv_ffmpeg.dll
in bin. So I install opencv-2.4.11 and copy all dll from OpenCV bin to paste in Debug in my project. I paste 184.avi to Debug too. But when I run it show error like this. How to play video with Emgu CV?
Upvotes: 2
Views: 2721
Reputation: 53
You can just provide full path instead of just the file name.
You do not have the video file in the same folder as your program exe. If you place video file just next to your program exe, it should also work.
Upvotes: 0
Reputation: 2255
Your code works fine. I think the problem is that you have not imported the video file to Visual Studio. So try importing the video file to visual studio and also set the properties to copy always. You can see below that i have imported the A.avi file and set it's properties to copy always.
And think you can just use imageBox.Image = _capture.QueryFrame();
instead of imageBox.Image = _capture.QueryFrame().ToBitmap();
because you don't need to convert to bitmap with ImageBox.
The code i used is same as yours.
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.UI;
using Emgu.CV.Features2D;
using Emgu.CV.Util;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{//Set the name of pop-up window
String winname = "First Window";
Timer My_Time = new Timer();
int FPS = 30;
Capture _capture;
public Form1()
{
InitializeComponent();
//Frame Rate
My_Time.Interval = 1000 / FPS;
My_Time.Tick += new EventHandler(My_Timer_Tick);
My_Time.Start();
_capture = new Capture("A.avi"); // Error this line
}
private void My_Timer_Tick(object sender, EventArgs e)
{
imageBox.Image = _capture.QueryFrame();
}
}
}
Upvotes: 0