common

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Overview

Package common .

Index

Constants

View Source
const (
	White = "#FFFFFF"
	Black = "#000000"
	Gray  = "#333333"
	Green = "#64DD17"
	Pink  = "#E91E63"
	Red   = "#FF1744"
	Blue  = "#2196F3"
)

Variables

View Source
var FullRect = Rect(0, 0, 1, 1)
View Source
var ZP = Point{}
View Source
var ZP3d = Point3d{}
View Source
var ZR = Rectangle{}

Functions

func CObjectInfoVectiorLength

func CObjectInfoVectiorLength(c *C.ObjectInfoVector) int

CObjectInfoVectiorLength get C.ObjectInfoVector length

func CObjectInfoVectorPtr

func CObjectInfoVectorPtr(c *C.ObjectInfoVector) unsafe.Pointer

CObjectInfoVectorPtr get C.ObjectInfoVector start pointer

func ColorFromHex

func ColorFromHex(hexColor string) color.RGBA

ColorFromHex get color from hex

func CreateGPUInstance

func CreateGPUInstance() int

CreateGPUInstance create gpu instance

func DestroyEstimator

func DestroyEstimator(e Estimator)

DestroyEstimator destory an Estimator

func DestroyGPUInstance

func DestroyGPUInstance()

DestroyGPUInstance destory gpu instance

func DrawCircle

func DrawCircle(gc *draw2dimg.GraphicContext, pt Point, r float64, borderColor string, bgColor string, strokeWidth float64)

DrawCircle draw circle on image

func DrawLabel added in v1.0.1

func DrawLabel(gc *draw2dimg.GraphicContext, font *Font, label string, pt Point, txtColor string, bgColor string, scale float64)

DrawLabel draw label text to image

func DrawLabelInWidth added in v1.0.1

func DrawLabelInWidth(gc *draw2dimg.GraphicContext, font *Font, label string, pt Point, txtColor string, bgColor string, boundWidth float64)

DrawLabelInWidth draw label text to image in width restrict

func DrawRectangle

func DrawRectangle(gc *draw2dimg.GraphicContext, rect Rectangle, borderColor string, bgColor string, strokeWidth float64)

DrawRectangle draw rectangle on image

func EstimatorLoadModel

func EstimatorLoadModel(e Estimator, modelPath string) error

EstimatorLoadModel load detecter model

func FreeCBytes

func FreeCBytes(c *C.Bytes)

func FreeCFloatVector

func FreeCFloatVector(c *C.FloatVector)

FreeCFloatVector release C.FloatVector memory

func FreeCImage

func FreeCImage(c *C.Image)

FreeCImage free C.Image

func FreeCKeypointVector

func FreeCKeypointVector(points *C.KeypointVector)

FreeCKeypointVector release *C.KeypointVector memory

func FreeCObjectInfoVector

func FreeCObjectInfoVector(p *C.ObjectInfoVector)

FreeCObjectInfoVector release *C.ObjectInfoVector memory

func FreeCPalmObjectVector added in v1.0.1

func FreeCPalmObjectVector(p *C.PalmObjectVector)

FreeCPalmObjectVector release *C.PalmObjectVector memory

func FreeCPoint2fVector

func FreeCPoint2fVector(c *C.Point2fVector)

FreeCPoint2fVector release C.Point2fVector memory

func FreeCPoint3dVector added in v1.0.1

func FreeCPoint3dVector(c *C.Point3dVector)

FreeCPoint3dVector release C.Point3dVector memory

func GetBigCPUCount

func GetBigCPUCount() int

GetBigCPUCount get cpu number

func GetGPUCount

func GetGPUCount() int

GetGPUCount get gpu number

func GoBytes

func GoBytes(c *C.Bytes) []byte

func GoFloatVector

func GoFloatVector(cVector *C.FloatVector) []float64

GoFloatVector convert C.FloatVector to []float64

func GoImage

func GoImage(c *C.Image, out *Image)

GoImage returns Image from C.Image

func Image2BGR

func Image2BGR(buf io.Writer, img image.Image)

Image2BGR write image bgrdata to buffer

func Image2RGB

func Image2RGB(buf io.Writer, img image.Image)

Image2RGB write image rgbdata to buffer

func Image2RGBA

func Image2RGBA(buf io.Writer, img image.Image)

Image2RGBA write image rgbdata to buffer

func NewCBytes

func NewCBytes() *C.Bytes

func NewCFloatVector

func NewCFloatVector() *C.FloatVector

NewCFloatVector returns C.FloatVector pointer

func NewCImage

func NewCImage() *C.Image

NewCImage returns new C.Image

func NewCKeypointVector

func NewCKeypointVector() *C.KeypointVector

NewCKeypointVector returns *C.KeypointVector

func NewCObjectInfoVector

func NewCObjectInfoVector() *C.ObjectInfoVector

NewCObjectInfoector returns *C.ObjectInfoVector

func NewCPalmObjectVector added in v1.0.1

func NewCPalmObjectVector() *C.PalmObjectVector

NewCPalmObjectVector returns *C.PalmObjectVector

func NewCPoint2fVector

func NewCPoint2fVector() *C.Point2fVector

NewCPoint2fVector retruns C.Point2fVector pointer

func NewCPoint3dVector added in v1.0.1

func NewCPoint3dVector() *C.Point3dVector

NewCPoint3dVector retruns C.Point3dVector pointer

func NewFontCache added in v1.0.1

func NewFontCache(fontFolder string) *draw2d.SyncFolderFontCache

NewFontCache load font cache

func NewImageFromBytes

func NewImageFromBytes(data []byte, w int, h int, channels int, out *Image)

NewImageFromBytes returns Image by []byte

func SetEstimatorLightMode

func SetEstimatorLightMode(e Estimator, mode bool)

