Skip to content

Commit b0c06b9

Browse files
authored
3.1.0 (#50)
* Set version and fix crash * Add ratio filters for config * Filter based on ratio * Formatting * Add ratio config to config * Set version
1 parent a26861e commit b0c06b9

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
default_target: local
22

33
COMMIT_HASH := $(shell git log -1 --pretty=format:"%h"|tail -1)
4-
VERSION = 3.0.4
4+
VERSION = 3.1.0
55

66
local:
77
cd web; flutter build web;

docs/config.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ objects:
2828
after: "00:00"
2929
# OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
3030
before: "24:00"
31-
# OPTIONAL: the min number of pixels with R, G, B values within the bounds to be
32-
# considered a true positive. This is recommended to be set as a super small amount
31+
# OPTIONAL: the min area of the bounding box around groups of matching R, G, B pixels
32+
# considered a true positive. This is not recommended to be set as a super small amount
3333
# could be a false positive. (Default: shown below)
3434
min_area: 1000
35-
# OPTIONAL: the max number of pixels with R, G, B values within the bounds to be
36-
# considered a true positive (Default: shown below).
35+
# OPTIONAL: the max area of the bounding box around groups of pixels with R, G, B
36+
# values within the bounds to be considered a true positive (Default: shown below).
3737
max_area: 100000
38+
# OPTIONAL: the min ratio of width/height of bounding box for valid object detection (default: shown below).
39+
min_ratio: 0
40+
# OPTIONAL: the max ratio of width/height of bounding box for valid object detection (default: shown below).
41+
max_ratio: 24000000
3842
```
3943
4044
### `cameras`

swatch/config.py

+6
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ class ObjectConfig(SwatchBaseModel):
7575
)
7676
min_area: int = Field(title="Min Area", default=0)
7777
max_area: int = Field(title="Max Area", default=240000)
78+
min_ratio: float = Field(
79+
title="Min ratio of width/height for valid detection.", default=0
80+
)
81+
max_ratio: float = Field(
82+
title="Max ratio of width/height for valid detection.", default=24000000
83+
)
7884

7985

8086
class ZoneConfig(SwatchBaseModel):

swatch/util.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ def detect_objects(mask: Any, obj: ObjectConfig) -> Set[Dict[str, Any]]:
5454
area = w * h
5555

5656
if obj.min_area < area < obj.max_area:
57-
detected.append(
58-
{
59-
"box": [x, y, x + w, y + h],
60-
"area": area,
61-
}
62-
)
57+
if obj.min_ratio < (w / h) < obj.max_ratio:
58+
detected.append(
59+
{
60+
"box": [x, y, x + w, y + h],
61+
"area": area,
62+
"ratio": (w / h),
63+
}
64+
)
6365

6466
return detected
6567

0 commit comments

Comments
 (0)