65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
/*
|
|
* 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 PmParamExt : ICloneable {
|
|
private const string FILE_NAME = "PmParamExt.json";
|
|
public ROI FindROI { get; set; } = new ROI();
|
|
|
|
public PmParamExt() {
|
|
}
|
|
|
|
public PmParamExt(ROI findRoi) {
|
|
FindROI = findRoi.Clone() as ROI;
|
|
}
|
|
|
|
public object Clone() {
|
|
return new PmParamExt() {
|
|
FindROI = FindROI.Clone() as ROI
|
|
};
|
|
}
|
|
|
|
internal static bool Exists(string dirPath) {
|
|
string filePath = Path.Combine(dirPath, FILE_NAME);
|
|
return File.Exists(filePath);
|
|
}
|
|
|
|
internal static PmParamExt Load(string dirPath) {
|
|
string filePath = Path.Combine(dirPath, FILE_NAME);
|
|
|
|
if (File.Exists(filePath)) {
|
|
return JsonConvert.DeserializeObject(
|
|
File.ReadAllText(filePath), typeof(PmParamExt)) as PmParamExt;
|
|
}
|
|
|
|
return new PmParamExt();
|
|
}
|
|
|
|
internal static int Save(string dirPath, PmParamExt pmParamExt) {
|
|
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, pmParamExt);
|
|
}
|
|
|
|
return E1.OK;
|
|
}
|
|
}
|
|
}
|