mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Show sub label in debug view when available (#7567)
* Show sub label in debug view if available * Ensure sub label is printable to be used
This commit is contained in:
parent
bbdf5e1bee
commit
45f7db5cf1
@ -29,6 +29,7 @@ from frigate.util.image import (
|
|||||||
calculate_region,
|
calculate_region,
|
||||||
draw_box_with_label,
|
draw_box_with_label,
|
||||||
draw_timestamp,
|
draw_timestamp,
|
||||||
|
is_label_printable,
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -509,13 +510,21 @@ class CameraState:
|
|||||||
|
|
||||||
# draw the bounding boxes on the frame
|
# draw the bounding boxes on the frame
|
||||||
box = obj["box"]
|
box = obj["box"]
|
||||||
|
text = (
|
||||||
|
obj["label"]
|
||||||
|
if (
|
||||||
|
not obj.get("sub_label")
|
||||||
|
or not is_label_printable(obj["sub_label"][0])
|
||||||
|
)
|
||||||
|
else obj["sub_label"][0]
|
||||||
|
)
|
||||||
draw_box_with_label(
|
draw_box_with_label(
|
||||||
frame_copy,
|
frame_copy,
|
||||||
box[0],
|
box[0],
|
||||||
box[1],
|
box[1],
|
||||||
box[2],
|
box[2],
|
||||||
box[3],
|
box[3],
|
||||||
obj["label"],
|
text,
|
||||||
f"{obj['score']:.0%} {int(obj['area'])}",
|
f"{obj['score']:.0%} {int(obj['area'])}",
|
||||||
thickness=thickness,
|
thickness=thickness,
|
||||||
color=color,
|
color=color,
|
||||||
|
@ -4,6 +4,7 @@ import datetime
|
|||||||
import logging
|
import logging
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from multiprocessing import shared_memory
|
from multiprocessing import shared_memory
|
||||||
|
from string import printable
|
||||||
from typing import AnyStr, Optional
|
from typing import AnyStr, Optional
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
@ -154,6 +155,11 @@ def draw_box_with_label(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def is_label_printable(label) -> bool:
|
||||||
|
"""Check if label is printable."""
|
||||||
|
return not bool(set(label) - set(printable))
|
||||||
|
|
||||||
|
|
||||||
def calculate_region(frame_shape, xmin, ymin, xmax, ymax, model_size, multiplier=2):
|
def calculate_region(frame_shape, xmin, ymin, xmax, ymax, model_size, multiplier=2):
|
||||||
# size is the longest edge and divisible by 4
|
# size is the longest edge and divisible by 4
|
||||||
size = int((max(xmax - xmin, ymax - ymin) * multiplier) // 4 * 4)
|
size = int((max(xmax - xmin, ymax - ymin) * multiplier) // 4 * 4)
|
||||||
|
Loading…
Reference in New Issue
Block a user