Click here to Skip to main content
15,868,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
sorry for my English, I want to get frame capture when moving on loaded video, how can I do it? Example, there is a way, take a frame capture while the car is on the way, but,
don't take a frame capture while the road is empty. my codes are as follows;

C#
VideoCapture capture = null;
  List<Mat> image_array = new List<Mat>();

        private void ProcessFrame(object sender, EventArgs arg)
        {
        Mat frame = new Mat();
        capture.Retrieve(frame, 0);
        ımageBox1.Image = frame;
        Thread.Sleep((int)capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps));
        try
        {
            string time = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_ffff");
            frame = capture.QueryFrame();
            Bitmap captureBitmap = new Bitmap(frame.Bitmap);
            captureBitmap.Save(@"D:\FrameCapture\Capture-" + time + ".jpg", ImageFormat.Jpeg);
            if (frame != null)
            {
                image_array.Add(frame);
            }
            else
            {
                Application.Idle -= ProcessFrame;
            }
        }
        catch (Exception)
        {
        }
    }


I want something like this;

C#
if(moved)
{
captureBitmap.Save(......)
}


how can I do it?

What I have tried:

C#
for (int i = 0; i < image_array.Count; i++)
                {

                    CvInvoke.AbsDiff(image_array[i], image_array[i + 1], diffFrame);

                      if (diffFrame!=null)
                      {
                    croppedBitmap.Save(@"D:\FrameCapture\Capture-" + time + ".jpg", ImageFormat.Jpeg);

                }
                }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900