public static void generateVideoForEvaluation(List <Image> Images, List <DateTime> dateTimeList, MultiObjectTrackingResult ctts, String videoName, String directory)
        {
            List <Image> imagesWithTracks = new List <Image>();

            for (int i = 0; i < Images.Count; i++)
            {
                List <BoundingBox> locations = new List <BoundingBox>();
                List <string>      labels    = new List <string>();
                Dictionary <string, List <bool> > attributes = new Dictionary <string, List <bool> >();
                attributes.Add("occlusion", new List <bool>());

                if (ctts.tracks.Count != 0)
                {
                    foreach (string key in ctts.tracks[0].booleanAttributeTracks.Keys)
                    {
                        if (!attributes.ContainsKey(key))
                        {
                            attributes.Add(key, new List <bool>());
                        }
                    }
                }

                List <int> idx = new List <int>();

                for (int j = 0; j < ctts.tracks.Count; j++)
                {
                    CompressedTrack ct = ctts.tracks[j];
                    SpaceTime       st = ct.getSpaceTimeAt(dateTimeList[i]);

                    BooleanAttribute outofview_attr = ct.getAttributeAt("outofview", dateTimeList[i]);
                    if (st != null && outofview_attr != null && !outofview_attr.value)
                    {
                        BoundingBox l = st.region;
                        locations.Add(l);
                        labels.Add(ctts.tracks[j].label);
                        foreach (string key in attributes.Keys)
                        {
                            attributes[key].Add(ct.getAttributeAt(key, dateTimeList[i]).value);
                        }

                        idx.Add(j);
                    }
                }
                Image new_image = generateTrackImage(Images[i], labels, locations, attributes, idx);
                imagesWithTracks.Add(new_image);
            }

            Console.WriteLine("Saving " + directory + "\\" + videoName);
            FFMpegWrappers.generateVideoFromFrames(imagesWithTracks, videoName, directory);

            //Directory.CreateDirectory(directory + "\\" + videoName);
            //Console.WriteLine("Saving " + directory + "\\" + videoName);
            //for (int i = 0; i < imagesWithTracks.Count; i++)
            //{

            //    imagesWithTracks[i].Save(directory + "\\" + videoName + "\\img" + i.ToString("000") + ".jpg");
            //}
            //Console.WriteLine("done");
        }
        // if the stitched video is too long
        public static void generateVideoFramesForEvaluation(List <string> ImageURLs, MultiObjectTrackingResult ctts, String directory, String videoName, int fps)
        {
            if (Directory.Exists(directory + "\\" + videoName))
            {
                return;
            }

            Directory.CreateDirectory(directory + "\\" + videoName);
            Console.WriteLine("Saving " + directory + "\\" + videoName);

            //List<Image> imageList = new List<Image>();
            var wc = new WebClient();


            //List<DateTime> frameTimes = new List<DateTime>();
            double frameTimeSpanInMiliseconds = (double)1000 / (double)fps;
            //double frameTimeSpanInMiliseconds = (double)(ChunkDuration) / (double)(ImageURLs.Count) * 1000;
            DateTime start = ctts.VideoSegmentStartTime;

            for (int i = 0; i < ImageURLs.Count; i++)
            {
                DateTime t;
                t = start.AddMilliseconds(frameTimeSpanInMiliseconds * i);
                //frameTimes.Add(t);

                Image x = Image.FromStream(wc.OpenRead(ImageURLs[i]));
                //imageList.Add(x);

                List <BoundingBox> locations = new List <BoundingBox>();
                List <string>      labels    = new List <string>();
                Dictionary <string, List <bool> > attributes = new Dictionary <string, List <bool> >();
                attributes.Add("occlusion", new List <bool>());

                List <int> idx = new List <int>();

                if (ctts.tracks.Count != 0)
                {
                    foreach (string key in ctts.tracks[0].booleanAttributeTracks.Keys)
                    {
                        if (!attributes.ContainsKey(key))
                        {
                            attributes.Add(key, new List <bool>());
                        }
                    }
                }

                for (int j = 0; j < ctts.tracks.Count; j++)
                {
                    CompressedTrack ct = ctts.tracks[j];
                    SpaceTime       st = ct.getSpaceTimeAt(t);

                    BooleanAttribute outofview_attr = ct.getAttributeAt("outofview", t);
                    if (st != null && outofview_attr != null && !outofview_attr.value)
                    {
                        BoundingBox l = st.region;
                        locations.Add(l);
                        labels.Add(ctts.tracks[j].label);
                        //attributes["occlusion"].Add(ct.getAttributeAt("occlusion", t).value);
                        foreach (string key in attributes.Keys)
                        {
                            attributes[key].Add(ct.getAttributeAt(key, t).value);
                        }
                        idx.Add(j);
                    }
                }
                Image new_image = generateTrackImage(x, labels, locations, attributes, idx);
                new_image.Save(directory + "\\" + videoName + "\\img" + i.ToString("000") + ".jpg");
            }

            FFMpegWrappers.generateVideoFromFolderofFrames(videoName, directory + "\\" + videoName + "\\");
            Console.WriteLine("done");
        }