You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to read frames from a video with a timer and display them in a picture box. The program opens the video and plays the first few frames and then exits with this message.
The program exited with the code 3(0x3)
Here is how I am trying to achieve this.
public partial class Form1: Form{
//declare the timing object for reading the frames
private Timer timer = new Timer(30);
//declare the video container for read the video data
private VideoCapture video;
//declare a Mat for storing the frames read
private Mat mat = new Mat();
}
//this method is for timing the reading and displaying the frame in the picture box
private void Timer_Elapsed(object? sender, ElapsedEventArgs e){
//check if the video is null
if(video == null || ! video.IsOpened)
return;
//read the frame
video.Read(frame);
//convert the frame to a bitmap
var bmp = mat.ToImage<Bgr ,byte>(true).ToJpegData(95);
var ms = new MemoryStream(bmp);
//display image in the picture box
pictureBox1.Image = new Bitmap(ms);
}
I assign the video object when a new video file is selected using the OpenFileDialog.ShowDialog and enable the timer there, what am I doing wrong, Thanks.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to read frames from a video with a timer and display them in a picture box. The program opens the video and plays the first few frames and then exits with this message.
The program exited with the code 3(0x3)
Here is how I am trying to achieve this.
I assign the video object when a new video file is selected using the OpenFileDialog.ShowDialog and enable the timer there, what am I doing wrong, Thanks.
Beta Was this translation helpful? Give feedback.
All reactions