nuts

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 15 Imported by: 0

README

Pick up Nuts

Package nuts implements ImageRead, ImageWrite, ImageCrop and Baidu OCR API for image cropping and character recognition.

⚡ Features

  • ✂️ Image Cropping (Refer to mergi)
  • 👀 Character Recognition

🚀 Getting started

Install via go get
go get github.com/cxfans/nuts
Usage
✂️ Image Cropping
Image Result Image
srcImage dstImage
err := CropImage("imgs/1.jpg", "crop/1.jpg",380, 640, 480, 240)
✂️ 👀 Character Recognition
client := NewClient(apiKey, secretKey, apiUrl)
if words, err := client.GetWordsFromImage("crop/1.jpg"); err == nil {
    fmt.Println(words)
}

Learn more examples.

🔵 License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Crop

func Crop(img image.Image, x, y, w, h int) (image.Image, error)

x, y: the top left starting point w, h: the final size width * height

func CropImage

func CropImage(src, dst string, x, y, w, h int) error

Simplify the process

func ImageExportBase64

func ImageExportBase64(path string, inc bool) (base64Str string, err error)

Export base64 format image data form the image path directly

func ImageRead

func ImageRead(path string) (image.Image, error)

Read the image directly from the path and return the data

func ImageWrite

func ImageWrite(img image.Image, path string) error

Write the image directly from the data and save to the path

Types

type ApiOcr

type ApiOcr struct {
	// contains filtered or unexported fields
}

The high-precision version can be requested 500 times a day for free

func NewClient

func NewClient(apiKey, secretKey, apiUrl string) ApiOcr

func (*ApiOcr) GetToken

func (api *ApiOcr) GetToken() (string, error)

func (ApiOcr) GetWords

func (api ApiOcr) GetWords(base64Str string) (wordsList []string, err error)

func (ApiOcr) GetWordsFromImage

func (api ApiOcr) GetWordsFromImage(path string) (wordsList []string, err error)

form the image path directly

type Base64Exporter

type Base64Exporter struct {
	// contains filtered or unexported fields
}

func NewBase64Exporter

func NewBase64Exporter(ext string, img image.Image, inc bool) Base64Exporter

func (Base64Exporter) Export

func (o Base64Exporter) Export() (base64Str string, err error)

type Image

type Image struct {
	// contains filtered or unexported fields
}

func (Image) Read

func (o Image) Read() (image.Image, error)

func (Image) Write

func (o Image) Write() error

type ImageReader

type ImageReader interface {
	Read() (image.Image, error)
}

func NewImageReader

func NewImageReader(path string) ImageReader

type ImageWriter

type ImageWriter interface {
	Write() error
}

func NewImageWriter

func NewImageWriter(img image.Image, path string) ImageWriter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL