Exemplo n.º 1
0
        private void GenerateVideo()
        {
            Application.Idle -= ProcessFrame;

            MessageBox.Show("Generating Video");
            List <Interval>       I    = new List <Interval>();
            List <CameraTimeInfo> cams = track.cameraList;

            SQLManager sql = new SQLManager();

            while (true)
            {
                int            index = -1;
                bool           check = true;
                CameraTimeInfo min   = cams[0];
                for (int i = 0; i < cams.Count; i++)
                {
                    if (cams[i].timeIntervals.Count > 1)
                    {
                        index = i;
                        min   = cams[i];
                        break;
                    }
                }
                if (index == -1)
                {
                    break;
                }
                for (int i = 0; i < cams.Count; i++)
                {
                    if (cams[i].timeIntervals.Count > 1)
                    {
                        if (cams[i].timeIntervals[0].startTime < min.timeIntervals[0].startTime)
                        {
                            min   = cams[i];
                            index = i;
                        }
                    }
                }

                I.Add(new Interval(cams[index].cameraName, cams[index].timeIntervals[0].startTime, cams[index].timeIntervals[0].endTime));
                cams[index].timeIntervals.RemoveAt(0);
            }



            string output = VideoGeneration.GenerateVideo(I);
        }
Exemplo n.º 2
0
        public void GetVideosinfo()
        {
            allVids = new List <List <Video> >();
            secs    = new List <int>();
            fps     = new List <int>();

            for (int i = 0; i < AllCams.Count; i++)
            {
                allVids.Add(sql.GetCamVideos(AllCams.ElementAt(i).Name));
                if (allVids.ElementAt(i).Count == 0)
                {
                    secs.Add(0);
                    cap.Add(null);
                }
                else
                {
                    Video temp = allVids.ElementAt(i).ElementAt(0);
                    secs.Add(VideoGeneration.initSec(temp.StartTime.ToString("hh:mm:ss"), temp.EndTime.ToString("hh:mm:ss")));
                    cap.Add(new Capture("Recording/" + temp.FileName));
                }
                //ShellFile shellFile = ShellFile.FromFilePath("Recording/" + allVids.ElementAt(i).ElementAt(0).FileName);
                //fps.Add(Convert.ToInt32((shellFile.Properties.System.Video.FrameRate.Value / 1000)));
            }
        }
Exemplo n.º 3
0
        public Mat getRecordedFrame(string cam)
        {
            if (allVids == null)
            {
                GetVideosinfo();
            }
            for (int i = 0; i < allVids.Count; i++)
            {
                if (AllCams.ElementAt(i).Name == cam)
                {
                    if (cap.ElementAt(i) == null)
                    {
                        return(null);
                    }
                }
            }

            Mat frame = null;

            if (FrameCount < 30)
            {
                FrameCount++;
                for (int i = 0; i < cap.Count; i++)
                {
                    if (cap.ElementAt(i) == null)
                    {
                        continue;
                    }
                    if (AllCams.ElementAt(i).Name == cam)
                    {
                        frame = cap.ElementAt(i).QueryFrame();
                    }
                    else
                    {
                        cap.ElementAt(i).QueryFrame();
                    }
                }
            }
            else
            {
                FrameCount = 0;
                for (int i = 0; i < cap.Count; i++)
                {
                    if (cap.ElementAt(i) == null)
                    {
                        continue;
                    }
                    if (AllCams.ElementAt(i).Name == cam)
                    {
                        frame = cap.ElementAt(i).QueryFrame();
                    }
                    else
                    {
                        cap.ElementAt(i).QueryFrame();
                    }
                    secs[i] = secs[i] - 1;
                    if (secs[i] == 0)
                    {
                        return(null);
                    }
                    if (secs.ElementAt(i) == 0)
                    {
                        if (allVids.ElementAt(i).Count > 0)
                        {
                            allVids.ElementAt(i).RemoveAt(0);
                            cap[i]  = new Capture(allVids.ElementAt(i).ElementAt(0).FileName);
                            secs[i] = VideoGeneration.initSec(allVids.ElementAt(i).ElementAt(0).StartTime.ToString("hh:mm:ss"), allVids.ElementAt(i).ElementAt(0).EndTime.ToString("hh:mm:ss"));
                        }
                    }
                }
            }
            return(frame);

            //if (RecordedFPS == 0)
            //{
            //    ShellFile shellFile = ShellFile.FromFilePath(sourceFile);
            //    int fps =  Convert.ToInt32((shellFile.Properties.System.Video.FrameRate.Value / 1000));
            //}
        }