59 lines
1.6 KiB
C#
59 lines
1.6 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 CogPattern {
|
|
internal class BlobParamExt : ICloneable {
|
|
private const string FILE_NAME = "BlobParamExt.json";
|
|
|
|
public double AreaLow { get; set; } = 0;
|
|
public double AreaHigh { get; set; } = 0;
|
|
|
|
public BlobParamExt() {
|
|
}
|
|
|
|
public object Clone() {
|
|
return new BlobParamExt() {
|
|
AreaLow = AreaLow,
|
|
AreaHigh = AreaHigh,
|
|
};
|
|
}
|
|
|
|
public static BlobParamExt Load(string dirPath) {
|
|
string filePath = Path.Combine(dirPath, FILE_NAME);
|
|
|
|
if (File.Exists(filePath)) {
|
|
return JsonConvert.DeserializeObject(
|
|
File.ReadAllText(filePath), typeof(BlobParamExt)) as BlobParamExt;
|
|
}
|
|
|
|
return new BlobParamExt();
|
|
}
|
|
|
|
public static int Save(string dirPath, BlobParamExt blobParamExt) {
|
|
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, blobParamExt);
|
|
}
|
|
|
|
return E1.OK;
|
|
}
|
|
}
|
|
}
|