如何通过Gocv平滑文本边界?

时间:2019-10-14 10:13:13

标签: go


package main

import (
    "fmt"
    "image"
    "image/color"
    "image/jpeg"
    "os"

    "gocv.io/x/gocv"
)

func main() {
    height := 50
    width := 120
    defaultFontScale := 1.
    defaultThickness := 1
    backgroundColor := color.RGBA{240, 232, 243, 0}
    textColor := color.RGBA{108, 58, 98, 255}
    brandImage := gocv.NewMatWithSize(height, width, gocv.MatTypeCV8UC3)
    defer brandImage.Close()

    pointText := image.Point{6, 30}
    points := [][]image.Point{
        {
            image.Pt(0, 0),
            image.Pt(width, 0),
            image.Pt(width, height),
            image.Pt(0, height),
        },
    }
    gocv.Rectangle(&brandImage, image.Rect(0, 50, 120, 50), backgroundColor, defaultThickness)
    gocv.FillPoly(&brandImage, points, backgroundColor)
    gocv.PutText(&brandImage, "Mijello", pointText, gocv.FontHersheyComplex, defaultFontScale, textColor, defaultThickness)
    l, _ := brandImage.ToImage()
    f, _ := os.Create("pathToFile/brand.jpg")
    err := jpeg.Encode(f, l, nil)
    if err != nil {
        fmt.Println(err)
    }
}

它使图像 enter image description here

CC#中,我还有1个参数LineType,但我不知道如何像这样的示例那样平滑边框: enter image description here

感谢您的建议。

0 个答案:

没有答案