public static void OpenSegmentation(string root, string dirName, Segmentation segmentation, List <Operation> opHist, ref int opIdx) { if (segmentation == null) { return; } segmentation.Clear(); string dir = Path.Combine(root, dirName); if (!Directory.Exists(dir)) { return; } // パラメータの読み込み string f = Path.Combine(dir, "segmentation.seg"); if (!File.Exists(f)) { return; } string[] lines = File.ReadAllLines(f); SegmentRoot sroot = null; Segment seg = null; foreach (var line in lines) { if (line.StartsWith("SegmentRoot:")) { string key = line.Substring("SegmentRoot:".Length).Trim(); segmentation.segmentRootDict[key] = new SegmentRoot(null, null); sroot = segmentation.segmentRootDict[key]; sroot.segments.Clear(); } if (root == null) { continue; } if (line.StartsWith("PathSegment:")) { string name = line.Substring("PathSegment:".Length).Trim(); seg = new PathSegment(name, sroot); sroot.segments.Add(seg); } if (seg == null) { continue; } if (line.StartsWith("closed:")) { string closedText = line.Substring("closed:".Length).Trim(); bool closed; if (bool.TryParse(closedText, out closed)) { seg._SetClosed(closed); } } if (line.StartsWith("offset:")) { string offsetText = line.Substring("offset:".Length).Trim(); string[] tokens = offsetText.Split(','); if (tokens.Length != 2) { continue; } int x, y; if (int.TryParse(tokens[0], out x) && int.TryParse(tokens[1], out y)) { seg.offset = new Point(x, y); } } if (line.StartsWith("path:")) { string pathText = line.Substring("path:".Length).Trim(); seg.path = StringToPointList(pathText); } if (line.StartsWith("section:")) { string sectionText = line.Substring("section:".Length).Trim(); seg.section = StringToPointList(sectionText); } if (line.StartsWith("partingLine:")) { string partingText = line.Substring("partingLine:".Length).Trim(); seg.partingLine = StringToPointList(partingText); } } // 画像の読み込み foreach (var kv in segmentation.segmentRootDict) { var bmpDict = new Dictionary <string, Bitmap>(); OpenImages(dir, kv.Key + "_bmp", bmpDict, opHist, ref opIdx); if (bmpDict.ContainsKey("_root_")) { kv.Value.bmp = bmpDict["_root_"]; } foreach (var sg in kv.Value.segments) { if (bmpDict.ContainsKey(sg.name)) { sg.bmp = bmpDict[sg.name]; } } } // スケルトンの読み込み foreach (var kv in segmentation.segmentRootDict) { var anDict = new Dictionary <string, SkeletonAnnotation>(); OpenAnnotations(dir, kv.Key + "_skeleton", anDict); if (anDict.ContainsKey("_root_")) { kv.Value.an = anDict["_root_"]; } foreach (var sg in kv.Value.segments) { if (anDict.ContainsKey(sg.name)) { sg.an = anDict[sg.name]; } } } }