From 51fd18f56d63f191dfc8e47efb032ead2509a2c2 Mon Sep 17 00:00:00 2001
From: Nicolas Mowen <nickmowen213@gmail.com>
Date: Sun, 10 Apr 2022 08:15:56 -0600
Subject: [PATCH] FEAT: Ability to set custom birdseye icon and birdseye docs
 (#2979)

* Show custom.png for birdseye icon if available

* Don't look for config value

* Add birdseye docs
---
 docs/docs/configuration/birdseye.md | 14 ++++++++++++++
 docs/sidebars.js                    |  1 +
 frigate/output.py                   | 22 ++++++++++++++++------
 3 files changed, 31 insertions(+), 6 deletions(-)
 create mode 100644 docs/docs/configuration/birdseye.md

diff --git a/docs/docs/configuration/birdseye.md b/docs/docs/configuration/birdseye.md
new file mode 100644
index 000000000..a3f05a107
--- /dev/null
+++ b/docs/docs/configuration/birdseye.md
@@ -0,0 +1,14 @@
+# Birdseye
+
+Birdseye allows a heads-up view of your cameras to see what is going on around your property / space without having to watch all cameras that may have nothing happening. Birdseye allows specific modes that intelligently show and disappear based on what you care about. 
+
+### Birdseye Modes
+
+Birdseye offers different modes to customize which cameras show under which circumstances.
+ - **continuous:** All cameras are always included
+ - **motion:** Cameras that have detected motion within the last 30 seconds are included
+ - **objects:** Cameras that have tracked an active object within the last 30 seconds are included
+
+### Custom Birdseye Icon
+
+A custom icon can be added to the birdseye background by provided a file `custom.png` inside of the Frigate `media` folder. The file must be a png with the icon as transparent, any non-transparent pixels will be white when displayed in the birdseye view. 
diff --git a/docs/sidebars.js b/docs/sidebars.js
index 2b3669bdf..df330936f 100644
--- a/docs/sidebars.js
+++ b/docs/sidebars.js
@@ -22,6 +22,7 @@ module.exports = {
       'configuration/objects',
       'configuration/rtmp',
       'configuration/zones',
+      'configuration/birdseye',
       'configuration/advanced',
       'configuration/hardware_acceleration',
       'configuration/nvdec',
diff --git a/frigate/output.py b/frigate/output.py
index dff8fc47e..62c672172 100644
--- a/frigate/output.py
+++ b/frigate/output.py
@@ -22,6 +22,7 @@ from ws4py.server.wsgiutils import WebSocketWSGIApplication
 from ws4py.websocket import WebSocket
 
 from frigate.config import BirdseyeModeEnum, FrigateConfig
+from frigate.const import BASE_DIR
 from frigate.util import SharedMemoryFrameManager, copy_yuv_to_position, get_yuv_crop
 
 logger = logging.getLogger(__name__)
@@ -104,12 +105,21 @@ class BirdsEyeFrameManager:
         self.blank_frame[0 : self.frame_shape[0], 0 : self.frame_shape[1]] = 16
 
         # find and copy the logo on the blank frame
-        logo_files = glob.glob("/opt/frigate/frigate/birdseye.png")
-        frigate_logo = None
-        if len(logo_files) > 0:
-            frigate_logo = cv2.imread(logo_files[0], cv2.IMREAD_UNCHANGED)
-        if not frigate_logo is None:
-            transparent_layer = frigate_logo[:, :, 3]
+        birdseye_logo = None
+
+        custom_logo_files = glob.glob(f"{BASE_DIR}/custom.png")
+
+        if len(custom_logo_files) > 0:
+            birdseye_logo = cv2.imread(custom_logo_files[0], cv2.IMREAD_UNCHANGED)
+
+        if birdseye_logo is None:
+            logo_files = glob.glob("/opt/frigate/frigate/birdseye.png")
+
+            if len(logo_files) > 0:
+                birdseye_logo = cv2.imread(logo_files[0], cv2.IMREAD_UNCHANGED)
+
+        if not birdseye_logo is None:
+            transparent_layer = birdseye_logo[:, :, 3]
             y_offset = height // 2 - transparent_layer.shape[0] // 2
             x_offset = width // 2 - transparent_layer.shape[1] // 2
             self.blank_frame[