Documentation ¶
Index ¶
- Variables
- func CatmullRom(a, b, c, d uint8, x float64) uint8
- func FindTransform(sources, dests []FPoint) []float64
- func ImageBiCatrom(im image.Image, x, y float64) color.RGBA
- func TransformError(sources, dests []FPoint, t AffineTransform) float64
- func YBiCatrom(im *image.YCbCr, x, y float64) uint8
- type AffineTransform
- type BsData
- type BubblesJson
- type Contest
- type ContestSelections
- type DrawSettings
- type FPoint
- type Header
- func (h *Header) CheckPage(s *ScanContext, it *image.YCbCr, debugi SettableImage) (score float64, err error)
- func (h *Header) DebugImage() SettableImage
- func (h *Header) HotspotDebugImage() *image.RGBA
- func (h *Header) HotspotDebugString() string
- func (h *Header) Png() []byte
- func (h *Header) SetOrigImage(pngbytes []byte) error
- type MatrixTransform
- type NopTransform
- type ScanContext
- func (s *ScanContext) FindTopLineTransform(it *image.YCbCr) error
- func (s *ScanContext) ProcessScannedImage(im image.Image) (marked map[string]map[string]bool, score float64, err error)
- func (s *ScanContext) ReadScannedImage(fname string) (marked map[string]map[string]bool, score float64, err error)
- type Scanner
- type SettableImage
Constants ¶
This section is empty.
Variables ¶
var DebugOut io.Writer
var NoLineError = errors.New("no line found")
Functions ¶
func CatmullRom ¶
func FindTransform ¶
FindTransform solves for best-fit affine transform which maps source positions to dest positions.
func TransformError ¶
func TransformError(sources, dests []FPoint, t AffineTransform) float64
TransformError returns the sum of squared differences of dests vs sources transformed to dests
Types ¶
type AffineTransform ¶
type BubblesJson ¶
type BubblesJson struct { DrawSettings *DrawSettings `json:"draw_settings"` // BsData should be preferred in the future // .BsData[ballotStyleIndex].GpUnitIds = [gp unit id str, ...] // .BsData[ballotStyleIndex].Bubbles[contest id str][selection id str] = [left, bottom, width, height] // .BsData[ballotStyleIndex].Headers[page number str] = [left, top, right, bottom] BsData []BsData `json:"bsdata"` // Bubbles is a list per ballot style, indexed in the same order as the source document ballot styles. // .Bubbles[ballotStyleIndex][contest @id][selection @id][x y width height] // Deprecated, use .BsData[ballotStyleIndex].Bubbles instead Bubbles []Contest `json:"bubbles"` // Headers[ballotStyleIndex][page number string][left top right bottom] // page coords are (0,0) bottom left, in points (1/72 inch) // Deprecated, use .BsData[ballotStyleIndex].Headers instead Headers []map[string][]float64 `json:"headers"` }
type Contest ¶
type Contest map[string]ContestSelections
type ContestSelections ¶
{"csel1": [44.2, 491.4000000000001, 22.67716535433071, 8.255859375], "csel2": [44.2, 458.2000000000001, 22.67716535433071, 8.255859375]} []float64 is length 4, [x,y, width,height]
type DrawSettings ¶
type FPoint ¶
func FPointFromInt ¶
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header is a little like Scanner, but just a ballot original image header, for matching to an unknown ballot scan
func ExtractHeaders ¶
func (*Header) CheckPage ¶
func (h *Header) CheckPage(s *ScanContext, it *image.YCbCr, debugi SettableImage) (score float64, err error)
like 'refineTransform' mapping header hotspots to matches in image, keep page with smallest error
func (*Header) DebugImage ¶
func (h *Header) DebugImage() SettableImage
func (*Header) HotspotDebugImage ¶
Build an image of the found header hotspot regions
func (*Header) HotspotDebugString ¶
func (*Header) SetOrigImage ¶
type MatrixTransform ¶
type MatrixTransform struct {
// contains filtered or unexported fields
}
func (MatrixTransform) Transform ¶
func (mt MatrixTransform) Transform(x, y float64) (float64, float64)
func (MatrixTransform) TransformInt ¶
func (mt MatrixTransform) TransformInt(x, y int) (int, int)
type NopTransform ¶
type NopTransform struct { }
func (NopTransform) TransformInt ¶
func (mt NopTransform) TransformInt(x, y int) (int, int)
type ScanContext ¶
type ScanContext struct { DebugOut io.Writer TargetsPngPath string DebugPngPath string BubblesPngPath string // contains filtered or unexported fields }
ScanContext
func (*ScanContext) FindTopLineTransform ¶
func (s *ScanContext) FindTopLineTransform(it *image.YCbCr) error
func (*ScanContext) ProcessScannedImage ¶
func (s *ScanContext) ProcessScannedImage(im image.Image) (marked map[string]map[string]bool, score float64, err error)
return map[contest @id]map[csel @id](bool marked)
func (*ScanContext) ReadScannedImage ¶
func (s *ScanContext) ReadScannedImage(fname string) (marked map[string]map[string]bool, score float64, err error)
return map[contest @id]map[csel @id](bool marked)
type Scanner ¶
type Scanner struct { Bj BubblesJson // contains filtered or unexported fields }
Scanner holds an original page Scanner is read-only after setup and can be referenced by multiple threads of ScanContext
func (*Scanner) DebugOrigBubbles ¶
func (*Scanner) NewScanContext ¶
func (s *Scanner) NewScanContext() *ScanContext