/* * 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 CogPattern { /// /// BrightnessParamExt 클래스 /// public class BrightnessParamExt : ICloneable { private const string FILE_NAME = "BrightnessParamExt.json"; /// /// AvgLow /// public double AvgLow { get; set; } = 0; /// /// AvgHigh /// public double AvgHigh { get; set; } = 0; /// /// FindROI /// public ROI FindROI { get; set; } = new ROI(); /// /// BrightnessParamExt 생성자 /// public BrightnessParamExt() { } /// /// BrightnessParamExt 생성자 /// /// ROI 정보 public BrightnessParamExt(ROI findRoi) { FindROI = findRoi.Clone() as ROI; } /// /// object 복사 /// public object Clone() { return new BrightnessParamExt() { AvgLow = AvgLow, AvgHigh = AvgHigh, FindROI = FindROI.Clone() as ROI }; } /// /// BrightnessParamExt 불러오기 /// /// 경로 정보 /// BrightnessParamExt public static BrightnessParamExt Load(string dirPath) { string filePath = Path.Combine(dirPath, FILE_NAME); if (File.Exists(filePath)) { return JsonConvert.DeserializeObject( File.ReadAllText(filePath), typeof(BrightnessParamExt)) as BrightnessParamExt; } return new BrightnessParamExt(); } /// /// BrightnessParamExt 저장 /// /// 경로 정보 /// BrightnessParamExt /// 성공 유무 public static int Save(string dirPath, BrightnessParamExt brightnessParamExt) { 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, brightnessParamExt); } return E1.OK; } } }