SetEstimatorLightMode set ncnn net opt.lightmode

func SetEstimatorThreads

func SetEstimatorThreads(e Estimator, n int)

SetEstimatorThreads set ncnn net opt.num_threads

func SetOMPThreads

func SetOMPThreads(n int)

SetOMPThreads set omp thread number

Types

type Estimator

type Estimator interface {
	LoadModel(modelPath string) error
	Destroy()
	Pointer() unsafe.Pointer
}

Estimator represents Estimator interface

type Font added in v1.0.1

type Font struct {
	// Cache FontCache
	Cache draw2d.FontCache
	// Size font size
	Size float64 `json:"size,omitempty"`
	// Data font setting
	Data *draw2d.FontData `json:"data,omitempty"`
	// Font
	Font *truetype.Font `json:"-"`
}

Font font info

func (*Font) Load added in v1.0.1

func (f *Font) Load(cache draw2d.FontCache) error

Load font from font cache

type Image

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

Image image with buffer cache

func NewImage

func NewImage(img image.Image) *Image

NewImage returns a new Image

func (Image) Bytes

func (i Image) Bytes() []byte

Bytes returns image bytes in rgb

func (Image) Height

func (i Image) Height() int

Height returns image height

func (Image) HeightF64

func (i Image) HeightF64() float64

HeightF64 returns image height in float64

func (Image) RGBABytes

func (i Image) RGBABytes() []byte

RGBABytes returns image bytes in rgba

func (*Image) Reset added in v1.0.1

func (i *Image) Reset()

func (Image) Width

func (i Image) Width() int

Width returns image width

func (Image) WidthF64

func (i Image) WidthF64() float64

WidthF64 returns image width in float64

func (*Image) Write added in v1.0.1

func (i *Image) Write(b []byte)

Write write bytes to buffer

type Keypoint

type Keypoint struct {
	// Point keypoint location
	Point Point
	// Score keypoint prob
	Score float32
}

Keypoint represents detected body keypoint

func GoKeypoint

func GoKeypoint(c *C.Keypoint, w float64, h float64) Keypoint

GoKeypoint convert C.Keypoint to go type

func GoKeypointVector

func GoKeypointVector(c *C.KeypointVector, w float64, h float64) []Keypoint

GoKeypointVector convert *C.KeypointVector to Keypoint slice

func (Keypoint) CKeypoint

func (k Keypoint) CKeypoint(w float64, h float64) *C.Keypoint

Convert Keypoint to C.Keypoint pointer

type ObjectInfo

type ObjectInfo struct {
	// Score detected score
	Score float32
	// Label
	Label int
	// Rect roi location
	Rect Rectangle
	// Points keypoints
	Keypoints []Keypoint
	// Name
	Name string
}

ObjectInfo represents detected roi object info

func GoObjectInfo

func GoObjectInfo(c *C.ObjectInfo, w float64, h float64) ObjectInfo

GoObjectInfo convert C.ObjectInfo to go type

func GoObjectInfoVector

func GoObjectInfoVector(c *C.ObjectInfoVector, w float64, h float64) []ObjectInfo

GoObjectInfoVector convert *C.ObjectInfoVector to ROI slice

func (ObjectInfo) ToCObjectInfo

func (o ObjectInfo) ToCObjectInfo(w float64, h float64) *C.ObjectInfo

ToCObjectInfo returns ObjectInfo C type

type PalmObject added in v1.0.1

type PalmObject struct {
	Name       string
	Score      float64
	Rotation   float64
	RectPoints []Point
	Landmarks  []Point
	Skeleton   []Point
	Skeleton3d []Point3d
}

PalmObject

func GoPalmObject added in v1.0.1

func GoPalmObject(cObj *C.PalmObject, w float64, h float64) PalmObject

GoPalmObject convert C.PalmObject to Go type

func GoPalmObjectVector added in v1.0.1

func GoPalmObjectVector(c *C.PalmObjectVector, w float64, h float64) []PalmObject

type Point

type Point struct {
	X float64
	Y float64
}

Point represents a Point

func GoPoint2f

func GoPoint2f(c *C.Point2f, w float64, h float64) Point

GoPoint2f conver C.Point2f to Point

func GoPoint2fVector

func GoPoint2fVector(cVector *C.Point2fVector, w float64, h float64) []Point

GoPoint2fVector convert C.Point2fVector to []Point

func Pt

func Pt(x, y float64) Point

Pt returns a New Point

type Point3d added in v1.0.1

type Point3d struct {
	X float64
	Y float64
	Z float64
}

Point3d represents a 3dPoint

func GoPoint3d added in v1.0.1

func GoPoint3d(c *C.Point3d) Point3d

GoPoint3d conver C.Point3d to Point3d

func GoPoint3dVector added in v1.0.1

func GoPoint3dVector(cVector *C.Point3dVector) []Point3d

GoPoint3dVector convert C.Point3dVector to []Point3d

func Pt3d added in v1.0.1

func Pt3d(x, y, z float64) Point3d

Pt3d returns a New Point3d

type Rectangle

type Rectangle struct {
	X      float64
	Y      float64
	Width  float64
	Height float64
}

Rectangle represents a Rectangle

func GoRect

func GoRect(c *C.Rect, w float64, h float64) Rectangle

GoRect convert C.Rect to go type

func Rect

func Rect(x, y, w, h float64) Rectangle

Rect returns a Retancle

func (Rectangle) CRect

func (r Rectangle) CRect(w float64, h float64) *C.Rect

CRect returns C.Rect

func (Rectangle) MaxX

func (r Rectangle) MaxX() float64

MaxX returns right x

func (Rectangle) MaxY

func (r Rectangle) MaxY() float64

MaxY returns bottom y

Jump to

Keyboard shortcuts

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