/* * Copyright (c) 2025 LG Electronics Inc. * SPDX-License-Identifier: LicenseRef-LGE-Proprietary */ using VisionCommon; using Hermes; using Newtonsoft.Json; using System; using System.IO; namespace MilPattern { public class EdgeParamExt : ICloneable { private const string FILE_NAME = "EdgeParamExt.json"; public ROI FindROI { get; set; } = new ROI(); public EdgeParamExt() { } public EdgeParamExt(ROI findRoi) { FindROI = findRoi.Clone() as ROI; } public object Clone() { return new EdgeParamExt() { FindROI = FindROI.Clone() as ROI }; } internal static EdgeParamExt Load(string dirPath) { string filePath = Path.Combine(dirPath, FILE_NAME); if (File.Exists(filePath)) { return JsonConvert.DeserializeObject( File.ReadAllText(filePath), typeof(EdgeParamExt)) as EdgeParamExt; } return new EdgeParamExt(); } internal static int Save(string dirPath, EdgeParamExt edgeParamExt) { string filePath = Path.Combine(dirPath, FILE_NAME); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } using (var fs = File.Create(filePath)) using (var sw = new StreamWriter(fs)) using (var jtw = new JsonTextWriter(sw) { Formatting = Formatting.Indented, Indentation = 2, }) { (new JsonSerializer()).Serialize(jtw, edgeParamExt); } return E1.OK; } } }