Exemplo n.º 1
0
        private static void CreateOutputFile(VottObject vottObject)
        {
            var outputFileName = $"{vottObject.Asset.Id}-asset.json";
            var outputFilePath = Path.Combine(outputDirectory.FullName, outputFileName);

            using var streamWriter   = File.CreateText(outputFilePath);
            using var jsonTextWriter = new JsonTextWriter(streamWriter)
                  {
                      Formatting  = Formatting.Indented,
                      Indentation = 4
                  };
            new JsonSerializer().Serialize(jsonTextWriter, vottObject);

            //string json = JsonConvert.SerializeObject(vottObject, Formatting.Indented)
            //    .Replace(@"\\", @"/"); // Fixing slashes escaping in the path
            //streamWriter.Write(json);
        }
Exemplo n.º 2
0
        public static VottObject Convert(string imagePath)
        {
            var yoloTxtFilePath = Path.ChangeExtension(imagePath, ".txt");
            var vottObject      = new VottObject(imagePath);

            using (var streamReader = new StreamReader(yoloTxtFilePath, Encoding.Default))
            {
                string yoloBoundingBoxLine;
                while ((yoloBoundingBoxLine = streamReader.ReadLine()) != null)
                {
                    var imageSize = vottObject.Asset.Size;
                    var region    = new Region(yoloBoundingBoxLine, imageSize);
                    vottObject.Regions.Add(region);
                }
            }

            return(vottObject);
        }