By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,480 Members | 771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,480 IT Pros & Developers. It's quick & easy.

Detecting motion in a video

P: 5
I'm writing a program that tracks a moving objects in a mpeg file. I'm using AForge.net. I'm new to c# and programming. I cannot get to play the video. For right now I want to play the video in a picture box and cature new and old video frame to compare the movements. Here is my code so far that does not work.
Expand|Select|Wrap|Line Numbers
  1. private void pictureBox1_Paint(object sender, PaintEventArgs e)
  2. {
  3. How do I get to play the video in the picture box?? }
  4.  
  5. private void button1_Click(object sender, EventArgs e)
  6. {
  7. videoSource = new FileVideoSource(videoFile);
  8. //videoSource.
  9. //videoSource.NewFrame += new AForge.Video.NewFrameEventHandler(video_NewFrame);
  10. videoSource.Start();
  11.  
  12.  
  13. }
  14.  
  15. private void video_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs)
  16. {
  17. Bitmap bitmap = eventArgs.Frame;
  18. }
  19. private void openToolStripMenuItem_Click(object sender, EventArgs e)
  20. {
  21.  
  22. openFileDialog.Filter = "Video (.mpeg)|*.mpeg|(.avi)|*.avi|ALL Files (*.*)|*.*";
  23.  
  24. if (openFileDialog.ShowDialog() == DialogResult.OK)
  25. {
  26. videoFile = openFileDialog.FileName;
  27.  
  28. }
  29.  
  30. }
  31. Help anyone please:kathsunil 
  32.  
Posts: 1
Joined: Wed Feb 18, 2009 11:56 am
Private message
Feb 22 '09 #1
Share this Question
Share on Google+
3 Replies


tlhintoq
Expert 2.5K+
P: 3,525
Keep in mind that a video is a series of still frames. You don't drop a video control onto your dialog and walk away. You have to handle each frame as it comes in. Each time you get a still frame, put that frame in the your picture box. You don't have do override the picturebox's Paint event. Try replacing line 17 with this.

Expand|Select|Wrap|Line Numbers
  1.  pictureBox1.Image = eventArgs.Frame;
Feb 23 '09 #2

P: 5
Thanks you
you have been very helpful to me. I had invested a lot of time trying to solve that.
Thank you again.
Feb 23 '09 #3

tlhintoq
Expert 2.5K+
P: 3,525
Glad that worked for you.
Feb 23 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.