diff --git a/cmd/debug/main.go b/cmd/debug/main.go index 2ba2f83..83c6ae3 100644 --- a/cmd/debug/main.go +++ b/cmd/debug/main.go @@ -33,17 +33,17 @@ func main() { debugDir := "testdata/debug" os.MkdirAll(debugDir, 0755) - // Define regions for 1080p (from config.go) + // Define regions for 1080p (from config.go — calibrated from real screenshot) regions := map[string]image.Rectangle{ - "health_orb": image.Rect(28, 545, 198, 715), - "mana_orb": image.Rect(1722, 545, 1892, 715), - "xp_bar": image.Rect(0, 1058, 1920, 1080), - "belt": image.Rect(838, 1010, 1082, 1058), - "minimap": image.Rect(1600, 0, 1920, 320), - "inventory": image.Rect(960, 330, 1490, 770), - "stash": image.Rect(430, 330, 960, 770), - "skill_left": image.Rect(194, 1030, 246, 1078), - "skill_right": image.Rect(1674, 1030, 1726, 1078), + "health_orb": image.Rect(370, 945, 460, 1030), + "mana_orb": image.Rect(1580, 910, 1670, 1000), + "xp_bar": image.Rect(0, 1058, 1920, 1080), + "belt": image.Rect(500, 990, 900, 1040), + "minimap": image.Rect(1600, 0, 1920, 320), + "inventory": image.Rect(960, 330, 1490, 770), + "stash": image.Rect(430, 330, 960, 770), + "skill_left": image.Rect(200, 1030, 250, 1078), + "skill_right": image.Rect(1670, 1030, 1730, 1078), } fmt.Println("\n=== REGION ANALYSIS ===") diff --git a/debug b/debug index 2f491f0..9bc1f2e 100755 Binary files a/debug and b/debug differ diff --git a/pkg/api/api.go b/pkg/api/api.go index a66e578..c5c2146 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -678,15 +678,15 @@ func (s *Server) getExpectedColorRange(regionName string) *vision.ColorRange { switch regionName { case "health_orb": return &vision.ColorRange{ - LowerH: 0, UpperH: 30, - LowerS: 50, UpperS: 255, - LowerV: 30, UpperV: 255, + LowerH: 0, UpperH: 10, + LowerS: 150, UpperS: 255, + LowerV: 150, UpperV: 255, } case "mana_orb": return &vision.ColorRange{ LowerH: 200, UpperH: 240, - LowerS: 40, UpperS: 255, - LowerV: 20, UpperV: 255, + LowerS: 100, UpperS: 255, + LowerV: 80, UpperV: 255, } default: // For other regions, we don't have specific expected color ranges diff --git a/plugins/d2r/config.go b/plugins/d2r/config.go index fcc1dd4..e724032 100644 --- a/plugins/d2r/config.go +++ b/plugins/d2r/config.go @@ -56,11 +56,11 @@ type Config struct { func DefaultConfig() Config { return Config{ Colors: Colors{ - // Tightened HSV ranges based on real D2R screenshot calibration - // Health orb is RED: H 0-30 (covering red wrapping), S 50-255, V 30-255 - HealthFilled: HSVRange{0, 50, 30, 30, 255, 255}, - // Mana orb is BLUE: H 200-240, S 40-255, V 20-255 - ManaFilled: HSVRange{200, 40, 20, 240, 255, 255}, + // Calibrated HSV ranges from real D2R screenshot (testdata/d2r_1080p.png) + // Health orb is bright RED: RGB ~(236,15,20) → HSV H 0-10, S 150+, V 150+ + HealthFilled: HSVRange{0, 150, 150, 10, 255, 255}, + // Mana orb is BLUE: H 200-240, S 100+, V 80+ + ManaFilled: HSVRange{200, 100, 80, 240, 255, 255}, ItemUnique: HSVRange{15, 100, 180, 30, 255, 255}, ItemSet: HSVRange{35, 100, 150, 55, 255, 255}, ItemRare: HSVRange{15, 50, 200, 25, 150, 255}, @@ -90,37 +90,38 @@ func DefaultConfig() Config { func RegisterProfiles(registry *resolution.Registry) error { profiles := []*resolution.Profile{ // 1920x1080 (1080p) - Primary resolution + // Calibrated from real D2R screenshot (testdata/d2r_1080p.png) { Width: 1920, Height: 1080, Label: "1080p", Regions: map[string]image.Rectangle{ - "health_orb": image.Rect(28, 545, 198, 715), - "mana_orb": image.Rect(1722, 545, 1892, 715), + "health_orb": image.Rect(370, 945, 460, 1030), + "mana_orb": image.Rect(1580, 910, 1670, 1000), "xp_bar": image.Rect(0, 1058, 1920, 1080), - "belt": image.Rect(838, 1010, 1082, 1058), + "belt": image.Rect(500, 990, 900, 1040), "minimap": image.Rect(1600, 0, 1920, 320), "inventory": image.Rect(960, 330, 1490, 770), "stash": image.Rect(430, 330, 960, 770), - "skill_left": image.Rect(194, 1030, 246, 1078), - "skill_right": image.Rect(1674, 1030, 1726, 1078), + "skill_left": image.Rect(200, 1030, 250, 1078), + "skill_right": image.Rect(1670, 1030, 1730, 1078), }, }, - // 1280x720 (720p) - Secondary resolution + // 1280x720 (720p) - Secondary resolution (scaled from 1080p) { Width: 1280, Height: 720, Label: "720p", Regions: map[string]image.Rectangle{ - "health_orb": image.Rect(19, 363, 132, 477), - "mana_orb": image.Rect(1148, 363, 1261, 477), + "health_orb": image.Rect(247, 630, 307, 687), + "mana_orb": image.Rect(1053, 607, 1113, 667), "xp_bar": image.Rect(0, 705, 1280, 720), - "belt": image.Rect(559, 673, 721, 705), + "belt": image.Rect(333, 660, 600, 693), "minimap": image.Rect(1067, 0, 1280, 213), "inventory": image.Rect(640, 220, 993, 513), "stash": image.Rect(287, 220, 640, 513), - "skill_left": image.Rect(129, 685, 164, 718), - "skill_right": image.Rect(1116, 685, 1151, 718), + "skill_left": image.Rect(133, 687, 167, 718), + "skill_right": image.Rect(1113, 687, 1153, 718), }, }, } diff --git a/testdata/debug/debug_health_orb.png b/testdata/debug/debug_health_orb.png index 93eea36..8907afa 100644 Binary files a/testdata/debug/debug_health_orb.png and b/testdata/debug/debug_health_orb.png differ diff --git a/testdata/debug/debug_mana_orb.png b/testdata/debug/debug_mana_orb.png index 1f0077c..1291351 100644 Binary files a/testdata/debug/debug_mana_orb.png and b/testdata/debug/debug_mana_orb.png differ