common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Overview

Package common .

Index

Constants

View Source
const (
	Green = "#64DD17"
	Pink  = "#E91E63"
	Red   = "#FF1744"
	Blue  = "#2196F3"
)

Variables

View Source
var ZP = Point{}
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 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)

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 FreeCPoint2fVector

func FreeCPoint2fVector(c *C.Point2fVector)

FreeCPoint2fVector release C.Point2fVector 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) (image.Image, error)

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 NewCPoint2fVector

func NewCPoint2fVector() *C.Point2fVector

NewCPoint2fVector retruns C.Point2fVector pointer

func NewImageFromBytes

func NewImageFromBytes(data []byte, w int, h int, channels int) (image.Image, error)

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 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) Width

func (i Image) Width() int

Width returns image width

func (Image) WidthF64

func (i Image) WidthF64() float64

WidthF64 returns image width in float64

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
}

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 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 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