public partial class Form1 : Form{ //declare the video capture object private VideoCapture video; //declare the frame container object private Mat mat = new Mat(); //this method let's a user choose a video for playing private void loadVideo(object sender, EventArgs e){ //declare the open file dialog using(var openfiledialog = new OpenFileDialog()){ //set video file filters openfiledialog.Filter = "Video Files|*.mp4;*.avi"; if(openfiledialog.ShowDialog() == DialogResult.OK){ //get the extension and make sure its a video file var ext = Path.GetExtension(openfiledialog.FileName); if(ext.Contains(".mp4") || ext.Contains(".avi")) { //load the video into a emgu cv capture object video = new VideoCapture(openfilediaog.FileName); //call method to play video PlayVideo(); } } } } //method to play the video private void async PlayVideo(){ while(video.Grab()){ //read a frame and display using(var frame = new Mat()){ CvInvoke.Resize(frame, frame,pictureBox1.Size); //convert the Mat to bitmap var bmp = ToBitmap(frame); //delay the thread for 33 seconds for video Task.Delay(33); } } } }
//delay the thread for 33 seconds for video Task.Delay(33);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)