diff --git a/dayglo_detector/dayglo_detector.py b/dayglo_detector/dayglo_detector.py index 9fd98a0..fc344cc 100644 --- a/dayglo_detector/dayglo_detector.py +++ b/dayglo_detector/dayglo_detector.py @@ -21,8 +21,9 @@ DISCOVERY_PREFIX = "homeassistant" last_rating = 0 # Default color thresholds for dayglo detection -LOWER_COLOR = np.array([20, 100, 100]) -UPPER_COLOR = np.array([40, 255, 255]) +# Fine-tune color thresholds for dayglo detection +LOWER_COLOR = np.array([25, 150, 150]) +UPPER_COLOR = np.array([35, 255, 255]) # Track if the initial snapshot has been processed initial_snapshot_processed = False @@ -92,7 +93,14 @@ def process_snapshot(payload): def calculate_dayglo_rating(image): print("Calculating dayglo rating...") - hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV) + # Crop the image to focus on the center area + height, width = image.shape[:2] + crop_margin = 0.1 # 10% margin + cropped_image = image[int(height * crop_margin):int(height * (1 - crop_margin)), + int(width * crop_margin):int(width * (1 - crop_margin))] + + print("Calculating dayglo rating...") + hsv_image = cv2.cvtColor(cropped_image, cv2.COLOR_BGR2HSV) mask = cv2.inRange(hsv_image, LOWER_COLOR, UPPER_COLOR) dayglo_pixels = cv2.countNonZero(mask) total_pixels = image.shape[0] * image.shape[1] @@ -123,7 +131,7 @@ if len(sys.argv) > 1: print(f"File not found: {image_file}") # Set up MQTT client for normal operation -client = mqtt.Client() +client = mqtt.Client(client_id='', clean_session=True, protocol=mqtt.MQTTv5) client.username_pw_set(MQTT_USERNAME, MQTT_PASSWORD) client.on_connect = on_connect client.on_message = on_message diff --git a/docker-compose.yml b/docker-compose.yml index c3fd6aa..88ded02 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -66,6 +66,7 @@ services: restart: always volumes: - /etc/localtime:/etc/localtime:ro + - /home/docker/compose/frigate/debug-image/:/tmp/debug-image/ environment: MQTT_BROKER: '10.59.221.172' MQTT_PORT: '1883'