This commit is contained in:
142
packages/java/dev/kreuzberg/ImagePreprocessingConfig.java
generated
Normal file
142
packages/java/dev/kreuzberg/ImagePreprocessingConfig.java
generated
Normal file
@@ -0,0 +1,142 @@
|
||||
// This file is auto-generated by alef — DO NOT EDIT.
|
||||
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
|
||||
// To regenerate: alef generate
|
||||
// To verify freshness: alef verify --exit-code
|
||||
// Issues & docs: https://github.com/kreuzberg-dev/alef
|
||||
package dev.kreuzberg;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
|
||||
|
||||
/**
|
||||
* Image preprocessing configuration for OCR.
|
||||
*
|
||||
* These settings control how images are preprocessed before OCR to improve
|
||||
* text recognition quality. Different preprocessing strategies work better
|
||||
* for different document types.
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_ABSENT)
|
||||
@JsonDeserialize(builder = ImagePreprocessingConfig.Builder.class)
|
||||
public record ImagePreprocessingConfig(
|
||||
/**
|
||||
* Target DPI for the image (300 is standard, 600 for small text).
|
||||
*/
|
||||
@JsonProperty("target_dpi") int targetDpi,
|
||||
/**
|
||||
* Auto-detect and correct image rotation.
|
||||
*/
|
||||
@JsonProperty("auto_rotate") boolean autoRotate,
|
||||
/**
|
||||
* Correct skew (tilted images).
|
||||
*/
|
||||
@JsonProperty("deskew") boolean deskew,
|
||||
/**
|
||||
* Remove noise from the image.
|
||||
*/
|
||||
@JsonProperty("denoise") boolean denoise,
|
||||
/**
|
||||
* Enhance contrast for better text visibility.
|
||||
*/
|
||||
@JsonProperty("contrast_enhance") boolean contrastEnhance,
|
||||
/**
|
||||
* Binarization method: "otsu", "sauvola", "adaptive".
|
||||
*/
|
||||
@JsonProperty("binarization_method") String binarizationMethod,
|
||||
/**
|
||||
* Invert colors (white text on black → black on white).
|
||||
*/
|
||||
@JsonProperty("invert_colors") boolean invertColors
|
||||
) {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
public ImagePreprocessingConfig{
|
||||
if (targetDpi == 0) targetDpi = 300;
|
||||
}
|
||||
|
||||
// CPD-OFF
|
||||
@JsonPOJOBuilder(withPrefix = "with", buildMethodName = "build")
|
||||
public static final class Builder {
|
||||
|
||||
@JsonProperty("target_dpi")
|
||||
private int targetDpi = 0;
|
||||
@JsonProperty("auto_rotate")
|
||||
private boolean autoRotate = true;
|
||||
private boolean deskew = true;
|
||||
private boolean denoise = false;
|
||||
@JsonProperty("contrast_enhance")
|
||||
private boolean contrastEnhance = false;
|
||||
@JsonProperty("binarization_method")
|
||||
private String binarizationMethod = "otsu";
|
||||
@JsonProperty("invert_colors")
|
||||
private boolean invertColors = false;
|
||||
|
||||
/** Sets the targetDpi field. */
|
||||
@JsonProperty("target_dpi")
|
||||
public Builder withTargetDpi(final int value) {
|
||||
this.targetDpi = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the autoRotate field. */
|
||||
@JsonProperty("auto_rotate")
|
||||
public Builder withAutoRotate(final boolean value) {
|
||||
this.autoRotate = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the deskew field. */
|
||||
@JsonProperty("deskew")
|
||||
public Builder withDeskew(final boolean value) {
|
||||
this.deskew = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the denoise field. */
|
||||
@JsonProperty("denoise")
|
||||
public Builder withDenoise(final boolean value) {
|
||||
this.denoise = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the contrastEnhance field. */
|
||||
@JsonProperty("contrast_enhance")
|
||||
public Builder withContrastEnhance(final boolean value) {
|
||||
this.contrastEnhance = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the binarizationMethod field. */
|
||||
@JsonProperty("binarization_method")
|
||||
public Builder withBinarizationMethod(final String value) {
|
||||
this.binarizationMethod = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Sets the invertColors field. */
|
||||
@JsonProperty("invert_colors")
|
||||
public Builder withInvertColors(final boolean value) {
|
||||
this.invertColors = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Builds the ImagePreprocessingConfig instance. */
|
||||
public ImagePreprocessingConfig build() {
|
||||
return new ImagePreprocessingConfig(
|
||||
targetDpi,
|
||||
autoRotate,
|
||||
deskew,
|
||||
denoise,
|
||||
contrastEnhance,
|
||||
binarizationMethod,
|
||||
invertColors
|
||||
);
|
||||
}
|
||||
}
|
||||
// CPD-ON
|
||||
public static ImagePreprocessingConfig defaultInstance() {
|
||||
throw new UnsupportedOperationException("defaultInstance is not yet bridged via JNI; use the Builder instead.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user