private MultiObjectLocalizationAndLabelingResult LoadLatestProgressiveAggregationResult(SatyamTaskTableEntry entry) { SatyamAggregatedProgressiveResultsTableAccess aggDB = new SatyamAggregatedProgressiveResultsTableAccess(); SatyamAggregatedProgressiveResultsTableEntry aggEntry = aggDB.getLatestEntryWithMostResultsAggregatedByTaskID(entry.ID); if (aggEntry == null) { return(null); } Hidden_PrevResultID.Value = aggEntry.ID.ToString(); SatyamAggregatedResult satyamResult = JSonUtils.ConvertJSonToObject <SatyamAggregatedResult>(aggEntry.ResultString); MultiObjectLocalizationAndLabelingAggregatedResult aggRes = JSonUtils.ConvertJSonToObject <MultiObjectLocalizationAndLabelingAggregatedResult>(satyamResult.AggregatedResultString); MultiObjectLocalizationAndLabelingResult res = aggRes.boxesAndCategories; return(res); }
public static void SaveAggregatedProgressiveResultImagesLocally(List <SatyamAggregatedProgressiveResultsTableEntry> entries, string directoryName) { if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } directoryName = directoryName + "\\Aggregated"; if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } for (int i = 0; i < entries.Count; i++) { SatyamAggregatedProgressiveResultsTableEntry entry = entries[i]; SatyamAggregatedResult satyamResult = JSonUtils.ConvertJSonToObject <SatyamAggregatedResult>(entry.ResultString); SatyamTask task = JSonUtils.ConvertJSonToObject <SatyamTask>(satyamResult.TaskParameters); SatyamJob job = task.jobEntry; MultiObjectLocalizationAndLabelingAggregatedResult res = JSonUtils.ConvertJSonToObject <MultiObjectLocalizationAndLabelingAggregatedResult>(satyamResult.AggregatedResultString); string ofilename = URIUtilities.filenameFromURI(task.SatyamURI); string[] fields = ofilename.Split('.'); string fileName = fields[0]; Image originalImage = ImageUtilities.getImageFromURI(task.SatyamURI); MultiObjectLocalizationAndLabelingSubmittedJob jobDefinition = JSonUtils.ConvertJSonToObject <MultiObjectLocalizationAndLabelingSubmittedJob>(job.JobParameters); Image imageWithBoundary = DrawingBoxesAndLinesOnImages.addLinesToImage(originalImage, jobDefinition.BoundaryLines, Color.Red, true); List <Rectangle> rectangles = new List <Rectangle>(); List <Color> colors = new List <Color>(); List <string> ids = new List <string>(); List <bool> dashed = new List <bool>(); for (int j = 0; j < res.boxesAndCategories.objects.Count; j++) { MultiObjectLocalizationAndLabelingResultSingleEntry box = res.boxesAndCategories.objects[j]; int x = box.boundingBox.tlx; int y = box.boundingBox.tly; int width = box.boundingBox.brx - box.boundingBox.tlx; int height = box.boundingBox.bry - box.boundingBox.tly; Rectangle r = new Rectangle(x, y, width, height); rectangles.Add(r); string category = box.Category; int colorIndex = jobDefinition.Categories.IndexOf(category); colors.Add(DrawingBoxesAndLinesOnImages.Colors[colorIndex]); string id = j + "-" + category; ids.Add(id); dashed.Add(false); } Image imageWithBoxesAndBoundary = DrawingBoxesAndLinesOnImages.addRectanglesToImage(imageWithBoundary, rectangles, colors, ids, dashed); fileName = fileName + "-AggregatedResult"; ImageUtilities.saveImage(imageWithBoxesAndBoundary, directoryName, fileName); } }