local-tool/: visionA-local desktop app
- M1: Wails shell + Go server + Next.js UI + Mock mode (macOS dmg ready)
- M2: i18n (zh-TW/en) + Settings 4-tab refactor
- M3: Embedded Python 3.12 runtime (python-build-standalone) + KneronPLUS wheels
- M4: Windows Inno Setup script (build on Windows runner)
- M5: Linux AppImage script + udev rule (build on Linux runner)
- M6: ffmpeg (GPL, pending legal review) + yt-dlp bundled
- Lifecycle: watchServer health check, fatal native dialog,
Wails IPC raise endpoint, stale process cleanup
.autoflow/: full PRD / Design Spec / Architecture / Testing docs
(4 rounds tri-party discussion + cross review)
.github/workflows/: macOS / Windows / Linux build CI
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
91 lines
2.7 KiB
Go
91 lines
2.7 KiB
Go
package driver
|
|
|
|
import "time"
|
|
|
|
type DeviceDriver interface {
|
|
Info() DeviceInfo
|
|
Connect() error
|
|
Disconnect() error
|
|
IsConnected() bool
|
|
Flash(modelPath string, progressCh chan<- FlashProgress) error
|
|
StartInference() error
|
|
StopInference() error
|
|
ReadInference() (*InferenceResult, error)
|
|
RunInference(imageData []byte) (*InferenceResult, error)
|
|
GetModelInfo() (*ModelInfo, error)
|
|
}
|
|
|
|
type DeviceInfo struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Type string `json:"type"`
|
|
Port string `json:"port"`
|
|
VendorID uint16 `json:"vendorId,omitempty"`
|
|
ProductID uint16 `json:"productId,omitempty"`
|
|
Status DeviceStatus `json:"status"`
|
|
FirmwareVer string `json:"firmwareVersion,omitempty"`
|
|
FlashedModel string `json:"flashedModel,omitempty"`
|
|
}
|
|
|
|
type DeviceStatus string
|
|
|
|
const (
|
|
StatusDetected DeviceStatus = "detected"
|
|
StatusConnecting DeviceStatus = "connecting"
|
|
StatusConnected DeviceStatus = "connected"
|
|
StatusFlashing DeviceStatus = "flashing"
|
|
StatusInferencing DeviceStatus = "inferencing"
|
|
StatusError DeviceStatus = "error"
|
|
StatusDisconnected DeviceStatus = "disconnected"
|
|
)
|
|
|
|
type FlashProgress struct {
|
|
Percent int `json:"percent"`
|
|
Stage string `json:"stage"`
|
|
Message string `json:"message,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
|
|
type InferenceResult struct {
|
|
DeviceID string `json:"deviceId,omitempty"`
|
|
ModelID string `json:"modelId,omitempty"`
|
|
TaskType string `json:"taskType"`
|
|
Timestamp int64 `json:"timestamp"`
|
|
LatencyMs float64 `json:"latencyMs"`
|
|
Classifications []ClassResult `json:"classifications,omitempty"`
|
|
Detections []DetectionResult `json:"detections,omitempty"`
|
|
|
|
// Batch image fields (omitted for single-image/camera/video modes)
|
|
ImageIndex int `json:"imageIndex,omitempty"`
|
|
TotalImages int `json:"totalImages,omitempty"`
|
|
Filename string `json:"filename,omitempty"`
|
|
|
|
// Video progress fields (omitted for non-video modes)
|
|
FrameIndex int `json:"frameIndex,omitempty"`
|
|
TotalFrames int `json:"totalFrames,omitempty"`
|
|
}
|
|
|
|
type ClassResult struct {
|
|
Label string `json:"label"`
|
|
Confidence float64 `json:"confidence"`
|
|
}
|
|
|
|
type DetectionResult struct {
|
|
Label string `json:"label"`
|
|
Confidence float64 `json:"confidence"`
|
|
BBox BBox `json:"bbox"`
|
|
}
|
|
|
|
type BBox struct {
|
|
X float64 `json:"x"`
|
|
Y float64 `json:"y"`
|
|
Width float64 `json:"width"`
|
|
Height float64 `json:"height"`
|
|
}
|
|
|
|
type ModelInfo struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
LoadedAt time.Time `json:"loadedAt"`
|
|
}
|