Documentation
¶
Overview ¶
Package process implements image pre-processing and model-output post-processing.
Index ¶
- func ImageToHWC(img image.Image, colorMode config.ImageColorMode) []byte
- func ImagesToBatch(imgs []image.Image, cfg *config.PlateConfig) []byte
- func ReadAndResizePlateImage(path string, cfg *config.PlateConfig) (image.Image, error)
- func ReadPlateImage(path string, colorMode config.ImageColorMode) (image.Image, error)
- func ResizeImage(img image.Image, targetH, targetW int, colorMode config.ImageColorMode, ...) (image.Image, error)
- func ToGray(img image.Image) *image.Gray
- func ToRGB(img image.Image) *image.NRGBA
- type PlatePrediction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ImageToHWC ¶
func ImageToHWC(img image.Image, colorMode config.ImageColorMode) []byte
ImageToHWC converts an image into a flat []byte in (H, W, C) order.
func ImagesToBatch ¶
func ImagesToBatch(imgs []image.Image, cfg *config.PlateConfig) []byte
ImagesToBatch builds the model-ready uint8 tensor (N, H, W, C) from a batch of images.
Each image must already have the correct (H, W) dimensions.
func ReadAndResizePlateImage ¶
ReadAndResizePlateImage is a convenience wrapper: read an image from disk and resize it.
func ReadPlateImage ¶
ReadPlateImage reads an image from disk in the colour mode specified by the config.
The returned image's colour space matches the mode:
- Grayscale → *image.Gray
- Rgb → *image.NRGBA with an opaque alpha channel
func ResizeImage ¶
func ResizeImage( img image.Image, targetH, targetW int, colorMode config.ImageColorMode, keepAspectRatio bool, interp config.ImageInterpolation, paddingColor config.PaddingColor, ) (image.Image, error)
ResizeImage resizes an image to (targetW, targetH), honouring the config options.
When keepAspectRatio is true the image is letter-boxed with paddingColor. The output always has the colour space implied by colorMode.
Types ¶
type PlatePrediction ¶
type PlatePrediction struct {
// Plate is the decoded license-plate string.
Plate string
// CharProbs holds the per-character confidence scores (nil unless returnConfidence).
CharProbs []float32
// Region is the predicted region / country label (nil when the model has no region head).
Region *string
// RegionProb is the probability of the predicted region (set together with Region when
// returnConfidence is true).
RegionProb *float32
}
PlatePrediction is the per-image plate prediction returned by the recognizer.
func PostprocessOutput ¶
func PostprocessOutput( modelOutput []float32, n int, maxPlateSlots int, alphabet string, padChar rune, removePadChar bool, returnConfidence bool, regionOutput []float32, regionLabels []string, ) ([]PlatePrediction, error)
PostprocessOutput decodes the raw plate-head output tensor into PlatePrediction values.
Parameters:
- modelOutput – flat float32 slice of shape (N * maxPlateSlots * vocabSize).
- n – batch size.
- maxPlateSlots – number of character positions.
- alphabet – the model's character set.
- padChar – padding character to strip from the right.
- removePadChar – whether to strip trailing padChar.
- returnConfidence– include per-character probabilities.
- regionOutput – optional flat float32 slice (N * numRegions) (already softmaxed).
- regionLabels – label list for the region head.
func (*PlatePrediction) AvgCharConfidence ¶
func (p *PlatePrediction) AvgCharConfidence() float32
AvgCharConfidence returns the average character confidence, or 0.0 when confidence scores were not requested.