Documentation
¶
Index ¶
- Variables
- func CheckGPUSupport()
- func ConvertFramesToVideo(framesDir, outputPath string, fps int) string
- func ConvertVideoToFrames(videoPath, outputDir string, fps int) string
- func DestroyEnvironment()
- func ExtractAudio(videoPath, audioPath string, codec ...string) error
- func GetCameraDeviceInfo() map[string]string
- func GetClasses() []string
- func GetGPUBenchmarkConfig(vramGB int) map[string]interface{}
- func GetOptimalGPUSettings() map[string]interface{}
- func HasAudioTrack(videoPath string) bool
- func HighEndGPUPerformanceTips()
- func HighPerformanceGPUBenchmarkConfig() map[string]interface{}
- func HighPerformanceGPUTips()
- func IsGPUAvailable() bool
- func ListCameraDevices() []string
- func ListScreenDevices() []string
- func SaveImage(img image.Image, path string) error
- func SetClasses(classes []string)
- func SetGUILauncher(launcher GUILauncher)
- func SetGUILauncherFunc(launcherFunc GUILauncherFunc)
- func StartLiveGUI(detector *YOLO, videoPath string, options *DetectionOptions) error
- type AppConfig
- type AudioSaveOptions
- type CameraVideoProcessor
- type CircuitBreaker
- type CircuitState
- type ConfigManager
- type Detection
- type DetectionOptions
- func (o *DetectionOptions) WithBoxColor(color string) *DetectionOptions
- func (o *DetectionOptions) WithConfThreshold(threshold float32) *DetectionOptions
- func (o *DetectionOptions) WithDrawBoxes(draw bool) *DetectionOptions
- func (o *DetectionOptions) WithDrawLabels(draw bool) *DetectionOptions
- func (o *DetectionOptions) WithFontSize(size int) *DetectionOptions
- func (o *DetectionOptions) WithIOUThreshold(threshold float32) *DetectionOptions
- func (o *DetectionOptions) WithLabelColor(color string) *DetectionOptions
- func (o *DetectionOptions) WithLineWidth(width int) *DetectionOptions
- func (o *DetectionOptions) WithShowFPS(show bool) *DetectionOptions
- type DetectionResults
- type GPUConfigStruct
- type GUILauncher
- type GUILauncherFunc
- type HealthChecker
- type ImprovedCUDAInitializer
- func (ici *ImprovedCUDAInitializer) Cleanup()
- func (ici *ImprovedCUDAInitializer) CompareWithCurrentImplementation() map[string]string
- func (ici *ImprovedCUDAInitializer) CreateSessionWithImprovedCUDA(modelPath string, inputNames, outputNames []string) (*ort.DynamicAdvancedSession, error)
- func (ici *ImprovedCUDAInitializer) GetInitializationSteps() []string
- func (ici *ImprovedCUDAInitializer) InitializeCUDAWithSuccessfulMethod() (*ort.SessionOptions, error)
- func (ici *ImprovedCUDAInitializer) TestCUDAInference(session *ort.DynamicAdvancedSession) error
- type InputSource
- func NewCameraInput(device string) *InputSource
- func NewCameraInputWithDevice(device string) *InputSource
- func NewFileInput(path string) *InputSource
- func NewRTMPInput(url string) *InputSource
- func NewRTSPInput(url string) *InputSource
- func NewScreenInput() *InputSource
- func NewScreenInputWithDevice(device string) *InputSource
- type PerformanceMetrics
- type ProcessResult
- type ProcessTask
- type RateLimiter
- type ResourceMonitor
- type SimpleVideoProcessor
- type UIConfig
- type VideoDetectionResult
- type VideoInfo
- type VideoOptimization
- func NewAdaptiveGPUVideoOptimization() *VideoOptimization
- func NewHighEndGPUVideoOptimization() *VideoOptimization
- func NewHighPerformanceGPUVideoOptimization() *VideoOptimization
- func NewVideoOptimization(enableGPU bool) *VideoOptimization
- func NewVideoOptimizationWithCUDA(enableGPU, enableCUDA bool, cudaDeviceID int) *VideoOptimization
- func (vo *VideoOptimization) AdjustPerformanceSettings(maxMemoryMB int64, maxGoroutines int64, maxCPU float64)
- func (vo *VideoOptimization) AsyncDetectImage(detector *YOLO, img image.Image, id int)
- func (vo *VideoOptimization) BatchDetectImages(detector *YOLO, images []image.Image) ([][]Detection, error)
- func (vo *VideoOptimization) Close()
- func (vo *VideoOptimization) GetAsyncResult() *ProcessResult
- func (vo *VideoOptimization) GetAsyncResultBlocking() *ProcessResult
- func (vo *VideoOptimization) GetBatchSize() int
- func (vo *VideoOptimization) GetCUDADeviceID() int
- func (vo *VideoOptimization) GetCUDAPerformanceMetrics() map[string]interface{}
- func (vo *VideoOptimization) GetGCStats() map[string]interface{}
- func (vo *VideoOptimization) GetMaxBatchSize() int
- func (vo *VideoOptimization) GetParallelWorkers() int
- func (vo *VideoOptimization) GetPreprocessBuffer() [][]float32
- func (vo *VideoOptimization) GetQueueStatus() (asyncQueueLen, processDoneLen, availableWorkers int)
- func (vo *VideoOptimization) GetStabilityStatus() map[string]interface{}
- func (vo *VideoOptimization) HasPendingResults() bool
- func (vo *VideoOptimization) IsCUDAEnabled() bool
- func (vo *VideoOptimization) IsGPUEnabled() bool
- func (vo *VideoOptimization) IsHealthy() bool
- func (vo *VideoOptimization) OptimizeCUDAMemory() error
- func (vo *VideoOptimization) OptimizedDetectImage(detector *YOLO, img image.Image) ([]Detection, error)
- func (vo *VideoOptimization) OptimizedPreprocessImage(img image.Image, inputWidth, inputHeight int) ([]float32, error)
- func (vo *VideoOptimization) ResetFrameCounter()
- func (vo *VideoOptimization) ResetStabilityMetrics()
- func (vo *VideoOptimization) SetCircuitBreakerSettings(maxFailures int64, timeout, retryTimeout time.Duration)
- func (vo *VideoOptimization) SetGCInterval(interval int64)
- func (vo *VideoOptimization) SetRateLimitSettings(maxTokens, refillRate int64)
- func (vo *VideoOptimization) SmartGarbageCollect(forceGC bool)
- type VideoOptions
- type VidioVideoProcessor
- func (vp *VidioVideoProcessor) GetOptimization() *VideoOptimization
- func (vp *VidioVideoProcessor) ProcessVideo(inputPath string) ([]VideoDetectionResult, error)
- func (vp *VidioVideoProcessor) ProcessVideoWithCallback(inputPath string, callback func(VideoDetectionResult)) error
- func (vp *VidioVideoProcessor) SaveVideoWithDetections(inputPath, outputPath string) error
- type YOLO
- func NewYOLO(modelPath, configPath string, config ...*YOLOConfig) (*YOLO, error)
- func NewYOLOFromConfig(modelPath string, configManager *ConfigManager, libraryPath string) (*YOLO, error)
- func NewYOLOWithConfig(modelPath, configPath string, config *YOLOConfig) (*YOLO, error)
- func NewYOLOWithPreset(modelPath, configPath, preset, libraryPath string) (*YOLO, error)
- func (y *YOLO) AddCustomOutputShape(shape []int64)
- func (y *YOLO) ClearCustomOutputShapes()
- func (y *YOLO) Close()
- func (y *YOLO) Detect(inputPath string, options *DetectionOptions, callbacks ...interface{}) (*DetectionResults, error)
- func (y *YOLO) DetectAndSave(imagePath, outputPath string) ([]Detection, error)
- func (y *YOLO) DetectFromCamera(device string, options *DetectionOptions, ...) (*DetectionResults, error)
- func (y *YOLO) DetectFromRTMP(rtmpURL string, options *DetectionOptions, ...) (*DetectionResults, error)
- func (y *YOLO) DetectFromRTSP(rtspURL string, options *DetectionOptions, ...) (*DetectionResults, error)
- func (y *YOLO) DetectFromScreen(options *DetectionOptions, callback ...func(VideoDetectionResult)) (*DetectionResults, error)
- func (y *YOLO) DetectImage(imagePath string) ([]Detection, error)
- func (y *YOLO) DetectVideo(inputPath string, showLive ...bool) ([]VideoDetectionResult, error)
- func (y *YOLO) DetectVideoAdvanced(inputPath, outputPath string, options VideoOptions) error
- func (y *YOLO) DetectVideoAndSave(inputPath, outputPath string, showLive ...bool) error
- func (y *YOLO) GetCustomOutputShapes() [][]int64
- func (y *YOLO) GetVideoProcessor() *VidioVideoProcessor
- func (y *YOLO) SetCustomOutputShapes(shapes [][]int64)
- func (y *YOLO) SetOutputShapeForClasses(numClasses int, anchors ...int)
- func (y *YOLO) SetRuntimeConfig(options *DetectionOptions)
- func (y *YOLO) Show(inputPath string, outputPath ...string) error
- func (y *YOLO) ShowLive(inputPath string) error
- func (y *YOLO) ShowLiveWindow(videoPath string, opts *DetectionOptions) error
- type YOLOConfig
- func AutoDetectInputSizeConfig(modelPath string) *YOLOConfig
- func CUDAAcceleratedConfig() *YOLOConfig
- func DefaultConfig() *YOLOConfig
- func DefaultConfigWithModelPath(modelPath string) *YOLOConfig
- func ExtremeCUDAConfig() *YOLOConfig
- func ExtremePerformanceConfig() *YOLOConfig
- func GetGPUConfig() *YOLOConfig
- func GetOptimalConfig() *YOLOConfig
- func HighEndGPUOptimizedConfig() *YOLOConfig
- func HighPerformanceConfig() *YOLOConfig
- func HighPerformanceGPUConfig() *YOLOConfig
- func MaxPerformanceCPUConfig() *YOLOConfig
- func MaxPerformanceGPUConfig() *YOLOConfig
- func (c *YOLOConfig) WithAutoCreateConfig(autoCreate bool) *YOLOConfig
- func (c *YOLOConfig) WithCUDA(use bool) *YOLOConfig
- func (c *YOLOConfig) WithCUDADeviceID(deviceID int) *YOLOConfig
- func (c *YOLOConfig) WithCUDAMemoryPool(enable bool) *YOLOConfig
- func (c *YOLOConfig) WithGPU(use bool) *YOLOConfig
- func (c *YOLOConfig) WithGPUDeviceID(deviceID int) *YOLOConfig
- func (c *YOLOConfig) WithInputDimensions(width, height int) *YOLOConfig
- func (c *YOLOConfig) WithInputSize(size int) *YOLOConfig
- func (c *YOLOConfig) WithLibraryPath(path string) *YOLOConfig
Constants ¶
This section is empty.
Variables ¶
var ( // GPUConfig GPU配置 GPUConfig = func() *YOLOConfig { return DefaultConfig().WithGPU(true) } // CPUConfig CPU配置 CPUConfig = func() *YOLOConfig { return DefaultConfig().WithGPU(false) } )
预设配置(检测器级别)
Functions ¶
func ConvertFramesToVideo ¶
ConvertFramesToVideo 提供帧转视频的命令建议
func ConvertVideoToFrames ¶
ConvertVideoToFrames 提供视频转帧的命令建议
func DestroyEnvironment ¶
func DestroyEnvironment()
DestroyEnvironment 销毁ONNX Runtime环境(在所有检测器都关闭后调用)
func ExtractAudio ¶
ExtractAudio 从视频中提取音频
func GetCameraDeviceInfo ¶
GetCameraDeviceInfo 获取摄像头设备信息
func GetGPUBenchmarkConfig ¶
GetGPUBenchmarkConfig 获取GPU基准测试配置 根据显存大小返回相应的性能预期
func GetOptimalGPUSettings ¶
func GetOptimalGPUSettings() map[string]interface{}
GetOptimalGPUSettings 获取当前GPU的最优设置建议
func HighEndGPUPerformanceTips ¶
func HighEndGPUPerformanceTips()
HighEndGPUPerformanceTips 高端GPU性能优化建议
func HighPerformanceGPUBenchmarkConfig ¶
func HighPerformanceGPUBenchmarkConfig() map[string]interface{}
HighPerformanceGPUBenchmarkConfig 高性能GPU基准测试配置(向后兼容)
func HighPerformanceGPUTips ¶
func HighPerformanceGPUTips()
HighPerformanceGPUTips 高性能GPU性能优化建议(向后兼容)
func SetGUILauncherFunc ¶
func SetGUILauncherFunc(launcherFunc GUILauncherFunc)
SetGUILauncherFunc 设置GUI启动器函数
func StartLiveGUI ¶
func StartLiveGUI(detector *YOLO, videoPath string, options *DetectionOptions) error
StartLiveGUI 启动实时GUI窗口
Types ¶
type AppConfig ¶
type AppConfig struct {
YOLO YOLOConfig `yaml:"yolo"`
GPU GPUConfigStruct `yaml:"gpu"`
UI UIConfig `yaml:"ui"`
}
AppConfig 应用程序配置
type AudioSaveOptions ¶
type AudioSaveOptions struct {
PreserveAudio bool // 是否保留音频
AudioCodec string // 音频编解码器 (默认: "aac")
AudioBitrate string // 音频比特率 (默认: "128k")
TempDir string // 临时文件目录
Quality float64 // 视频质量 (0.0-1.0)
}
AudioSaveOptions 音频保存选项
func DefaultAudioSaveOptions ¶
func DefaultAudioSaveOptions() *AudioSaveOptions
DefaultAudioSaveOptions 返回默认的音频保存选项
type CameraVideoProcessor ¶
type CameraVideoProcessor struct {
// contains filtered or unexported fields
}
CameraVideoProcessor 专门处理摄像头输入的视频处理器
func NewCameraVideoProcessor ¶
func NewCameraVideoProcessor(detector *YOLO, inputPath string) *CameraVideoProcessor
NewCameraVideoProcessor 创建摄像头视频处理器
func (*CameraVideoProcessor) GetFrameCount ¶
func (cvp *CameraVideoProcessor) GetFrameCount() int64
GetFrameCount 获取处理的帧数
func (*CameraVideoProcessor) IsRunning ¶
func (cvp *CameraVideoProcessor) IsRunning() bool
IsRunning 检查是否正在运行
func (*CameraVideoProcessor) ProcessCameraWithCallback ¶
func (cvp *CameraVideoProcessor) ProcessCameraWithCallback(callback func(VideoDetectionResult)) error
ProcessCameraWithCallback 处理摄像头输入并通过VideoDetectionResult回调返回结果
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker 熔断器 - 防止系统过载
type ConfigManager ¶
type ConfigManager struct {
// contains filtered or unexported fields
}
ConfigManager 配置管理器
func NewConfigManager ¶
func NewConfigManager(configPath string) *ConfigManager
NewConfigManager 创建配置管理器
func (*ConfigManager) CreateDefaultConfig ¶
func (cm *ConfigManager) CreateDefaultConfig() error
CreateDefaultConfig 创建默认配置文件
func (*ConfigManager) GetGPUConfig ¶
func (cm *ConfigManager) GetGPUConfig() *GPUConfigStruct
GetGPUConfig 获取GPU配置
func (*ConfigManager) GetUIConfig ¶
func (cm *ConfigManager) GetUIConfig() *UIConfig
GetUIConfig 获取UI配置
func (*ConfigManager) GetYOLOConfig ¶
func (cm *ConfigManager) GetYOLOConfig() *YOLOConfig
GetYOLOConfig 获取YOLO配置
type DetectionOptions ¶
type DetectionOptions struct {
ConfThreshold float32 // 置信度阈值
IOUThreshold float32 // IOU阈值
DrawBoxes bool // 是否绘制检测框
DrawLabels bool // 是否绘制标签
ShowFPS bool // 是否显示FPS
BoxColor string // 检测框颜色
LabelColor string // 标签颜色
LineWidth int // 线条宽度
FontSize int // 字体大小
}
DetectionOptions 检测选项
func DefaultDetectionOptions ¶
func DefaultDetectionOptions() *DetectionOptions
DefaultDetectionOptions 默认检测选项(运行时级别)
func (*DetectionOptions) WithBoxColor ¶
func (o *DetectionOptions) WithBoxColor(color string) *DetectionOptions
WithBoxColor 设置框的颜色
func (*DetectionOptions) WithConfThreshold ¶
func (o *DetectionOptions) WithConfThreshold(threshold float32) *DetectionOptions
WithConfThreshold 设置置信度阈值
func (*DetectionOptions) WithDrawBoxes ¶
func (o *DetectionOptions) WithDrawBoxes(draw bool) *DetectionOptions
WithDrawBoxes 设置是否画框
func (*DetectionOptions) WithDrawLabels ¶
func (o *DetectionOptions) WithDrawLabels(draw bool) *DetectionOptions
WithDrawLabels 设置是否画标签
func (*DetectionOptions) WithFontSize ¶
func (o *DetectionOptions) WithFontSize(size int) *DetectionOptions
WithFontSize 设置字体大小
func (*DetectionOptions) WithIOUThreshold ¶
func (o *DetectionOptions) WithIOUThreshold(threshold float32) *DetectionOptions
WithIOUThreshold 设置IOU阈值
func (*DetectionOptions) WithLabelColor ¶
func (o *DetectionOptions) WithLabelColor(color string) *DetectionOptions
WithLabelColor 设置标签的颜色
func (*DetectionOptions) WithLineWidth ¶
func (o *DetectionOptions) WithLineWidth(width int) *DetectionOptions
WithLineWidth 设置线条宽度
func (*DetectionOptions) WithShowFPS ¶
func (o *DetectionOptions) WithShowFPS(show bool) *DetectionOptions
WithShowFPS 设置是否显示FPS
type DetectionResults ¶
type DetectionResults struct {
Detections []Detection
InputPath string
// 新增:存储视频的逐帧检测结果
VideoResults []VideoDetectionResult
// contains filtered or unexported fields
}
DetectionResults 检测结果集合
func (*DetectionResults) Save ¶
func (dr *DetectionResults) Save(outputPath string) error
Save 保存检测结果到指定路径
func (*DetectionResults) SaveWithAudio ¶
func (dr *DetectionResults) SaveWithAudio(outputPath string) error
SaveWithAudio 保存视频并保留音频
type GPUConfigStruct ¶
type GPUConfigStruct struct {
Enabled bool `yaml:"enabled"`
DeviceID int `yaml:"device_id"`
MemoryLimit string `yaml:"memory_limit"`
}
GPUConfigStruct GPU配置结构
type GUILauncher ¶
type GUILauncher interface {
LaunchLiveWindow(detector *YOLO, videoPath string, options *DetectionOptions) error
}
GUILauncher 接口用于启动GUI窗口
type GUILauncherFunc ¶
type GUILauncherFunc func(detector *YOLO, videoPath string, options *DetectionOptions) error
GUILauncherFunc 函数类型用于启动GUI窗口
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker 健康检查器 - 检查系统健康状态
type ImprovedCUDAInitializer ¶
type ImprovedCUDAInitializer struct {
// contains filtered or unexported fields
}
ImprovedCUDAInitializer 改进的CUDA初始化器 基于用户成功案例的CUDA初始化方式
func NewImprovedCUDAInitializer ¶
func NewImprovedCUDAInitializer(libraryPath string, deviceID int) *ImprovedCUDAInitializer
NewImprovedCUDAInitializer 创建改进的CUDA初始化器
func (*ImprovedCUDAInitializer) Cleanup ¶
func (ici *ImprovedCUDAInitializer) Cleanup()
Cleanup 清理资源
func (*ImprovedCUDAInitializer) CompareWithCurrentImplementation ¶
func (ici *ImprovedCUDAInitializer) CompareWithCurrentImplementation() map[string]string
CompareWithCurrentImplementation 与当前实现的对比
func (*ImprovedCUDAInitializer) CreateSessionWithImprovedCUDA ¶
func (ici *ImprovedCUDAInitializer) CreateSessionWithImprovedCUDA(modelPath string, inputNames, outputNames []string) (*ort.DynamicAdvancedSession, error)
CreateSessionWithImprovedCUDA 使用改进的CUDA方法创建Session
func (*ImprovedCUDAInitializer) GetInitializationSteps ¶
func (ici *ImprovedCUDAInitializer) GetInitializationSteps() []string
GetInitializationSteps 获取初始化步骤说明
func (*ImprovedCUDAInitializer) InitializeCUDAWithSuccessfulMethod ¶
func (ici *ImprovedCUDAInitializer) InitializeCUDAWithSuccessfulMethod() (*ort.SessionOptions, error)
InitializeCUDAWithSuccessfulMethod 使用成功的方法初始化CUDA 基于用户提供的成功案例
func (*ImprovedCUDAInitializer) TestCUDAInference ¶
func (ici *ImprovedCUDAInitializer) TestCUDAInference(session *ort.DynamicAdvancedSession) error
TestCUDAInference 测试CUDA推理
type InputSource ¶
type InputSource struct {
Type string // "file", "camera", "rtsp", "rtmp", "screen"
Path string // 输入路径
Options map[string]string // 额外选项
}
InputSource 输入源类型
func NewCameraInputWithDevice ¶
func NewCameraInputWithDevice(device string) *InputSource
NewCameraInputWithDevice 创建指定设备的摄像头输入源
func NewRTMPInput ¶
func NewRTMPInput(url string) *InputSource
NewRTMPInput 创建RTMP流输入源 支持带认证的URL格式: rtmp://username:password@host:port/app/stream
func NewRTSPInput ¶
func NewRTSPInput(url string) *InputSource
NewRTSPInput 创建RTSP流输入源 支持带认证的URL格式: rtsp://username:password@host:port/path
func NewScreenInputWithDevice ¶
func NewScreenInputWithDevice(device string) *InputSource
NewScreenInputWithDevice 创建指定设备的屏幕录制输入源
func (*InputSource) GetCameraIndex ¶
func (is *InputSource) GetCameraIndex() int
GetCameraIndex 获取摄像头索引(用于兼容性)
func (*InputSource) GetFFmpegInput ¶
func (is *InputSource) GetFFmpegInput() string
GetFFmpegInput 获取FFmpeg输入参数
func (*InputSource) GetFFmpegOptions ¶
func (is *InputSource) GetFFmpegOptions() []string
GetFFmpegOptions 获取FFmpeg选项
func (*InputSource) GetInputType ¶
func (is *InputSource) GetInputType() string
GetInputType 获取输入源类型
type PerformanceMetrics ¶
type PerformanceMetrics struct {
// contains filtered or unexported fields
}
PerformanceMetrics 性能指标 - 记录性能数据
type ProcessResult ¶
type ProcessResult struct {
// contains filtered or unexported fields
}
ProcessResult 处理结果
type ProcessTask ¶
type ProcessTask struct {
// contains filtered or unexported fields
}
ProcessTask 异步处理任务
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter 限流器 - 控制调用频率
type ResourceMonitor ¶
type ResourceMonitor struct {
// contains filtered or unexported fields
}
ResourceMonitor 资源监控器 - 监控系统资源
type SimpleVideoProcessor ¶
type SimpleVideoProcessor struct {
// contains filtered or unexported fields
}
SimpleVideoProcessor 简单视频处理器(使用标准库)
func NewSimpleVideoProcessor ¶
func NewSimpleVideoProcessor(detector *YOLO) *SimpleVideoProcessor
NewSimpleVideoProcessor 创建简单视频处理器
func (*SimpleVideoProcessor) ProcessImageSequence ¶
func (svp *SimpleVideoProcessor) ProcessImageSequence(inputDir, outputDir string) error
ProcessImageSequence 处理图像序列
func (*SimpleVideoProcessor) ProcessImageWithCallback ¶
func (svp *SimpleVideoProcessor) ProcessImageWithCallback(inputDir string, callback func(VideoDetectionResult)) error
ProcessImageWithCallback 处理图像并调用回调函数
type UIConfig ¶
type UIConfig struct {
DrawBoxes bool `yaml:"draw_boxes"`
DrawLabels bool `yaml:"draw_labels"`
ShowFPS bool `yaml:"show_fps"`
}
UIConfig 界面配置
type VideoDetectionResult ¶
type VideoDetectionResult struct {
FrameNumber int
Timestamp time.Duration
Detections []Detection
Image image.Image
}
VideoDetectionResult 视频检测结果
type VideoInfo ¶
type VideoInfo struct {
Path string // 视频路径
HasAudio bool // 是否包含音频
RawInfo string // 原始信息(JSON格式)
}
VideoInfo 视频信息
func GetVideoInfo ¶
GetVideoInfo 获取视频信息(包括音频信息)
type VideoOptimization ¶
type VideoOptimization struct {
// contains filtered or unexported fields
}
VideoOptimization GPU优化相关的结构体和方法 - 疯狂调用稳定版 + CUDA加速
func NewAdaptiveGPUVideoOptimization ¶
func NewAdaptiveGPUVideoOptimization() *VideoOptimization
NewAdaptiveGPUVideoOptimization 创建自适应GPU视频优化实例 根据检测到的显存大小自动调整批处理和内存池配置
func NewHighEndGPUVideoOptimization ¶
func NewHighEndGPUVideoOptimization() *VideoOptimization
NewHighEndGPUVideoOptimization 创建高端GPU通用视频优化实例 自动检测显存大小并调整配置:大显存显卡(20GB+), 中高端显卡(12-16GB), 中端显卡(8-10GB)等
func NewHighPerformanceGPUVideoOptimization ¶
func NewHighPerformanceGPUVideoOptimization() *VideoOptimization
NewHighPerformanceGPUVideoOptimization 创建高性能GPU专用视频优化实例
func NewVideoOptimization ¶
func NewVideoOptimization(enableGPU bool) *VideoOptimization
NewVideoOptimization 创建视频优化实例 - 疯狂调用稳定版本 + CUDA加速
func NewVideoOptimizationWithCUDA ¶
func NewVideoOptimizationWithCUDA(enableGPU, enableCUDA bool, cudaDeviceID int) *VideoOptimization
NewVideoOptimizationWithCUDA 创建带CUDA加速的视频优化实例
func (*VideoOptimization) AdjustPerformanceSettings ¶
func (vo *VideoOptimization) AdjustPerformanceSettings(maxMemoryMB int64, maxGoroutines int64, maxCPU float64)
AdjustPerformanceSettings 动态调整性能设置 - 疯狂调用优化
func (*VideoOptimization) AsyncDetectImage ¶
func (vo *VideoOptimization) AsyncDetectImage(detector *YOLO, img image.Image, id int)
AsyncDetectImage 异步检测图像
func (*VideoOptimization) BatchDetectImages ¶
func (vo *VideoOptimization) BatchDetectImages(detector *YOLO, images []image.Image) ([][]Detection, error)
BatchDetectImages 批量检测图像 - 极致GPU性能 + CUDA加速
func (*VideoOptimization) Close ¶
func (vo *VideoOptimization) Close()
Close 关闭VideoOptimization,清理资源 - 疯狂调用安全关闭 + CUDA加速
func (*VideoOptimization) GetAsyncResult ¶
func (vo *VideoOptimization) GetAsyncResult() *ProcessResult
GetAsyncResult 获取异步处理结果
func (*VideoOptimization) GetAsyncResultBlocking ¶
func (vo *VideoOptimization) GetAsyncResultBlocking() *ProcessResult
GetAsyncResultBlocking 阻塞获取异步处理结果
func (*VideoOptimization) GetBatchSize ¶
func (vo *VideoOptimization) GetBatchSize() int
GetBatchSize 获取批处理大小
func (*VideoOptimization) GetCUDADeviceID ¶
func (vo *VideoOptimization) GetCUDADeviceID() int
GetCUDADeviceID 获取CUDA设备ID
func (*VideoOptimization) GetCUDAPerformanceMetrics ¶
func (vo *VideoOptimization) GetCUDAPerformanceMetrics() map[string]interface{}
GetCUDAPerformanceMetrics 获取CUDA性能指标 GetCUDAPerformanceMetrics 获取CUDA性能指标(已简化) 注意:自定义CUDA加速器已移除,此方法仅返回基本状态信息
func (*VideoOptimization) GetGCStats ¶
func (vo *VideoOptimization) GetGCStats() map[string]interface{}
GetGCStats 获取垃圾回收统计信息
func (*VideoOptimization) GetMaxBatchSize ¶
func (vo *VideoOptimization) GetMaxBatchSize() int
GetMaxBatchSize 获取最大批处理大小
func (*VideoOptimization) GetParallelWorkers ¶
func (vo *VideoOptimization) GetParallelWorkers() int
GetParallelWorkers 获取并行工作线程数
func (*VideoOptimization) GetPreprocessBuffer ¶
func (vo *VideoOptimization) GetPreprocessBuffer() [][]float32
GetPreprocessBuffer 获取预处理缓冲区
func (*VideoOptimization) GetQueueStatus ¶
func (vo *VideoOptimization) GetQueueStatus() (asyncQueueLen, processDoneLen, availableWorkers int)
GetQueueStatus 获取队列状态信息
func (*VideoOptimization) GetStabilityStatus ¶
func (vo *VideoOptimization) GetStabilityStatus() map[string]interface{}
GetStabilityStatus 获取稳定性状态信息 - 疯狂调用监控
func (*VideoOptimization) HasPendingResults ¶
func (vo *VideoOptimization) HasPendingResults() bool
HasPendingResults 检查是否有待处理的结果
func (*VideoOptimization) IsCUDAEnabled ¶
func (vo *VideoOptimization) IsCUDAEnabled() bool
IsCUDAEnabled 检查是否启用CUDA加速 注意:现在仅检查enableCUDA标志,因为自定义CUDA加速器已移除
func (*VideoOptimization) IsGPUEnabled ¶
func (vo *VideoOptimization) IsGPUEnabled() bool
IsGPUEnabled 检查是否启用GPU
func (*VideoOptimization) IsHealthy ¶
func (vo *VideoOptimization) IsHealthy() bool
IsHealthy 检查VideoOptimization的健康状态 - 疯狂调用健康检查
func (*VideoOptimization) OptimizeCUDAMemory ¶
func (vo *VideoOptimization) OptimizeCUDAMemory() error
OptimizeCUDAMemory 优化CUDA内存使用(已简化) 注意:自定义CUDA加速器已移除,此方法不再执行实际的内存优化
func (*VideoOptimization) OptimizedDetectImage ¶
func (vo *VideoOptimization) OptimizedDetectImage(detector *YOLO, img image.Image) ([]Detection, error)
OptimizedDetectImage 优化的图像检测方法
func (*VideoOptimization) OptimizedPreprocessImage ¶
func (vo *VideoOptimization) OptimizedPreprocessImage(img image.Image, inputWidth, inputHeight int) ([]float32, error)
OptimizedPreprocessImage 优化的图像预处理方法 - 极致性能版本 + CUDA加速
func (*VideoOptimization) ResetFrameCounter ¶
func (vo *VideoOptimization) ResetFrameCounter()
ResetFrameCounter 重置帧计数器
func (*VideoOptimization) ResetStabilityMetrics ¶
func (vo *VideoOptimization) ResetStabilityMetrics()
ResetStabilityMetrics 重置稳定性指标 - 用于长期运行重置
func (*VideoOptimization) SetCircuitBreakerSettings ¶
func (vo *VideoOptimization) SetCircuitBreakerSettings(maxFailures int64, timeout, retryTimeout time.Duration)
SetCircuitBreakerSettings 动态调整熔断器设置 - 疯狂调用保护
func (*VideoOptimization) SetGCInterval ¶
func (vo *VideoOptimization) SetGCInterval(interval int64)
SetGCInterval 设置垃圾回收间隔
func (*VideoOptimization) SetRateLimitSettings ¶
func (vo *VideoOptimization) SetRateLimitSettings(maxTokens, refillRate int64)
SetRateLimitSettings 动态调整限流设置 - 疯狂调用控制
func (*VideoOptimization) SmartGarbageCollect ¶
func (vo *VideoOptimization) SmartGarbageCollect(forceGC bool)
SmartGarbageCollect 智能垃圾回收 - 安全地清理内存而不影响保存功能
type VideoOptions ¶
VideoOptions 视频处理选项
type VidioVideoProcessor ¶
type VidioVideoProcessor struct {
// contains filtered or unexported fields
}
VidioVideoProcessor 使用Vidio库的视频处理器
func NewVidioVideoProcessor ¶
func NewVidioVideoProcessor(detector *YOLO) *VidioVideoProcessor
NewVidioVideoProcessor 创建Vidio视频处理器
func NewVidioVideoProcessorWithOptions ¶
func NewVidioVideoProcessorWithOptions(detector *YOLO, options *DetectionOptions) *VidioVideoProcessor
NewVidioVideoProcessorWithOptions 创建带配置选项的Vidio视频处理器
func (*VidioVideoProcessor) GetOptimization ¶
func (vp *VidioVideoProcessor) GetOptimization() *VideoOptimization
GetOptimization 获取视频优化实例
func (*VidioVideoProcessor) ProcessVideo ¶
func (vp *VidioVideoProcessor) ProcessVideo(inputPath string) ([]VideoDetectionResult, error)
ProcessVideo 处理视频文件并返回所有检测结果
func (*VidioVideoProcessor) ProcessVideoWithCallback ¶
func (vp *VidioVideoProcessor) ProcessVideoWithCallback(inputPath string, callback func(VideoDetectionResult)) error
ProcessVideoWithCallback 处理视频并对每帧调用回调函数(优化版本)
func (*VidioVideoProcessor) SaveVideoWithDetections ¶
func (vp *VidioVideoProcessor) SaveVideoWithDetections(inputPath, outputPath string) error
SaveVideoWithDetections 保存带检测框的视频
type YOLO ¶
type YOLO struct {
// contains filtered or unexported fields
}
YOLO 检测器
func NewYOLO ¶
func NewYOLO(modelPath, configPath string, config ...*YOLOConfig) (*YOLO, error)
NewYOLO 创建新的YOLO检测器(配置文件必须,YOLOConfig可选)
func NewYOLOFromConfig ¶
func NewYOLOFromConfig(modelPath string, configManager *ConfigManager, libraryPath string) (*YOLO, error)
便捷方法:从配置管理器创建YOLO
func NewYOLOWithConfig ¶
func NewYOLOWithConfig(modelPath, configPath string, config *YOLOConfig) (*YOLO, error)
NewYOLOWithConfig 创建新的YOLO检测器(支持配置文件)
func NewYOLOWithPreset ¶
便捷方法:使用预设配置创建YOLO(需要配置文件路径)
func (*YOLO) AddCustomOutputShape ¶
AddCustomOutputShape 添加单个自定义输出形状 shape: 输出形状,格式为 [batch, features, anchors] 例如: [1, 5, 8400] 表示1类别模型
func (*YOLO) ClearCustomOutputShapes ¶
func (y *YOLO) ClearCustomOutputShapes()
ClearCustomOutputShapes 清除所有自定义输出形状,恢复使用默认探测列表
func (*YOLO) Detect ¶
func (y *YOLO) Detect(inputPath string, options *DetectionOptions, callbacks ...interface{}) (*DetectionResults, error)
Detect 检测并返回结果(不保存),支持可选的回调函数
func (*YOLO) DetectAndSave ¶
DetectAndSave 检测图片并保存结果
func (*YOLO) DetectFromCamera ¶
func (y *YOLO) DetectFromCamera(device string, options *DetectionOptions, callback ...func(VideoDetectionResult)) (*DetectionResults, error)
DetectFromCamera 从摄像头检测对象,统一使用VideoDetectionResult回调
func (*YOLO) DetectFromRTMP ¶
func (y *YOLO) DetectFromRTMP(rtmpURL string, options *DetectionOptions, callback ...func(VideoDetectionResult)) (*DetectionResults, error)
DetectFromRTMP 从RTMP流进行实时检测,支持可选的回调函数
func (*YOLO) DetectFromRTSP ¶
func (y *YOLO) DetectFromRTSP(rtspURL string, options *DetectionOptions, callback ...func(VideoDetectionResult)) (*DetectionResults, error)
DetectFromRTSP 从RTSP流进行实时检测,支持可选的回调函数
func (*YOLO) DetectFromScreen ¶
func (y *YOLO) DetectFromScreen(options *DetectionOptions, callback ...func(VideoDetectionResult)) (*DetectionResults, error)
DetectFromScreen 从屏幕录制进行实时检测,支持可选的回调函数
func (*YOLO) DetectImage ¶
DetectImage 检测单张图片
func (*YOLO) DetectVideo ¶
func (y *YOLO) DetectVideo(inputPath string, showLive ...bool) ([]VideoDetectionResult, error)
DetectVideo 检测视频文件(MP4等)
func (*YOLO) DetectVideoAdvanced ¶
func (y *YOLO) DetectVideoAdvanced(inputPath, outputPath string, options VideoOptions) error
DetectVideoAdvanced 高级视频检测(支持更多选项)
func (*YOLO) DetectVideoAndSave ¶
DetectVideoAndSave 检测视频并保存结果
func (*YOLO) GetCustomOutputShapes ¶
GetCustomOutputShapes 获取当前设置的自定义输出形状列表
func (*YOLO) GetVideoProcessor ¶
func (y *YOLO) GetVideoProcessor() *VidioVideoProcessor
便捷方法:获取视频处理器
func (*YOLO) SetCustomOutputShapes ¶
SetCustomOutputShapes 设置自定义输出形状探测列表 shapes: 输出形状列表,每个形状为 [batch, features, anchors] 格式 例如: [[1, 5, 8400], [1, 84, 8400]] 表示支持1类别和80类别的模型
func (*YOLO) SetOutputShapeForClasses ¶
SetOutputShapeForClasses 根据类别数量设置输出形状 numClasses: 类别数量 anchors: 锚点数量,默认为8400
func (*YOLO) SetRuntimeConfig ¶
func (y *YOLO) SetRuntimeConfig(options *DetectionOptions)
SetRuntimeConfig 设置运行时检测配置
func (*YOLO) ShowLiveWindow ¶
func (y *YOLO) ShowLiveWindow(videoPath string, opts *DetectionOptions) error
ShowLiveWindow 启动实时GUI窗口
type YOLOConfig ¶
type YOLOConfig struct {
InputSize int // 输入尺寸(正方形时使用)
InputWidth int // 输入宽度(非正方形时使用)
InputHeight int // 输入高度(非正方形时使用)
UseGPU bool // 是否使用GPU
GPUDeviceID int // GPU设备ID(默认0,仅在UseGPU=true时有效)
LibraryPath string // ONNX Runtime库路径
AutoCreateConfig bool // 是否自动创建配置文件(默认false)
// CUDA加速配置
UseCUDA bool // 是否使用CUDA加速(需要CUDA库支持)
CUDADeviceID int // CUDA设备ID(默认0,仅在UseCUDA=true时有效)
CUDAMemoryPool bool // 是否启用CUDA内存池优化(默认true)
}
YOLOConfig YOLO检测器配置(检测器级别 - 创建时设置)
func AutoDetectInputSizeConfig ¶
func AutoDetectInputSizeConfig(modelPath string) *YOLOConfig
AutoDetectInputSizeConfig 自动检测模型输入尺寸的配置
func CUDAAcceleratedConfig ¶
func CUDAAcceleratedConfig() *YOLOConfig
CUDAAcceleratedConfig CUDA加速配置 - 启用CUDA库加速
func DefaultConfigWithModelPath ¶
func DefaultConfigWithModelPath(modelPath string) *YOLOConfig
DefaultConfigWithModelPath 根据模型路径返回智能配置(推荐使用)
func ExtremeCUDAConfig ¶
func ExtremeCUDAConfig() *YOLOConfig
ExtremeCUDAConfig 极致CUDA配置 - 最高性能CUDA加速
func ExtremePerformanceConfig ¶
func ExtremePerformanceConfig() *YOLOConfig
ExtremePerformanceConfig 极限性能配置(不计成本压榨硬件)
func HighEndGPUOptimizedConfig ¶
func HighEndGPUOptimizedConfig() *YOLOConfig
HighEndGPUOptimizedConfig 高端GPU极致优化配置 支持高端显卡,强制要求GPU可用 注意:此配置强制要求GPU,如果GPU不可用会在NewYOLO时返回错误
func HighPerformanceConfig ¶
func HighPerformanceConfig() *YOLOConfig
HighPerformanceConfig 高性能配置(自动检测并优化CPU/GPU) 注意:DefaultConfig现在已经是高性能配置,此函数保持向后兼容
func HighPerformanceGPUConfig ¶
func HighPerformanceGPUConfig() *YOLOConfig
HighPerformanceGPUConfig 高性能GPU专用极致优化配置 针对高端显卡的大显存和多核心进行优化 注意:此配置强制要求GPU,如果GPU不可用会在NewYOLO时返回错误
func MaxPerformanceCPUConfig ¶
func MaxPerformanceCPUConfig() *YOLOConfig
MaxPerformanceCPUConfig CPU最大性能配置
func MaxPerformanceGPUConfig ¶
func MaxPerformanceGPUConfig() *YOLOConfig
MaxPerformanceGPUConfig GPU最大性能配置
func (*YOLOConfig) WithAutoCreateConfig ¶
func (c *YOLOConfig) WithAutoCreateConfig(autoCreate bool) *YOLOConfig
WithAutoCreateConfig 设置是否自动创建配置文件
func (*YOLOConfig) WithCUDA ¶
func (c *YOLOConfig) WithCUDA(use bool) *YOLOConfig
WithCUDA 设置是否使用CUDA加速
func (*YOLOConfig) WithCUDADeviceID ¶
func (c *YOLOConfig) WithCUDADeviceID(deviceID int) *YOLOConfig
WithCUDADeviceID 设置CUDA设备ID
func (*YOLOConfig) WithCUDAMemoryPool ¶
func (c *YOLOConfig) WithCUDAMemoryPool(enable bool) *YOLOConfig
WithCUDAMemoryPool 设置是否启用CUDA内存池
func (*YOLOConfig) WithGPUDeviceID ¶
func (c *YOLOConfig) WithGPUDeviceID(deviceID int) *YOLOConfig
WithGPUDeviceID 设置GPU设备ID(仅在UseGPU=true时有效)
func (*YOLOConfig) WithInputDimensions ¶
func (c *YOLOConfig) WithInputDimensions(width, height int) *YOLOConfig
WithInputDimensions 设置输入尺寸(宽度和高度)
func (*YOLOConfig) WithInputSize ¶
func (c *YOLOConfig) WithInputSize(size int) *YOLOConfig
WithInputSize 设置输入尺寸(正方形)
func (*YOLOConfig) WithLibraryPath ¶
func (c *YOLOConfig) WithLibraryPath(path string) *YOLOConfig
WithLibraryPath 设置ONNX Runtime库路径