Example #1
0
        static void PresentDebugInfoWithOriginalFile(string imgFilePathOrUrl, WhiteRectangleDetector.IDebugInformation debugInfo)
        {
            var path     = File.Exists(imgFilePathOrUrl) ? imgFilePathOrUrl : new Uri(imgFilePathOrUrl).LocalPath;
            var filebase = Path.GetFileNameWithoutExtension(path);

            PresentDebugInfo(filebase, debugInfo);
        }
Example #2
0
        static void PresentDebugInfo(string filebase, WhiteRectangleDetector.IDebugInformation debugInfo)
        {
            // Save images.
            if (!Directory.Exists(OutDir))
            {
                Directory.CreateDirectory(OutDir);
            }

            ImageUtils.SaveImageAsJpg(debugInfo.CropImage, Path.Combine(OutDir, $"{filebase}_0_crop.jpg"));
            ImageUtils.SaveImageAsJpg(debugInfo.BWImage, Path.Combine(OutDir, $"{filebase}_1_bw.jpg"));
            ImageUtils.SaveImageAsJpg(debugInfo.BlobsDetectionResult, Path.Combine(OutDir, $"{filebase}_2_blobs.jpg"));

            // Print timing stats.
            Console.WriteLine("Timing stats:");
            foreach (var kv in debugInfo.Timings)
            {
                Console.WriteLine($"{kv.Key}: {kv.Value}ms");
            }
            Console.WriteLine($"Total: {debugInfo.Timings.Values.Sum()}ms");
        }