internal void NewAttribute() { if (attributes == null) { attributes = new Attributes(); } if (pendingAttributeName != null) { iText.StyledXmlParser.Jsoup.Nodes.Attribute attribute; if (hasPendingAttributeValue) { attribute = new iText.StyledXmlParser.Jsoup.Nodes.Attribute(pendingAttributeName, pendingAttributeValue.Length > 0 ? pendingAttributeValue.ToString() : pendingAttributeValueS); } else { if (hasEmptyAttributeValue) { attribute = new iText.StyledXmlParser.Jsoup.Nodes.Attribute(pendingAttributeName, ""); } else { attribute = new BooleanAttribute(pendingAttributeName); } } attributes.Put(attribute); } pendingAttributeName = null; hasEmptyAttributeValue = false; hasPendingAttributeValue = false; Reset(pendingAttributeValue); pendingAttributeValueS = null; }
/// <summary> /// Populates the element (including children) with information from its XML definition. /// </summary> /// <param name="Input">XML definition.</param> public override void FromXml(XmlElement Input) { base.FromXml(Input); this.radius = new LengthAttribute(Input, "radius"); this.clockwise = new BooleanAttribute(Input, "clockwise"); }
/// <summary> /// Populates the element (including children) with information from its XML definition. /// </summary> /// <param name="Input">XML definition.</param> public override void FromXml(XmlElement Input) { base.FromXml(Input); this.expression = new ExpressionAttribute(Input, "expression"); this.testAfter = new BooleanAttribute(Input, "testAfter"); }
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"); }
/// <summary> /// Populates the element (including children) with information from its XML definition. /// </summary> /// <param name="Input">XML definition.</param> public override void FromXml(XmlElement Input) { base.FromXml(Input); this.startAngleRadians = new DoubleAttribute(Input, "startAngleRadians"); this.startAngleDegrees = new DoubleAttribute(Input, "startAngleDegrees"); this.endAngleRadians = new DoubleAttribute(Input, "endAngleRadians"); this.endAngleDegrees = new DoubleAttribute(Input, "endAngleDegrees"); this.clockwise = new BooleanAttribute(Input, "clockwise"); }
/// <summary> /// Populates the element (including children) with information from its XML definition. /// </summary> /// <param name="Input">XML definition.</param> public override void FromXml(XmlElement Input) { base.FromXml(Input); this.width = new LengthAttribute(Input, "width"); this.height = new LengthAttribute(Input, "height"); this.maxWidth = new LengthAttribute(Input, "maxWidth"); this.maxHeight = new LengthAttribute(Input, "maxHeight"); this.minWidth = new LengthAttribute(Input, "minWidth"); this.minHeight = new LengthAttribute(Input, "minHeight"); this.keepAspectRatio = new BooleanAttribute(Input, "keepAspectRatio"); this.overflow = new EnumAttribute <Overflow>(Input, "overflow"); this.onClick = new ExpressionAttribute(Input, "onClick"); }
/// <summary> /// Populates the element (including children) with information from its XML definition. /// </summary> /// <param name="Input">XML definition.</param> public virtual void FromXml(XmlElement Input) { this.id = new StringAttribute(Input, "id"); this.visible = new BooleanAttribute(Input, "visible"); }
// 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"); }
public static MultiObjectTrackingResult stitchTwoTracesByOneFrameBoundingBoxes(MultiObjectTrackingResult currentTrace, MultiObjectTrackingResult nextTrace, int totalFrameCountsBeforeStitching, int totalFrameCountsAfterStitching, int noFramesOverlap = 0, int fps = 10) { List <List <BoundingBox> > boundingboxes = new List <List <BoundingBox> >(); List <List <string> > CrossChunkEntitiesAnnotationStrings = new List <List <string> >(); List <List <string> > SingleChunkEntitiesAnnotationStrings = new List <List <string> >(); for (int i = 0; i < 2; i++) { boundingboxes.Add(new List <BoundingBox>()); CrossChunkEntitiesAnnotationStrings.Add(new List <string>()); SingleChunkEntitiesAnnotationStrings.Add(new List <string>()); } double frameTimeInMiliSeconds = (double)1000 / (double)fps; double timeToPostponeInMilliSeconds = (double)(totalFrameCountsBeforeStitching - noFramesOverlap) * frameTimeInMiliSeconds; //TimeSpan timeSpanToPostponeInSeconds = new TimeSpan(0,0,0,0, (int)timeToPostponeInMilliSeconds); TimeSpan timeSpanToPostponeInSeconds = DateTimeUtilities.getTimeSpanFromTotalMilliSeconds((int)timeToPostponeInMilliSeconds); // get the end of the first trace and the begining + overlap of the second trace DateTime CurrentTraceSampleFrameTime = currentTrace.VideoSegmentStartTime.AddMilliseconds(frameTimeInMiliSeconds * (totalFrameCountsBeforeStitching - 1)); DateTime NextTraceSampleFrameTime = nextTrace.VideoSegmentStartTime.AddMilliseconds(frameTimeInMiliSeconds * (Math.Max(noFramesOverlap - 1, 0))); // current trace foreach (CompressedTrack entity in currentTrace.tracks) { SpaceTime st = entity.getSpaceTimeAt(CurrentTraceSampleFrameTime); BooleanAttribute outofview_attr = entity.getAttributeAt("outofview", CurrentTraceSampleFrameTime); if (st != null && outofview_attr != null && !outofview_attr.value) { BoundingBox box = st.region; boundingboxes[0].Add(box); CrossChunkEntitiesAnnotationStrings[0].Add(entity.unCompressToTrackAnnotationString()); } else { SingleChunkEntitiesAnnotationStrings[0].Add(entity.unCompressToTrackAnnotationString()); } } // next trace nextTrace.VideoSegmentStartTime += timeSpanToPostponeInSeconds; nextTrace.VideoSegmentEndTime += timeSpanToPostponeInSeconds; foreach (CompressedTrack entity in nextTrace.tracks) { // get the frame first before changing the time stmaps. SpaceTime st = entity.getSpaceTimeAt(NextTraceSampleFrameTime); BooleanAttribute outofview_attr = entity.getAttributeAt("outofview", entity.endTime); /// postpone the timestamp of the second trace entity.startTime += timeSpanToPostponeInSeconds; entity.endTime += timeSpanToPostponeInSeconds; entity.spaceTimeTrack.startTime += timeSpanToPostponeInSeconds; entity.spaceTimeTrack.endTime += timeSpanToPostponeInSeconds; //foreach (SpaceTime st in entity.spaceTimeTrack.space_time_track) for (int i = 0; i < entity.spaceTimeTrack.space_time_track.Count; i++) { entity.spaceTimeTrack.space_time_track[i].time += timeSpanToPostponeInSeconds; } //foreach (CompressedBooleanAttributeTrack booleanAttributeTrack in entity.booleanAttributeTracks.Values) foreach (string key in entity.booleanAttributeTracks.Keys) { entity.booleanAttributeTracks[key].startTime += timeSpanToPostponeInSeconds; entity.booleanAttributeTracks[key].endTime += timeSpanToPostponeInSeconds; //foreach (BooleanAttribute ba in entity.booleanAttributeTracks[key].attribute_track) for (int i = 0; i < entity.booleanAttributeTracks[key].attribute_track.Count; i++) { entity.booleanAttributeTracks[key].attribute_track[i].time += timeSpanToPostponeInSeconds; } } if (st != null && outofview_attr != null && !outofview_attr.value) { BoundingBox box = st.region; boundingboxes[1].Add(box); CrossChunkEntitiesAnnotationStrings[1].Add(entity.unCompressToTrackAnnotationString()); } else { SingleChunkEntitiesAnnotationStrings[1].Add(entity.unCompressToTrackAnnotationString()); } } List <MultipartiteWeightedMatch> association = BoundingBoxAssociation.computeBoundingBoxAssociations(boundingboxes); DateTime NewFrameStartTime = currentTrace.VideoSegmentStartTime + DateTimeUtilities.getTimeSpanFromTotalMilliSeconds((int)(totalFrameCountsBeforeStitching * frameTimeInMiliSeconds)); string totalStitchedAnnotationString = stitchAnnotationStringByAssociation(CrossChunkEntitiesAnnotationStrings, SingleChunkEntitiesAnnotationStrings, association, NewFrameStartTime); MultiObjectTrackingResult ret = MultiObjectTrackingResult.ConvertAnnotationStringToMultiObjectTrackingResult(currentTrace.VideoSegmentStartTime, totalStitchedAnnotationString, currentTrace.cameraId, currentTrace.UID, totalFrameCountsAfterStitching, fps); return(ret); }