diff --git a/DeepTongue_feature_LabColor/feature_labColor/newcamera_deeplearning/Form_TIASAutomaticShootingSystem.cs b/DeepTongue_feature_LabColor/feature_labColor/newcamera_deeplearning/Form_TIASAutomaticShootingSystem.cs index 39ce937..e111da5 100644 --- a/DeepTongue_feature_LabColor/feature_labColor/newcamera_deeplearning/Form_TIASAutomaticShootingSystem.cs +++ b/DeepTongue_feature_LabColor/feature_labColor/newcamera_deeplearning/Form_TIASAutomaticShootingSystem.cs @@ -48,13 +48,13 @@ private void button_ConnectTIAS_Click(object sender, EventArgs e) { // GetImage() - var path_oriImg = @"data_lab\f\Shot0001.bmp"; - var path_calibCsv = @"data_lab\f\Calib.csv"; + var path_oriImg = @"data_lab\g\Shot0001.bmp"; + var path_calibCsv = @"data_lab\g\Calib.csv"; var path_colorMatrixXYZ = "xyz.txt"; using (Mat mat_oriImg = Cv2.ImRead(path_oriImg, ImreadModes.Color)) { // Process_DeepTIAS() - var path_mask = @"data_lab\f\Shot0001_mask.bmp"; + var path_mask = @"data_lab\g\Shot0001_mask.bmp"; Mat mat_finalMask = Cv2.ImRead(path_mask, ImreadModes.Grayscale); Cv2.Threshold(mat_finalMask, mat_finalMask, 128, 255, ThresholdTypes.Binary); @@ -68,7 +68,19 @@ // 8領域の取得 List list_8area = Get8area(list_5points); Show8area(mat_oriImg.Clone(), list_8area); - + + // DEBUG + //List list_5points_002 = new List() { + // new OpenCvSharp.Point(230, 628), + // new OpenCvSharp.Point(704, 572), + // new OpenCvSharp.Point(642, 782), + // new OpenCvSharp.Point(360, 808), + // new OpenCvSharp.Point(500, 920) + //}; + //List list_8area_002 = Get8area(list_5points_002); + //Show8area(mat_oriImg.Clone(), list_8area_002); + + /* // 色抽出 List list_8Bgr = Get8colors(mat_maskedImg, list_8area); diff --git a/Tongue extraction_cropresizemethod/Tongue extraction/Form1.cs b/Tongue extraction_cropresizemethod/Tongue extraction/Form1.cs index a6fa5d0..5072afb 100644 --- a/Tongue extraction_cropresizemethod/Tongue extraction/Form1.cs +++ b/Tongue extraction_cropresizemethod/Tongue extraction/Form1.cs @@ -843,16 +843,23 @@ // boundingboxなどのinfo出力用 sw = new StreamWriter(fileName_info, false, System.Text.Encoding.GetEncoding("shift_jis")); // 出力用csvの準備 - //sw.WriteLine( - // "image" + "," + - // "top left X" + "," + "top left Y" + "," + "bottom right X" + "," + "bottom right Y" + "," + - // "Area" + "," + "Gloss Count"); + sw.Write( + "image" + "," + + "top left X" + "," + "top left Y" + "," + "bottom right X" + "," + "bottom right Y" + "," + ); + for (int i = 0; i < 3; i++) + for (int j = 0; j < 5; j++) + sw.Write("x" + j.ToString() + "," + "y" + j.ToString() + ","); + for (int i = 0; i < 3; i++) + for (int j = 0; j < 8; j++) + sw.Write("x" + j.ToString() + "," + "y" + j.ToString() + ","); + sw.WriteLine(); sw.Close(); using (MemoryStream ms = new MemoryStream()) { // ディレクトリglobの取得 - var glob_dir = Directory.GetDirectories(@"D:\kei2\Study\Tongue\TongueColorAnalysis\automaze5click\Process"); + var glob_dir = Directory.GetDirectories(@"D:\kei2\Study\Tongue\TongueColorAnalysis\automaze5click\Dataset"); for (int a = 0; a < glob_dir.Length; a++) { @@ -864,11 +871,12 @@ var path_image = glob_file.Where(n => n.Contains("bmp") || n.Contains("png")).ToList()[0]; var path_base = Directory.GetCurrentDirectory(); var name_image = Path.GetFileName(path_image); + var name_dir = Path.GetFileName(glob_dir[a]); // ステータスの表示 Invoke((MethodInvoker)delegate { - label_processingFileName.Text = "Processing File: " + "\\" + name_image; + label_processingFileName.Text = "Processing File: " + "\\" + name_dir; count = a + 1; label_totalProgress.Text = "Total Progress: " + count + "/" + glob_dir.Length; }); @@ -934,7 +942,7 @@ } } // Detection結果表示・保存 - mat_drawBox.SaveImage(path_base + "\\detection" + "\\" + name_image); + mat_drawBox.SaveImage(path_base + "\\detection" + "\\" + name_dir + ".bmp"); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_drawBox); Invoke((MethodInvoker)delegate { @@ -953,7 +961,7 @@ mat_cropped.Set(i, j, pix); } } - mat_cropped.SaveImage(path_base + "\\cropped" + "\\" + name_image); + mat_cropped.SaveImage(path_base + "\\cropped" + "\\" + name_dir + ".bmp"); // 舌検出領域でresize OpenCvSharp.Size size_roi = new OpenCvSharp.Size(); @@ -962,7 +970,7 @@ roi = new Rect(P1, size_roi); mat_roisize = mat_input.Clone(roi); Cv2.Resize(mat_roisize, mat_roi, mat_roi256.Size()); - mat_roi.SaveImage(path_base + "\\cropresized" + "\\" + name_image); + mat_roi.SaveImage(path_base + "\\cropresized" + "\\" + name_dir + ".bmp"); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_roi); Invoke((MethodInvoker)delegate { @@ -1028,20 +1036,20 @@ }); label3.BackColor = Color.White; label4.BackColor = Color.Red; - mat_output.SaveImage(path_base + "\\output256" + "\\" + name_image); + mat_output.SaveImage(path_base + "\\output256" + "\\" + name_dir + ".bmp"); // 後処理(領域拡張法)でノイズ除去 iteration 2 try { - RemoveSmallRegion(path_base + "\\output256" + "\\" + name_image, path_base + "\\output_changed1" + "\\" + name_image, 500, 1, 1); - RemoveSmallRegion(path_base + "\\output_changed1" + "\\" + name_image, path_base + "\\output_changed2" + "\\" + name_image, 500, 0, 0); + RemoveSmallRegion(path_base + "\\output256" + "\\" + name_dir + ".bmp", path_base + "\\output_changed1" + "\\" + name_dir + ".bmp", 500, 1, 1); + RemoveSmallRegion(path_base + "\\output_changed1" + "\\" + name_dir + ".bmp", path_base + "\\output_changed2" + "\\" + name_dir + ".bmp", 500, 0, 0); } catch { 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(path_base + "\\output_changed2" + "\\" + name_image, ImreadModes.GrayScale); + mat_outputSRG = new Mat(path_base + "\\output_changed2" + "\\" + name_dir + ".bmp", ImreadModes.GrayScale); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_outputSRG); Invoke((MethodInvoker)delegate { @@ -1053,7 +1061,7 @@ // バウンディングボックスのサイズに戻す Cv2.Resize(mat_outputSRG, mat_outputChanged, mat_roisize.Size()); - mat_outputChanged.SaveImage(path_base + "\\output_resized" + "\\" + name_image); + mat_outputChanged.SaveImage(path_base + "\\output_resized" + "\\" + name_dir + ".bmp"); // 入力と同じサイズでマスクを作成(なんかたまに不安定.resizeで微妙にサイズ変わってrange overしれるかも) // 気休め @@ -1075,24 +1083,24 @@ } mmp = 0; Cv2.Resize(mat_mask, mat_mask, mat_input.Size()); - mat_mask.SaveImage(path_base + "\\mask" + "\\" + name_image); + mat_mask.SaveImage(path_base + "\\mask" + "\\" + name_dir + ".bmp"); // ノイズ処理 try { - RemoveSmallRegion(path_base + "\\mask" + "\\" + name_image, path_base + "\\mask_changed1" + "\\" + name_image, 500, 1, 1); - RemoveSmallRegion(path_base + "\\mask_changed1" + "\\" + name_image, path_base + "\\mask_changed2" + "\\" + name_image, 500, 0, 0); + RemoveSmallRegion(path_base + "\\mask" + "\\" + name_dir + ".bmp", path_base + "\\mask_changed1" + "\\" + name_dir + ".bmp", 500, 1, 1); + RemoveSmallRegion(path_base + "\\mask_changed1" + "\\" + name_dir + ".bmp", path_base + "\\mask_changed2" + "\\" + name_dir + ".bmp", 500, 0, 0); } catch { 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(path_base + "\\mask_changed2" + "\\" + name_image, ImreadModes.GrayScale); + mat_maskSRG = new Mat(path_base + "\\mask_changed2" + "\\" + name_dir + ".bmp", ImreadModes.GrayScale); Cv2.Threshold(mat_maskSRG, mat_maskSRG, 128, 255, ThresholdTypes.Binary); // 2値マスクの最終結果 - mat_maskSRG.SaveImage(path_base + "\\mask_final" + "\\" + name_image); + mat_maskSRG.SaveImage(path_base + "\\mask_final" + "\\" + name_dir + ".bmp"); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_maskSRG); Invoke((MethodInvoker)delegate { @@ -1128,7 +1136,7 @@ } } } - mat_extraction.SaveImage(path_base + "\\extraction" + "\\" + name_image); + mat_extraction.SaveImage(path_base + "\\extraction" + "\\" + name_dir + ".bmp"); bitmap_bitch = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat_extraction); Invoke((MethodInvoker)delegate { @@ -1185,18 +1193,24 @@ // 処理log label8.BackColor = Color.Red; time = DateTime.Now.ToLocalTime().ToString(); - File.AppendAllText("Log.txt ", time + " " + "\\" + name_image + " Done!\n"); + File.AppendAllText("Log.txt ", time + " " + "\\" + name_dir + ".bmp" + " Done!\n"); // info出力 sw = new StreamWriter(fileName_info, true, System.Text.Encoding.GetEncoding("shift_jis")); sw.Write( - name_image.ToString() + "," + name_dir.ToString() + "," // bounding box + P1.X.ToString() + "," + P1.Y.ToString() + "," + P2.X.ToString() + "," + P2.Y.ToString() + "," // area - + areaCount.ToString() + "," + //+ areaCount.ToString() + "," ); + foreach (var n in list_5points_1) + sw.Write(n.X + "," + n.Y + ","); + foreach (var n in list_5points_2) + sw.Write(n.X + "," + n.Y + ","); + foreach (var n in list_5points_3) + sw.Write(n.X + "," + n.Y + ","); foreach (var n in list_8area_1) sw.Write(n.X + "," + n.Y + ","); foreach (var n in list_8area_2)