private void average_ssim_test() { // Force environment path to plugin folder. //String currentPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process); //String dllPath = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "Assets" + Path.DirectorySeparatorChar + "Plugins"; //if (currentPath.Contains(dllPath) == false) { // Environment.SetEnvironmentVariable("PATH", currentPath + Path.PathSeparator + dllPath, EnvironmentVariableTarget.Process); //} _main_camera = Camera.main; byte[] image1 = capture_byte_screenshot(); byte[] image2 = capture_byte_screenshot(); float start_time = 0; float[] numbers = new float[10]; for (int i = 0; i < 10; i++) { start_time = Time.realtimeSinceStartup; float index = SSIM.compute_mssim_byte(image1, image2, capture_width, capture_height); numbers[i] = Time.realtimeSinceStartup - start_time; Debug.Log("MSSIM Execution Time: " + (Time.realtimeSinceStartup - start_time)); Debug.Log("MSSIM: " + index); } Debug.Log("MSSIM Average Execution Time: " + (numbers.Average())); }
public override TreeItemData ToTreeView() { var root = new TreeItemData(Type, Started, new() { new("Source File", FilePath), new("Filter", FilterID), new("Preset", Preset), new("Success", Success?.ToString() ?? "Unknown") }); if (SSIM.HasValue) { root.TreeItems.Add(new("SSIM", SSIM.ToPercent(2).Adorn("%"))); } if (Compression.HasValue) { root.TreeItems.Add(new("Compression", Compression.ToPercent(2).Adorn("%"))); } if (Percentage.HasValue) { root.TreeItems.Add(new("Percentage", Percentage.Adorn("%"))); } if (Speed.HasValue) { root.TreeItems.Add(new("Speed", Speed)); } if (FPS.HasValue) { root.TreeItems.Add(new("FPS", FPS)); } if (Arguments != null && Arguments.Any()) { var argumentsTree = new TreeItemData("Arguments") { TreeItems = new() }; for (int i = 0; i < Arguments.Count; i++) { argumentsTree.TreeItems.Add(new($"Pass {i + 1}", Arguments[i])); } root.TreeItems.Add(argumentsTree); } return(root); } }
private HashSet <TreeItemData> ToTreeItemData() { var items = new HashSet <TreeItemData>() { new("Destination File", DestinationFilePath), new("Filter", FilterID), new("Preset", Preset), new("Success", Success?.ToString() ?? "Unknown") }; if (SSIM.HasValue) { items.Add(new("SSIM", SSIM.ToPercent(2).Adorn("%"))); } if (Compression.HasValue) { items.Add(new("Compression", Compression.ToPercent(2).Adorn("%"))); } if (Percentage.HasValue) { items.Add(new("Percentage", Percentage.Adorn("%"))); } if (Speed.HasValue) { items.Add(new("Speed", Speed)); } if (FPS.HasValue) { items.Add(new("FPS", FPS)); } if (Arguments != null && Arguments.Any()) { var argumentsTree = new TreeItemData("Arguments") { TreeItems = new() }; for (int i = 0; i < Arguments.Count; i++) { argumentsTree.TreeItems.Add(new($"Pass {i + 1}", Arguments[i])); } items.Add(argumentsTree); } return(items); } }
public override string ToString() { return($"{base.ToString()} Filter: {FilterID} | Preset: {Preset} | Success: {Success?.ToString() ?? "Unknown"}{SSIM.Wrap(" | SSIM: {0}")}{Compression.Wrap(" | Comp: {0}")}{Speed.Wrap(" | Speed: {0}")}{FPS.Wrap(" | FPS: {0}")}"); }
public void generate_dlod_table(int max_triangles, int width, int height, bool save_file, string folderpath) { DLODGroup[] dlods = _get_dlods_within_frustum(); if (dlods.Length == 0) { return; } foreach (DLODGroup dlod in dlods) { dlod.set_to_original(); } int triangles = calc_triangles(); if (save_file) { Directory.CreateDirectory(folderpath + "/" + gameObject.name); } int itr = 0; Texture2D reference = _take_screen_shoot(width, height); while (triangles > max_triangles) { Pair <DLODGroup, float>[] dlod_ssim = new Pair <DLODGroup, float> [dlods.Length]; for (int i = 0; i < dlods.Length; ++i) { dlod_ssim[i] = new Pair <DLODGroup, float>(dlods[i], -1.0f); } string folder_path = ""; if (save_file) { folder_path = folderpath + "/" + gameObject.name + "/itr_" + itr.ToString(); Directory.CreateDirectory(folder_path); } int counter = 0; foreach (Pair <DLODGroup, float> dlod in dlod_ssim) { // If false we, skip. The mesh will be culled. if (!dlod.first.try_to_lower()) { dlod.first.activate(dlod.first.num_dlod_versions() - 1); continue; } Texture2D tex = _take_screen_shoot(width, height); float mssim = SSIM.compute_mssim_textures(reference, tex, width, height); dlod.second = mssim; if (save_file) { string dlod_table = ""; dlod_table += "SSIM: " + mssim.ToString() + "\n\n"; foreach (DLODGroup d in dlods) { dlod_table += d.gameObject.name; dlod_table += ": "; dlod_table += d.get_active_version().ToString(); dlod_table += "\n"; } File.WriteAllText(folder_path + "/" + gameObject.name + "_itr_" + itr.ToString() + "_" + counter.ToString() + ".txt", dlod_table); File.WriteAllBytes(folder_path + "/" + gameObject.name + "_itr_" + itr.ToString() + "_" + counter.ToString() + ".png", tex.EncodeToPNG()); } dlod.first.try_to_higher(); DestroyImmediate(tex); ++counter; } int index = -1; float val = 0.0f; for (int i = 0; i < dlods.Length; ++i) { if (dlod_ssim[i].second > val) { index = i; val = dlod_ssim[i].second; } } if (index >= 0) { dlod_ssim[index].first.try_to_lower(); triangles = calc_triangles(); } else { triangles = 0; } ++itr; } DestroyImmediate(reference); table = GetComponent <DLODTable>(); if (!table) { table = gameObject.AddComponent <DLODTable>(); } if (save_file) { string dlod_table = ""; foreach (DLODGroup d in dlods) { dlod_table += d.gameObject.name; dlod_table += ": "; dlod_table += d.get_active_version().ToString(); dlod_table += "\n"; } Texture2D tex = _take_screen_shoot(width, height); File.WriteAllText(folderpath + "/" + gameObject.name + "/" + gameObject.name + "_golden.txt", dlod_table); File.WriteAllBytes(folderpath + "/" + gameObject.name + "/" + gameObject.name + "_golden.png", tex.EncodeToPNG()); } foreach (DLODGroup dlod in dlods) { table.push_back(dlod, dlod.get_active_version()); dlod.set_to_original(); } triangles = calc_triangles(); }