yolov11

package
v0.0.0-...-d793979 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawPoseResult

func DrawPoseResult(img image.Image, results []PoseResult) image.Image

DrawPoseResult 将骨架绘制到图片上

Params:

img: 原图
results: 姿态结果

Types

type ClassResult

type ClassResult struct {
	// 分类ID,例如:
	//	436: station wagon
	//	656: minivan
	// 详细映射参考:
	//	https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/ImageNet.yaml
	ClassID int
	Score   float32
}

ClassResult 分类结果

type ClsEngine

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

ClsEngine YOLOv11-cls Engine

func NewClsEngine

func NewClsEngine(cfg Config) (*ClsEngine, error)

NewClsEngine 初始化分类引擎

func (*ClsEngine) Destroy

func (e *ClsEngine) Destroy()

Destroy 释放相关资源

func (*ClsEngine) Predict

func (e *ClsEngine) Predict(img image.Image, topK int) ([]ClassResult, error)

Predict 执行分类推理

Params:

img: 待分类图片
topK: 指定返回概率最高的 K 个类别

type Config

type Config struct {
	ModelPath          string // ONNX 模型路径
	OnnxRuntimeLibPath string // ONNX Runtime 动态库路径

	// 推理参数
	ConfThreshold float32 // 置信度阈值 (默认 0.45)
	IOUThreshold  float32 // NMS IOU 阈值 (默认 0.5)
	MaskThreshold float32 // Mask 二值化阈值 (默认 0.5)

	// 模型参数
	InputSize     int // 默认 640
	NumClasses    int // 默认 80
	NumMaskCoeffs int // 默认 32
	NumKeyPoints  int // 默认 17

	// 可选参数
	UseCuda           bool // (可选) 是否启用 CUDA
	NumThreads        int  // (可选) ONNX 线程数, 默认由CPU核心数决定
	EnableCpuMemArena bool // (可选) 是否开启 ONNX 内存池
}

Config 引擎的初始化参数

func DefaultClsConfig

func DefaultClsConfig() Config

DefaultClsConfig 分类的默认配置

func DefaultConfig

func DefaultConfig() Config

DefaultConfig 默认配置

func DefaultDetConfig

func DefaultDetConfig() Config

DefaultDetConfig 检测的默认配置

func DefaultOBBConfig

func DefaultOBBConfig() Config

DefaultOBBConfig OBB的默认配置

func DefaultPoseConfig

func DefaultPoseConfig() Config

DefaultPoseConfig 姿势的默认配置

func DefaultSegConfig

func DefaultSegConfig() Config

DefaultSegConfig 分割的默认配置

type DetEngine

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

DetEngine YOLOv11-det Engine

func NewDetEngine

func NewDetEngine(cfg Config) (*DetEngine, error)

NewDetEngine 初始化检测引擎

func (*DetEngine) Destroy

func (e *DetEngine) Destroy()

Destroy 释放相关资源

func (*DetEngine) Predict

func (e *DetEngine) Predict(img image.Image) ([]DetResult, error)

Predict 执行检测推理

type DetResult

type DetResult struct {
	// 分类ID,例如:
	//	0: person
	//  1: bicycle
	//  2: car
	// - 详细映射参考:
	//	https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml
	ClassID int
	Score   float32
	Box     image.Rectangle // 检测框
}

DetResult 目标检测结果

type KeyPoint

type KeyPoint struct {
	X, Y  int     // 原图坐标
	Score float32 // 可见性/置信度
}

KeyPoint 单个关键点

type OBBEngine

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

OBBEngine YOLOv11-OBB Engine

func NewOBBEngine

func NewOBBEngine(cfg Config) (*OBBEngine, error)

NewOBBEngine 初始化 OBB 引擎

func (*OBBEngine) Destroy

func (e *OBBEngine) Destroy()

Destroy 释放相关资源

func (*OBBEngine) Predict

func (e *OBBEngine) Predict(img image.Image) ([]OBBResult, error)

Predict 执行旋转目标检测

type OBBResult

type OBBResult struct {
	ClassID int
	Score   float32
	// 旋转框的顶点坐标:TopLeft, TopRight, BottomRight, BottomLeft
	Corners [4]image.Point

	Center image.Point
	Angle  float32 // 弧度
}

OBBResult 旋转目标检测结果

type PoseEngine

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

PoseEngine YOLOv11-pose Engine

func NewPoseEngine

func NewPoseEngine(cfg Config) (*PoseEngine, error)

NewPoseEngine 初始化姿态引擎

func (*PoseEngine) Destroy

func (e *PoseEngine) Destroy()

Destroy 释放相关资源

func (*PoseEngine) Predict

func (e *PoseEngine) Predict(img image.Image) ([]PoseResult, error)

Predict 执行姿态估计

type PoseResult

type PoseResult struct {
	ClassID   int
	Score     float32
	Box       image.Rectangle
	KeyPoints []KeyPoint // 关键点列表
}

PoseResult 姿态估计结果

type SegEngine

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

SegEngine YOLOv11-seg Engine

func NewSegEngine

func NewSegEngine(cfg Config) (*SegEngine, error)

NewSegEngine 初始化分割引擎

func (*SegEngine) Destroy

func (e *SegEngine) Destroy()

Destroy 释放相关资源

func (*SegEngine) Predict

func (e *SegEngine) Predict(img image.Image) ([]SegResult, error)

Predict 执行分割推理

type SegResult

type SegResult struct {
	// 分类ID,例如:
	//	0: person
	//  1: bicycle
	//  2: car
	// 详细映射参考:
	//	https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/coco.yaml
	ClassID int
	Score   float32
	Box     image.Rectangle // 分割出的矩形区域
	Mask    *image.Gray     // 解码后的 Mask
}

SegResult 分割结果

Jump to

Keyboard shortcuts

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