diff --git a/Tongue extraction_cropresizemethod/Tongue extraction.sln b/Tongue extraction_cropresizemethod/Tongue extraction.sln index f516bea..569a900 100644 --- a/Tongue extraction_cropresizemethod/Tongue extraction.sln +++ b/Tongue extraction_cropresizemethod/Tongue extraction.sln @@ -1,9 +1,13 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepTongue1.6", "Tongue extraction\DeepTongue1.6.csproj", "{D382F9E7-A41D-4D82-A59B-CF4095134D6B}" +<<<<<<< Updated upstream +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepTongue1.6", "Tongue extraction\DeepTongue1.6.csproj", "{AFD610B1-8D23-423A-AA0F-B09BA769BDD7}" +======= +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepTongue1.7", "Tongue extraction\DeepTongue1.7.csproj", "{D382F9E7-A41D-4D82-A59B-CF4095134D6B}" +>>>>>>> Stashed changes EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,16 +17,23 @@ Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D382F9E7-A41D-4D82-A59B-CF4095134D6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D382F9E7-A41D-4D82-A59B-CF4095134D6B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D382F9E7-A41D-4D82-A59B-CF4095134D6B}.Debug|x64.ActiveCfg = Debug|x64 - {D382F9E7-A41D-4D82-A59B-CF4095134D6B}.Debug|x64.Build.0 = Debug|x64 - {D382F9E7-A41D-4D82-A59B-CF4095134D6B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D382F9E7-A41D-4D82-A59B-CF4095134D6B}.Release|Any CPU.Build.0 = Release|Any CPU - {D382F9E7-A41D-4D82-A59B-CF4095134D6B}.Release|x64.ActiveCfg = Release|x64 - {D382F9E7-A41D-4D82-A59B-CF4095134D6B}.Release|x64.Build.0 = Release|x64 + {AFD610B1-8D23-423A-AA0F-B09BA769BDD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AFD610B1-8D23-423A-AA0F-B09BA769BDD7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AFD610B1-8D23-423A-AA0F-B09BA769BDD7}.Debug|x64.ActiveCfg = Debug|x64 + {AFD610B1-8D23-423A-AA0F-B09BA769BDD7}.Debug|x64.Build.0 = Debug|x64 + {AFD610B1-8D23-423A-AA0F-B09BA769BDD7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AFD610B1-8D23-423A-AA0F-B09BA769BDD7}.Release|Any CPU.Build.0 = Release|Any CPU + {AFD610B1-8D23-423A-AA0F-B09BA769BDD7}.Release|x64.ActiveCfg = Release|x64 + {AFD610B1-8D23-423A-AA0F-B09BA769BDD7}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution +<<<<<<< Updated upstream + SolutionGuid = {C60F769D-7539-436D-9117-B35E6195FC86} +======= + SolutionGuid = {33F6C697-859B-4D55-9D28-998267FD09AE} +>>>>>>> Stashed changes + EndGlobalSection EndGlobal diff --git a/Tongue extraction_cropresizemethod/Tongue extraction/DeepTongue1.6.csproj b/Tongue extraction_cropresizemethod/Tongue extraction/DeepTongue1.6.csproj index b069c3c..d0f0360 100644 --- a/Tongue extraction_cropresizemethod/Tongue extraction/DeepTongue1.6.csproj +++ b/Tongue extraction_cropresizemethod/Tongue extraction/DeepTongue1.6.csproj @@ -5,7 +5,7 @@ Debug AnyCPU - {D382F9E7-A41D-4D82-A59B-CF4095134D6B} + {AFD610B1-8D23-423A-AA0F-B09BA769BDD7} WinExe Properties Tongue_extraction @@ -83,6 +83,7 @@ + Form1.cs @@ -106,9 +107,10 @@ + - + @@ -123,17 +125,20 @@ - - ..\..\..\..\..\..\system\sdk\OpenCVsharp\net461\OpenCvSharp.dll + + False + ..\..\..\packages\OpenCvSharp3-AnyCPU.3.2.0.20170107\lib\net40\OpenCvSharp.dll - - ..\..\..\..\..\..\system\sdk\OpenCVsharp\net461\OpenCvSharp.Blob.dll + + False + ..\..\..\packages\OpenCvSharp3-AnyCPU.3.2.0.20170107\lib\net40\OpenCvSharp.Blob.dll - - ..\..\..\..\..\..\system\sdk\OpenCVsharp\net461\OpenCvSharp.Extensions.dll + + False + ..\..\..\packages\OpenCvSharp3-AnyCPU.3.2.0.20170107\lib\net40\OpenCvSharp.Extensions.dll - ..\..\..\..\..\..\system\sdk\OpenCVsharp\net461\OpenCvSharp.UserInterface.dll + ..\..\..\packages\OpenCvSharp3-AnyCPU.3.2.0.20170107\lib\net40\OpenCvSharp.UserInterface.dll C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\System.dll @@ -147,8 +152,13 @@ C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\System.ComponentModel.DataAnnotations.dll + + + + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\System.Reflection.Context.dll @@ -157,7 +167,8 @@ - + + False ..\..\..\packages\TensorFlowSharp.1.11.0\lib\net471\TensorFlowSharp.dll diff --git a/Tongue extraction_cropresizemethod/Tongue extraction/Form1.cs b/Tongue extraction_cropresizemethod/Tongue extraction/Form1.cs index d9e4657..227758c 100644 --- a/Tongue extraction_cropresizemethod/Tongue extraction/Form1.cs +++ b/Tongue extraction_cropresizemethod/Tongue extraction/Form1.cs @@ -17,9 +17,9 @@ [DllImport(@"RemoveSmallRegionDLL.dll", EntryPoint = "RemoveSmallRegion", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)] extern static void RemoveSmallRegion(string name, string name2, int AreaLimit, int CheckMode, int NeihborMode); - Mat mat_input = new Mat(1024, 1280, MatType.CV_8UC3, 1); Mat mat_drawBox = new Mat(1024, 1280, MatType.CV_8UC3, 1); Mat mat_roi = new Mat(1024, 1280, MatType.CV_8UC3, 1); + Mat mat_input = new Mat(1024, 1280, MatType.CV_8UC3, 1); Mat mat_roi256 = new Mat(256, 256, MatType.CV_8UC3, 1); Mat mat_roisize = new Mat(1024, 1280, MatType.CV_8UC3, 1); Mat mat_output = new Mat(1024, 1280, MatType.CV_8UC1, 1); @@ -60,6 +60,9 @@ private ManualResetEvent manualReset = new ManualResetEvent(true); + // 20200421 + delegate bool testDele(); + public Form1() { InitializeComponent(); @@ -254,7 +257,7 @@ private static string DownloadDefaultModel(string dir) { - var modelFile = Path.Combine(dir, "AREinProcess_step12800.pb"); + var modelFile = Path.Combine(dir, "2120_256_64_42999_enhancment_L1loss0.03435.pb"); return modelFile; } @@ -322,18 +325,28 @@ ii = 0; basepath = Directory.GetCurrentDirectory(); imageFile = System.Text.RegularExpressions.Regex.Replace(path[a], "data", ""); - label_processingFileName.Text = "Processing File: " + imageFile; - count = a + 1; - label_totalProgress.Text = "Total Progress: " + count + "/" + path.Length; + Invoke((MethodInvoker)delegate + { + label_processingFileName.Text = "Processing File: " + imageFile; + count = a + 1; + label_totalProgress.Text = "Total Progress: " + count + "/" + path.Length; + }); + mat_input = Cv2.ImRead(basepath + "\\data" + imageFile); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_input); pictureBox_input.Image = bitmap_bitch; - pictureBox_input.Refresh(); + Invoke((MethodInvoker)delegate + { + pictureBox_input.Refresh(); + + }); + label8.BackColor = Color.White; label1.BackColor = Color.Red; mat_drawBox = mat_input.Clone(); mat_cropped = new Mat(mat_input.Size(), MatType.CV_8UC3, 1); byte_inputDetection = Bitmap2Byte(bitmap_bitch); + using (var graph = new TFGraph()) { var model = File.ReadAllBytes(Directory.GetCurrentDirectory() + "/Detection_Normal.pb"); @@ -386,8 +399,12 @@ { mat_drawBox.SaveImage(basepath + "\\detection" + imageFile); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_drawBox); - pictureBox_detection.Image = bitmap_bitch; - pictureBox_detection.Refresh(); + Invoke((MethodInvoker)delegate + { + pictureBox_detection.Image = bitmap_bitch; + pictureBox_detection.Refresh(); + }); + label1.BackColor = Color.White; label2.BackColor = Color.Red; } @@ -468,7 +485,7 @@ MessageBox.Show("Error: Unable to reprocess! Please check is there [RemoveSmallRegionDLL.dll] file in floder?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } - mat_outputSRGNoBox = new Mat(basepath + "\\output_changed2" + imageFile, ImreadModes.Grayscale); + mat_outputSRGNoBox = new Mat(basepath + "\\output_changed2" + imageFile, ImreadModes.GrayScale); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_outputSRGNoBox); pictureBox_outputSRG.Image = bitmap_bitch; pictureBox_outputSRG.Refresh(); @@ -486,7 +503,7 @@ MessageBox.Show("Error: Unable to reprocess! Please check is there [RemoveSmallRegionDLL.dll] file in floder?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } - mat_maskSRG = new Mat(basepath + "\\mask_changed2" + imageFile, ImreadModes.Grayscale); + mat_maskSRG = new Mat(basepath + "\\mask_changed2" + imageFile, ImreadModes.GrayScale); Cv2.Threshold(mat_maskSRG, mat_maskSRG, 128, 255, ThresholdTypes.Binary); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_maskSRG); pictureBox_maskSRG.Image = bitmap_bitch; @@ -545,8 +562,12 @@ Cv2.Resize(mat_roisize, mat_roi, mat_roi256.Size()); mat_roi.SaveImage(basepath + "\\cropresized" + imageFile); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_roi); - pictureBox_cropResized.Image = bitmap_bitch; - pictureBox_cropResized.Refresh(); + Invoke((MethodInvoker)delegate + { + pictureBox_cropResized.Image = bitmap_bitch; + pictureBox_cropResized.Refresh(); + }); + label2.BackColor = Color.White; label3.BackColor = Color.Red; byte_inputSegmentation = Bitmap2Byte(bitmap_bitch); @@ -593,8 +614,12 @@ bitmap_bitch = ToGrayBitmap(mask, 256, 256); mat_output = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap_bitch); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_output); - pictureBox_output.Image = bitmap_bitch; - pictureBox_output.Refresh(); + Invoke((MethodInvoker)delegate + { + pictureBox_output.Image = bitmap_bitch; + pictureBox_output.Refresh(); + }); + label3.BackColor = Color.White; label4.BackColor = Color.Red; mat_output.SaveImage(basepath + "\\output256" + imageFile); @@ -608,10 +633,14 @@ MessageBox.Show("Error: Unable to reprocess! Please check is there [RemoveSmallRegionDLL.dll] file in floder?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } - mat_outputSRG = new Mat(basepath + "\\output_changed2" + imageFile, ImreadModes.Grayscale); + mat_outputSRG = new Mat(basepath + "\\output_changed2" + imageFile, ImreadModes.GrayScale); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_outputSRG); - pictureBox_outputSRG.Image = bitmap_bitch; - pictureBox_outputSRG.Refresh(); + Invoke((MethodInvoker)delegate + { + pictureBox_outputSRG.Image = bitmap_bitch; + pictureBox_outputSRG.Refresh(); + }); + label4.BackColor = Color.White; label5.BackColor = Color.Red; Cv2.Resize(mat_outputSRG, mat_outputChanged, mat_roisize.Size()); @@ -641,13 +670,21 @@ MessageBox.Show("Error: Unable to reprocess! Please check is there [RemoveSmallRegionDLL.dll] file in floder?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } - mat_maskSRG = new Mat(basepath + "\\mask_changed2" + imageFile, ImreadModes.Grayscale); + + //RemoveSmallRegion(basepath + "\\output256" + imageFile, basepath + "\\mask_changed1" + imageFile, 2000, 1, 1); + //RemoveSmallRegion(basepath + "\\mask_changed1" + imageFile, basepath + "\\mask_changed2" + imageFile, 2000, 0, 0); + mat_maskSRG = new Mat(basepath + "\\mask_changed2" + imageFile, ImreadModes.GrayScale); Cv2.Threshold(mat_maskSRG, mat_maskSRG, 128, 255, ThresholdTypes.Binary); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_maskSRG); - pictureBox_maskSRG.Image = bitmap_bitch; - pictureBox_maskSRG.Refresh(); + Invoke((MethodInvoker)delegate + { + pictureBox_maskSRG.Image = bitmap_bitch; + pictureBox_maskSRG.Refresh(); + }); + label5.BackColor = Color.White; label6.BackColor = Color.Red; + mat_extraction = mat_input.Clone(); for (int i = 0; i < mat_input.Height; i++) { @@ -672,22 +709,34 @@ } mat_extraction.SaveImage(basepath + "\\extraction" + imageFile); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_extraction); - pictureBox_extraction.Image = bitmap_bitch; - pictureBox_extraction.Refresh(); + Invoke((MethodInvoker)delegate + { + pictureBox_extraction.Image = bitmap_bitch; + pictureBox_extraction.Refresh(); + }); + label6.BackColor = Color.White; label7.BackColor = Color.Red; bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_input); - pictureBox_contract.Image = bitmap_bitch; - pictureBox_contract.Refresh(); + Invoke((MethodInvoker)delegate + { + pictureBox_contract.Image = bitmap_bitch; + pictureBox_contract.Refresh(); + }); + label7.BackColor = Color.White; label8.BackColor = Color.Red; time = DateTime.Now.ToLocalTime().ToString(); File.AppendAllText("Log.txt ", time + " " + imageFile + " Done!\n"); } MessageBox.Show("Finished!"); - button_start.Enabled = true; - button_pause.Enabled = false; - label_processingFileName.Text = "Processing File: None"; + + Invoke((MethodInvoker)delegate + { + button_start.Enabled = true; + button_pause.Enabled = false; + label_processingFileName.Text = "Processing File: None"; + }); } } diff --git a/Tongue extraction_cropresizemethod/Tongue extraction/Properties/Settings.Designer.cs b/Tongue extraction_cropresizemethod/Tongue extraction/Properties/Settings.Designer.cs new file mode 100644 index 0000000..15b8fb1 --- /dev/null +++ b/Tongue extraction_cropresizemethod/Tongue extraction/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tongue_extraction.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.5.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask/20180419045627.jpg b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask/20180419045627.jpg index f90ef96..f5430f5 100644 --- a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask/20180419045627.jpg +++ b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask/20180419045627.jpg Binary files differ diff --git a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask_changed1/20180419045627.jpg b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask_changed1/20180419045627.jpg index 181499c..a87c0ef 100644 --- a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask_changed1/20180419045627.jpg +++ b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask_changed1/20180419045627.jpg Binary files differ diff --git a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask_changed2/20180419045627.jpg b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask_changed2/20180419045627.jpg index f7d5b0e..552f515 100644 --- a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask_changed2/20180419045627.jpg +++ b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Debug/mask_changed2/20180419045627.jpg Binary files differ diff --git a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/extraction/20180419045627.jpg b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/extraction/20180419045627.jpg index 53e374e..459eb3f 100644 --- a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/extraction/20180419045627.jpg +++ b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/extraction/20180419045627.jpg Binary files differ diff --git a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask/20180419045627.jpg b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask/20180419045627.jpg index f90ef96..7187af5 100644 --- a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask/20180419045627.jpg +++ b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask/20180419045627.jpg Binary files differ diff --git a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask_changed1/20180419045627.jpg b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask_changed1/20180419045627.jpg index 181499c..dc5a070 100644 --- a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask_changed1/20180419045627.jpg +++ b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask_changed1/20180419045627.jpg Binary files differ diff --git a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask_changed2/20180419045627.jpg b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask_changed2/20180419045627.jpg index f7d5b0e..4f5fb59 100644 --- a/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask_changed2/20180419045627.jpg +++ b/Tongue extraction_cropresizemethod/Tongue extraction/bin/x64/Release/mask_changed2/20180419045627.jpg Binary files differ