暂存提交
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.baiyue.integration.dto.ocr;
|
||||
|
||||
/**
|
||||
* 百度 OCR 返回的文字候选及其识别框。
|
||||
*/
|
||||
public record OcrCandidate(
|
||||
String text,
|
||||
Double confidence,
|
||||
Integer left,
|
||||
Integer top,
|
||||
Integer width,
|
||||
Integer height
|
||||
) {
|
||||
public long area() {
|
||||
if (width == null || height == null || width <= 0 || height <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return (long) width * height;
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.baiyue.integration.dto.ocr;
|
||||
|
||||
import jakarta.validation.constraints.DecimalMax;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 重量 OCR 批次请求。目录必须位于服务配置的允许根目录内。
|
||||
*/
|
||||
public record WeightOcrBatchRequest(
|
||||
@NotBlank(message = "输入目录不能为空") String inputDirectory,
|
||||
String outputDirectory,
|
||||
@DecimalMin(value = "0.0", message = "纵向裁剪起始比例不能小于 0")
|
||||
@DecimalMax(value = "0.95", message = "纵向裁剪起始比例不能大于 0.95")
|
||||
Double cropStartRatio,
|
||||
@DecimalMin(value = "0.0", message = "横向裁剪比例不能小于 0")
|
||||
@DecimalMax(value = "0.49", message = "横向裁剪比例不能大于 0.49")
|
||||
Double horizontalTrimRatio,
|
||||
Boolean recursive
|
||||
) {
|
||||
public double effectiveCropStartRatio() {
|
||||
return cropStartRatio == null ? 0.5 : cropStartRatio;
|
||||
}
|
||||
|
||||
public double effectiveHorizontalTrimRatio() {
|
||||
return horizontalTrimRatio == null ? 0.25 : horizontalTrimRatio;
|
||||
}
|
||||
|
||||
public boolean effectiveRecursive() {
|
||||
return Boolean.TRUE.equals(recursive);
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.baiyue.integration.dto.ocr;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 重量 OCR 批次汇总结果。
|
||||
*/
|
||||
public record WeightOcrBatchResult(
|
||||
String batchId,
|
||||
Instant startedAt,
|
||||
Instant finishedAt,
|
||||
String inputDirectory,
|
||||
String outputDirectory,
|
||||
int total,
|
||||
int recognized,
|
||||
int noWeightFound,
|
||||
int failed,
|
||||
List<WeightOcrImageResult> results
|
||||
) {
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.baiyue.integration.dto.ocr;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 单张称重图片识别结果。路径均为相对于受控根目录的相对路径。
|
||||
*/
|
||||
public record WeightOcrImageResult(
|
||||
String sourceImage,
|
||||
String croppedImage,
|
||||
String rawResponseFile,
|
||||
Status status,
|
||||
BigDecimal weight,
|
||||
Double confidence,
|
||||
List<OcrCandidate> candidates,
|
||||
String error
|
||||
) {
|
||||
public enum Status {
|
||||
RECOGNIZED,
|
||||
NO_WEIGHT_FOUND,
|
||||
FAILED
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user