49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using HardwareControl.Core.SampleAnalysis;
|
|
|
|
namespace HardwareWeb.Models
|
|
{
|
|
/// <summary>基准画面采集结果。</summary>
|
|
public sealed record SampleBaselinePayload(
|
|
int Width,
|
|
int Height,
|
|
DateTimeOffset CapturedAt)
|
|
{
|
|
public static SampleBaselinePayload From(SampleBaselineInfo info) =>
|
|
new(info.Width, info.Height, info.CapturedAt);
|
|
}
|
|
|
|
/// <summary>靶样画面采集结果。</summary>
|
|
public sealed record SampleTargetPayload(
|
|
int Width,
|
|
int Height,
|
|
DateTimeOffset CapturedAt)
|
|
{
|
|
public static SampleTargetPayload From(SampleTargetInfo info) =>
|
|
new(info.Width, info.Height, info.CapturedAt);
|
|
}
|
|
|
|
/// <summary>采样点坐标(图像像素)。</summary>
|
|
public sealed record SamplePointPayload(int X, int Y);
|
|
|
|
/// <summary>靶样轮廓与采样点分析结果。</summary>
|
|
public sealed record SampleAnalysisPayload(
|
|
string ImageBase64,
|
|
string MimeType,
|
|
int Width,
|
|
int Height,
|
|
int SamplingPointCount,
|
|
IReadOnlyList<SamplePointPayload> SamplingPoints)
|
|
{
|
|
public static SampleAnalysisPayload From(SampleAnalysisResult result) =>
|
|
new(
|
|
Convert.ToBase64String(result.ImageData),
|
|
result.MimeType,
|
|
result.Width,
|
|
result.Height,
|
|
result.SamplingPointCount,
|
|
result.SamplingPoints
|
|
.Select(point => new SamplePointPayload(point.X, point.Y))
|
|
.ToList());
|
|
}
|
|
}
|