Skip to content

Commit

Permalink
chore: added green and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarvid committed Oct 7, 2022
1 parent c29e040 commit 6fc3869
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
10 changes: 8 additions & 2 deletions inference/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
"upper_hsv": (29, 255, 255),
}

green = {
"name": "green",
"lower_hsv": (48, 50, 0),
"upper_hsv": (55, 255, 255),
}

sky_blue = {
"name": "sky_blue",
"lower_hsv": (95, 38, 0),
Expand All @@ -43,7 +49,7 @@
black = {
"name": "black",
"lower_hsv": (0, 0, 0),
"upper_hsv": (179, 255, 60),
"upper_hsv": (179, 255, 49),
}

all = [white, red, blueish_red, orange, yellow, sky_blue, blue, black]
all = [white, red, orange, yellow, green, sky_blue, blue, blueish_red, black]
4 changes: 2 additions & 2 deletions inference/filters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from inference.colors import black, blue, sky_blue, yellow
from inference.colors import black, blue, green, sky_blue

chelsea_filter = {
"name": "Chelsea",
"colors": [blue, yellow],
"colors": [blue, green],
}

city_filter = {
Expand Down
20 changes: 10 additions & 10 deletions inference/hsv_classifier.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import copy
import json
from typing import List, Tuple
from typing import List

import cv2
import matplotlib.pyplot as plt
Expand All @@ -20,14 +19,6 @@ def __init__(self, filters: List[dict]):
filters: List[dict]
List of colors to classify
If you want to add a specific color, you can add it as a Python dictionary with the following format:
custom_color = {
"name":"my_custom_color",
"lower_hsv": (0, 0, 0),
"upper_hsv": (179, 255, 255)
}
Format:
[
{
Expand All @@ -48,6 +39,15 @@ def __init__(self, filters: List[dict]):
},
]
If you want to add a specific color, you can add it as a Python dictionary with the following format:
custom_color = {
"name":"my_custom_color",
"lower_hsv": (0, 0, 0),
"upper_hsv": (179, 255, 255)
}
You can find your custom hsv range with an online tool like https://github.com/hariangr/HsvRangeTool
"""
super().__init__()

Expand Down
3 changes: 3 additions & 0 deletions soccer/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,9 @@ def draw_arrow_head(
# vector length
Len = sqrt(dX * dX + dY * dY) # use Hypot if available

if Len == 0:
return img

# normalized direction vector components
udX = dX / Len
udY = dY / Len
Expand Down

0 comments on commit 6fc3869

Please sign in to comment.