Example #1
0
        public static void TestTemplates(FileInfo listOfIndexFiles, FileInfo templatesFile, FileInfo imageOfLdfcSpectrogram)
        {
            var contentDictionary = ContentSignatures.ContentDescriptionOfMultipleRecordingFiles(listOfIndexFiles, templatesFile);

            // Write the results to a csv file
            var outputDirectory = templatesFile.DirectoryName;
            var filePath        = Path.Combine(outputDirectory ?? throw new InvalidOperationException("Output directory does not exist."), "AcousticSignatures.csv");

            FileTools.WriteDictionaryAsCsvFile(contentDictionary, filePath);

            // get content description plots and use to examine score distributions.
            var contentPlots = ContentSignatures.GetPlots(contentDictionary);
            var images       = GraphsAndCharts.DrawPlotDistributions(contentPlots);
            var plotsImage   = ImageTools.CombineImagesVertically(images);
            var path1        = Path.Combine(outputDirectory, "ScoreDistributions.png");

            plotsImage.Save(path1);

            // Attach plots to LDFC spectrogram and write to file
            var imageList = new List <Image <Rgb24> >();

            if (imageOfLdfcSpectrogram != null)
            {
                var ldfcSpectrogram = Image.Load <Rgb24>(imageOfLdfcSpectrogram.FullName);
                imageList.Add(ldfcSpectrogram);
            }

            if (contentPlots != null)
            {
                int plotHeight = 30;
                foreach (var plot in contentPlots)
                {
                    var imageOfPlot = plot.DrawAnnotatedPlot(plotHeight);
                    imageList.Add(imageOfPlot);
                }
            }

            if (imageList.Count != 0)
            {
                var opImage = ImageTools.CombineImagesVertically(imageList);
                var path2   = Path.Combine(outputDirectory, templatesFile.BaseName() + ".TestOfTemplates.png");
                opImage.Save(path2);
            }

            //Console.WriteLine("# Finished test of content description templates");
        }