NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Fix: workaround for drawing non-latin characters (#7686)
Sergey Krashevich500d369c50e9
diff --git a/docker/main/requirements-wheels.txt b/docker/main/requirements-wheels.txtindex 0b3fe2952b..f4167744eb 100644--- a/docker/main/requirements-wheels.txt+++ b/docker/main/requirements-wheels.txt@@ -23,6 +23,7 @@ scipy == 1.11.*norfair == 2.2.*setproctitle == 1.3.*ws4py == 0.5.*+unidecode == 1.3.*# Openvino Library - Custom built with MYRIAD supportopenvino @ https://github.com/NateMeyer/openvino-wheels/releases/download/multi-arch_2022.3.1/openvino-2022.3.1-1-cp39-cp39-manylinux_2_31_x86_64.whl; platform_machine == 'x86_64'openvino @ https://github.com/NateMeyer/openvino-wheels/releases/download/multi-arch_2022.3.1/openvino-2022.3.1-1-cp39-cp39-linux_aarch64.whl; platform_machine == 'aarch64'diff --git a/frigate/test/test_video.py b/frigate/test/test_video.pyindex 1eb70cf504..cba63c950f 100644--- a/frigate/test/test_video.py+++ b/frigate/test/test_video.py@@ -5,7 +5,7 @@ import numpy as npfrom norfair.drawing.color import Palettefrom norfair.drawing.drawer import Drawer-from frigate.util.image import intersection+from frigate.util.image import intersection, transliterate_to_latinfrom frigate.util.object import (get_cluster_boundary,get_cluster_candidates,@@ -82,6 +82,11 @@ class TestRegion(unittest.TestCase):assert len(cluster_candidates) == 2+ def test_transliterate_to_latin(self):+ self.assertEqual(transliterate_to_latin("frégate"), "fregate")+ self.assertEqual(transliterate_to_latin("utilité"), "utilite")+ self.assertEqual(transliterate_to_latin("imágé"), "image")+def test_cluster_boundary(self):boxes = [(100, 100, 200, 200), (215, 215, 325, 325)]boundary_boxes = [diff --git a/frigate/util/image.py b/frigate/util/image.pyindex c2cd9e5b9e..55c745eb0b 100644--- a/frigate/util/image.py+++ b/frigate/util/image.py@@ -9,10 +9,32 @@ from typing import AnyStr, Optionalimport cv2import numpy as np+from unidecode import unidecodelogger = logging.getLogger(__name__)+def transliterate_to_latin(text: str) -> str:+ """+ Transliterate a given text to Latin.++ This function uses the unidecode library to transliterate the input text to Latin.+ It is useful for converting texts with diacritics or non-Latin characters to a+ Latin equivalent.++ Args:+ text (str): The text to be transliterated.++ Returns:+ str: The transliterated text.++ Example:+ >>> transliterate_to_latin('frégate')+ 'fregate'+ """+ return unidecode(text)++def draw_timestamp(frame,timestamp,@@ -116,7 +138,10 @@ def draw_box_with_label():if color is None:color = (0, 0, 255)- display_text = "{}: {}".format(label, info)+ try:+ display_text = transliterate_to_latin("{}: {}".format(label, info))+ except Exception:+ display_text = "{}: {}".format(label, info)cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), color, thickness)font_scale = 0.5font = cv2.FONT_HERSHEY_SIMPLEX