Giter VIP home page Giter VIP logo

swatch's Introduction

Hi there ๐Ÿ‘‹ I'm Nick

I am a mobile (Android, Flutter, iOS), Docker & python developer who is very passionate about what he does and loves creating new and useful things that people enjoy to use!

Anurag's GitHub stats

My Favorite Projects

I am a mobile & full stack developer. I contribute to a handful of open source projects related to Home Automation / AI and also have released quite a few apps on both the App Store and Google Play. Below are my favorite projects that I have worked on which show what I am all about.

Frigate


Frigate is an AI Network Video Recorder deployed via docker and written in Python. I am an active contributor and have really enjoyed working on this project. I also contribute to the Frigate-HomeAssistant Integration.



Albatross for Twitter


Albatross for Twitter is a clean Twitter client for Android and iOS which contains many unique features that add value to the typical Twitter experience. It is inspired by material design and is very intuitive to use while also being quite versatile and customizable to fit your style of browsing Twitter.


Link Preview

Link Preview is an open source library that is an Android view which can accept a String and parse any links that are contained in it and then show an image and the article title and link to easily show a user where a link leads.

Swatch



Color detection in images to capture presence of known objects.



Texpert & Texpert Sync



Texpert is an Android SMS client which adds high value features like scheduled messages and machine learning informed suggestions into a clean material design SMS client. Texpert Sync adds on to the experience by letting you text from your other Android and iOS devices without needing to get your phone from the other room.


Where I have worked

I have many years of experience.

ADT - Senior Android Developer (October 2020 - Present)

I work with many teams on lots of awesome projects including ADT+, ADT Blue, ADT Pulse

Fitplan Technologies - Mid Level Android Developer (May 2019 - November 2020)

Fitplan is a tech startup where I am an Android / Mobile engineer.

My social accounts

If you want to support what I do

If you would like to make a donation to support development, please use GitHub Sponsors.

Buy Me A Coffee

swatch's People

Contributors

nickm-27 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

swatch's Issues

[Support]: What's the current best way to install this ?

Describe the problem you are having

Can I just use the supplied docker compose file to pull or ?

Also, am I mistaken in assuming that any black colour bin probably will not be recognisable very well in the night, especially when they switch to black and white mode ?

Version

not installed yet

Swatch config file

na

Relevant log output

na

Any other information that may be helpful

na

Image normalization to account for lighting conditions, by using a color reference zone

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Would love the ability to set a color reference zone. For example, the side of the house, or the white trim around a window. Essentially, a region that should be used to modify the values to account for lighting conditions. When the reference zone is created, the colors in the zone would be averaged, stored permanently and used as a reference to determine lighting conditions for the image in future detections. Suggest a minimum of 25 pixels for this area. They could even just be individual pixels from parts of the image that won't be used for object detection.

For example, if your reference zone averages to rgb(117, 128, 131) when created, it would be checked again before object detection is processed. If it now averages to rgb(129, 127, 122), each channel in the object detection zone would be multiplied by some constant to normalize the colors - in this case the constants would be rgb(0.907,1.008,1.074).

Another thing to note is that colors should be normalized when saving the color variant for an object.

Describe alternatives you've considered
Maybe implementing this myself? But I'd need at least the ability to template the colors of variants and am not sure if that's possible without having to constantly reload the configuration.

Additional context
I literally haven't even implemented this integration yet ๐Ÿ˜ƒ, so take this with a grain of salt. Just something I considered while reading the docs.

[Support]: Help debugging matches/misses, previous snapshots

Describe the problem you are having

I have a "working" config, in that it does manage to match areas I've defined, and with the HASS integration, marks my binary sensor appropriately. However, I've noticed that the binary sensor will frequently cycle through off/on/off/on while the image is otherwise static (aside from sun and light reflections changing). Ive taken my own snapshots at various times of day, and have created different color values for various times of day. I've ultimately left most of the _area and _ratio configs alone, because, truthfully, the documentation isnt super clear on how to best adjust them, or how the numbers should be derived.

The challenge I'm having is, when there is a positive match, i can pretty easily see which area is matched, how much area was considered positive, etc. However, when the match fails, Im not entirely sure where to get a copy of the snapshot.jpg that failed, and how to run it through any of the APIs to successfully understand what made it fail - was it the area? the ratio? the color values?

Ive noticed different results when hitting /api/cameraname/latest when hass marks the binary sensor 'clear', sometimes it includes the name of the color_variant, an area size (less than 1000, so clearly not going to match), and result:false - this seems like good guidance for shrinking the min_area, but ive seen other times when it just returns area: -1 and result:false and im not sure what to make of that output.

The UI is helpful although seems incomplete - is there supposed to be a place that obviously tells me the state of the detection, aside from looking at the detections list and comparing timestamps? The config file implies that snapshots are saved (i configured mine to save even when they miss), and stored for up to 7 days, so it implies i should be able to go back to old snapshots and debug them to understand what made it a "miss"

It also seems like perhaps I should be cropping to a larger area for detection, but I'm not entirely sure of that. The docs make mention of the area being too small, but dont include any examples of what 'too small' actually translates to, in pixels.

Version

3.1.0-2717ec6

Swatch config file

# to one camera or common between many / all cameras
objects:
  # REQUIRED: Name of the object
  cove_beach_gate:
    # REQUIRED: the list of color variants that this object can be detected as. Useful for
    # different lighting conditions
    color_variants:
      # REQUIRED: the name of the color variant
      night:
        # REQUIRED: the lower R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_lower: 220, 150, 150
        # REQUIRED: the upper R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_upper: 255, 255, 255
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          after: "16:30"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          before: "24:00"
      morning:
        # REQUIRED: the lower R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_lower: 220, 150, 150
        # REQUIRED: the upper R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_upper: 255, 255, 255
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          after: "00:00"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          before: "07:30"
      day:
        # REQUIRED: the lower R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_lower: 0, 0, 70
        # REQUIRED: the upper R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_upper: 90, 255, 255
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          after: "07:30"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          before: "16:30"          
    # OPTIONAL: the min area of the bounding box around groups of matching R, G, B pixels
    # considered a true positive. This is not recommended to be set as a super small amount
    # could be a false positive. (Default: shown below)
    min_area: 1000
    # OPTIONAL: the max area of the bounding box around groups of pixels with R, G, B
    # values within the bounds to be considered a true positive (Default: shown below).
    max_area: 100000
    # OPTIONAL: the min ratio of width/height of bounding box for valid object detection (default: shown below).
    min_ratio: 0
     # OPTIONAL: the max ratio of width/height of bounding box for valid object detection (default: shown below).
    max_ratio: 24000000
    # REQUIRED: Define list of cameras that will be used for color detection.
cameras:
  # REQUIRED: Name of the camera
  cove_beach_gate:
    # OPTIONAL: Frequency in seconds to run detection on the camera.
    # a value of 0 disables auto detection (Default: shown below).
    auto_detect: 5
    # OPTIONAL: Configure the url and retention of snapshots. (Default: Shown Below)
    snapshot_config:
        # OPTIONAL: but highly recommended, setting the default url for a snapshot to be
        # processed by this camera. This is required for auto detection (Default: none).
        url: "http://hikvision-nvr/ISAPI/Streaming/channels/401/picture"
        # OPTIONAL: Whether or not to draw bounding boxes for confirmed objects in the snapshots (Default: shown below).
        bounding_box: true
        # OPTIONAL: Whether or not to save a clean png of the snapshot along with the annotated jpg (Default: shown below).
        clean_snapshot: true
        # OPTIONAL: Whether or not to save the snapshots of confirmed detections (Default: shown below).
        save_detections: true
        # OPTIONAL: Whether or not to save the snapshots of missed detections (Default: shown below).
        save_misses: true
        # OPTIONAL: Variations of snapshots to keep. Options are all, mask, crop (Default: shown below).
        mode: "all"
        # OPTIONAL: Number of days of snapshots to keep (Default: shown below).
        retain_days: 7
    # REQUIRED: Zones are cropped areas where the object can be expected to be.
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      gate:
        # REQUIRED: Coordinates to crop the zone by.
        # NOTE: The order of the coordinates are: x, y, x+w, y+h starting in the top left corner as 0, 0.
        coordinates: 255, 345, 340, 385
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:
          - cove_beach_gate

Relevant log output

[2023-11-16 09:26:52,159]: INFO - Starting SwatchApp
[2023-11-16 09:26:52,185]: INFO - Importing SwatchApp Config
[2023-11-16 09:26:52,185]: INFO - Verified SwatchApp Config
Starting migrations
[2023-11-16 09:26:52,219]: INFO - Starting migrations
There is nothing to migrate
[2023-11-16 09:26:52,240]: INFO - There is nothing to migrate
[2023-11-16 09:26:52,243]: INFO - Starting Auto Detection for cove_beach_gate
[2023-11-16 09:26:52,244]: INFO - Starting snapshot cleanup
[2023-11-16 09:26:52,245]: INFO - Starting Detection Cleanup

Any other information that may be helpful

Here's a couple screenshots showing what the snapshot and detections look like, in case it helps.

day-shiny
swatch-ui

[Support]: still image

Describe the problem you are having

My camera operates on a self-signed SSL certificate and only make the main stream available as a snapshot. Swatch doesn't like the self signed certificate. So I tried connecting the the webrtc server (go2rtc). It can serve serve stills as [frame.mp4] when encoding is H.264, but does not send jpeg.

Any chance it could support the raw frame from mp4 or accept a self-signed ssl?

Version

3.1.0-2717ec6

Swatch config file

Default. Attempting to install

Relevant log output

None

Any other information that may be helpful

No response

[Support]: Color Playground

Describe the problem you are having

Hi, I came across your color detector.
I am trying to get it to read from snapshots stored in /config/www/tmp/snapshot-doorbell.jpg
I have tried both "/config/www/tmp/snapshot-doorbell.jpg" and the url of the image but no image ever pops up on the color playground for me to use. Am I using the wrong link?
Thanks

Version

Latest

Swatch config file

# REQUIRED: Define a list of objects that are expected to be seen. These can be specific
# to one camera or common between many / all cameras
objects:
  # REQUIRED: Name of the object
  trash_can:
    color_variants:
      default:
        color_lower: 70, 70, 0
        color_upper: 110, 100, 50
        
# REQUIRED: Define list of cameras that will be used for color detection.
cameras:
  # REQUIRED: Name of the camera
  front_doorbell_cam:
    # REQUIRED: Zones are cropped areas where the object can be expected to be.
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      street:
        # REQUIRED: Coordinates to crop the zone by.
        # NOTE: The order of the coordinates are: x, y, x+w, y+h starting in the top left corner as 0, 0.
        coordinates: 225, 540, 350, 620
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:
          - trash_can

Relevant log output

Dont think I have any

Any other information that may be helpful

No response

[Support]: I'm very lost

Describe the problem you are having

I installed the addon and went to start it and that's when i started having issues. I noticed that it required a /config/swatch.yml file so i created one and then it wanted it to be filled in so I found code from someone because I want to make sure it works before changing all the information and putting in the work. I keep trying to start it but nothing. Please help I'm new to the config file stuff.

Version

3.1.0-2717ec6

Swatch config file

# to one camera or common between many / all cameras
objects:
  # REQUIRED: Name of the object
  trash_can:
    # REQUIRED: the list of color variants that this object can be detected as. Useful for
    # different lighting conditions
    color_variants:
      # REQUIRED: the name of the color variant
      default:
        # REQUIRED: the lower R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_lower: 70, 70, 0
        # REQUIRED: the upper R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_upper: 110, 100, 50
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          after: "00:00"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          before: "24:00"
    # OPTIONAL: the min area of the bounding box around groups of matching R, G, B pixels
    # considered a true positive. This is not recommended to be set as a super small amount
    # could be a false positive. (Default: shown below)
    min_area: 1000
    # OPTIONAL: the max area of the bounding box around groups of pixels with R, G, B
    # values within the bounds to be considered a true positive (Default: shown below).
    max_area: 100000
    # OPTIONAL: the min ratio of width/height of bounding box for valid object detection (default: shown below).
    min_ratio: 0
     # OPTIONAL: the max ratio of width/height of bounding box for valid object detection (default: shown below).
    max_ratio: 24000000
    # REQUIRED: Define list of cameras that will be used for color detection.
cameras:
  # REQUIRED: Name of the camera
  front_doorbell_cam:
    # OPTIONAL: Frequency in seconds to run detection on the camera.
    # a value of 0 disables auto detection (Default: shown below).
    auto_detect: 0
    # OPTIONAL: Configure the url and retention of snapshots. (Default: Shown Below)
    snapshot_config:
        # OPTIONAL: but highly recommended, setting the default url for a snapshot to be
        # processed by this camera. This is required for auto detection (Default: none).
        url: "http://ip.ad.dr.ess/jpg"
        # OPTIONAL: Whether or not to draw bounding boxes for confirmed objects in the snapshots (Default: shown below).
        bounding_box: true
        # OPTIONAL: Whether or not to save a clean png of the snapshot along with the annotated jpg (Default: shown below).
        clean_snapshot: true
        # OPTIONAL: Whether or not to save the snapshots of confirmed detections (Default: shown below).
        save_detections: true
        # OPTIONAL: Whether or not to save the snapshots of missed detections (Default: shown below).
        save_misses: false
        # OPTIONAL: Variations of snapshots to keep. Options are all, mask, crop (Default: shown below).
        mode: "all"
        # OPTIONAL: Number of days of snapshots to keep (Default: shown below).
        retain_days: 7
    # REQUIRED: Zones are cropped areas where the object can be expected to be.
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      street:
        # REQUIRED: Coordinates to crop the zone by.
        # NOTE: The order of the coordinates are: x, y, x+w, y+h starting in the top left corner as 0, 0.
        coordinates: 225, 540, 350, 620
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:
          - trash_can

Relevant log output

[2023-11-07 14:26:05,534]: INFO - Importing SwatchApp Config
[2023-11-07 14:26:05,536]: INFO - Verified SwatchApp Config
Starting migrations
[2023-11-07 14:26:05,581]: INFO - Starting migrations
There is nothing to migrate
[2023-11-07 14:26:05,630]: INFO - There is nothing to migrate
[2023-11-07 14:26:05,634]: INFO - Starting snapshot cleanup
[2023-11-07 14:26:05,635]: INFO - Starting Detection Cleanup

Any other information that may be helpful

No response

[Support]: Possible Config Issues/ No Detections Firing

Describe the problem you are having

I've setup a zone that crops my image down to this:
Screen Shot 2022-06-08 at 10 32 21 PM

In the config file you'll see the color variant I've setup (color_lower: 0, 0, 150, color_upper: 255, 130, 255)

I've not seen any detections triggered. Do I have the color variant range setup correctly? I've triggered new snapshots that contain the same amount of color as the image above.

Logs were sparse

Version

3.0.3

Swatch config file

objects:
  water_meter:
    color_variants:
      default:
        color_lower: 0, 0, 150
        color_upper: 255, 130, 255
    
cameras:
  BB_Camera:
    snapshot_config:
        url: "http://HA/lastimage.jpeg"
    zones:
      full_view:
        coordinates: 225, 25, 360, 360
        objects:
          - water_meter
      water_needed:
        coordinates: 300, 300, 365, 360
        objects:
          - water_meter

Relevant log output

[2022-06-08 22:32:03,141]: INFO - Starting SwatchApp
[2022-06-08 22:32:03,150]: INFO - Importing SwatchApp Config
[2022-06-08 22:32:03,150]: INFO - Verified SwatchApp Config
Starting migrations
[2022-06-08 22:32:03,154]: INFO - Starting migrations
There is nothing to migrate
[2022-06-08 22:32:03,164]: INFO - There is nothing to migrate
[2022-06-08 22:32:03,166]: INFO - Starting snapshot cleanup
[2022-06-08 22:32:03,166]: INFO - Starting Detection Cleanup

Any other information that may be helpful

Thanks in advance - really excited about getting this across the finish line

[Support]: Container will not start

Describe the problem you are having

Im running unraid and using the official unraid appstore version of swatch with all the default docker configs (i've placed a config.yaml in the correct location i believe. container maps to /config/config.yaml).

Version

crzynik/swatch:latest

Swatch config file

# REQUIRED: Define a list of objects that are expected to be seen. These can be specific
# to one camera or common between many / all cameras
objects:
  # REQUIRED: Name of the object
  trash_can:
    # REQUIRED: the list of color variants that this object can be detected as. Useful for
    # different lighting conditions
    color_variants:
      # REQUIRED: the name of the color variant
      default:
        # REQUIRED: the lower R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_lower: 70, 70, 0
        # REQUIRED: the upper R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_upper: 110, 100, 50
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          after: "00:00"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          before: "24:00"
    # OPTIONAL: the min area of the bounding box around groups of matching R, G, B pixels
    # considered a true positive. This is not recommended to be set as a super small amount
    # could be a false positive. (Default: shown below)
    min_area: 1000
    # OPTIONAL: the max area of the bounding box around groups of pixels with R, G, B
    # values within the bounds to be considered a true positive (Default: shown below).
    max_area: 100000
    # OPTIONAL: the min ratio of width/height of bounding box for valid object detection (default: shown below).
    min_ratio: 0
     # OPTIONAL: the max ratio of width/height of bounding box for valid object detection (default: shown below).
    max_ratio: 24000000
# REQUIRED: Define list of cameras that will be used for color detection.
cameras:
  # REQUIRED: Name of the camera
  porch:
    # OPTIONAL: Frequency in seconds to run detection on the camera.
    # a value of 0 disables auto detection (Default: shown below).
    auto_detect: 0
    # OPTIONAL: Configure the url and retention of snapshots. (Default: Shown Below)
    snapshot_config:
        # OPTIONAL: but highly recommended, setting the default url for a snapshot to be
        # processed by this camera. This is required for auto detection (Default: none).
        #url: "http://ip.ad.dr.ess/jpg"
        # OPTIONAL: Whether or not to draw bounding boxes for confirmed objects in the snapshots (Default: shown below).
        bounding_box: true
        # OPTIONAL: Whether or not to save a clean png of the snapshot along with the annotated jpg (Default: shown below).
        clean_snapshot: true
        # OPTIONAL: Whether or not to save the snapshots of confirmed detections (Default: shown below).
        save_detections: true
        # OPTIONAL: Whether or not to save the snapshots of missed detections (Default: shown below).
        save_misses: false
        # OPTIONAL: Variations of snapshots to keep. Options are all, mask, crop (Default: shown below).
        mode: "all"
        # OPTIONAL: Number of days of snapshots to keep (Default: shown below).
        retain_days: 7
    # REQUIRED: Zones are cropped areas where the object can be expected to be.
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      driveway_entry:
        # REQUIRED: Coordinates to crop the zone by.
        # NOTE: The order of the coordinates are: x, y, x+w, y+h starting in the top left corner as 0, 0.
        coordinates: 225, 540, 350, 620
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:

Relevant log output

ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/usr/local/lib/python3.11/site-packages/werkzeug/urls.py)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/swatch/swatch/__main__.py", line 6, in <module>
    from swatch.app import SwatchApp
  File "/opt/swatch/swatch/app.py", line 16, in <module>
    from swatch.http import create_app
  File "/opt/swatch/swatch/http.py", line 10, in <module>
    from flask import (
  File "/usr/local/lib/python3.11/site-packages/flask/__init__.py", line 7, in <module>
    from .app import Flask as Flask
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 27, in <module>
    from . import cli
  File "/usr/local/lib/python3.11/site-packages/flask/cli.py", line 17, in <module>
    from .helpers import get_debug_flag
  File "/usr/local/lib/python3.11/site-packages/flask/helpers.py", line 14, in <module>
    from werkzeug.urls import url_quote
ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/usr/local/lib/python3.11/site-packages/werkzeug/urls.py)

Any other information that may be helpful

I've also tried configuring this with docker-compose using the following but with the same issues. The config locations are a bit different but still map to the correct locations in the container.

  swatch:
    container_name: swatch
    image: crzynik/swatch
    #depends_on:
    #  - nginx-proxy-manager
    privileged: true
    network_mode: swatch_network
    restart: always
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
    ports:
      - "4500:4500"
      - "4501:4501"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${ROOT}/config/swatch/config/config.yaml:/config/config.yaml:ro #also tried just mapping the directories
      - ${ROOT}/config/swatch/media:/media

[Support]: Database error after updating to 2.2.0 as running a home assistant addon

Describe the problem you are having

Hi! Trying to test this, but just updated and now it wont start. Gives error related to database? I'm running inside home assistant and as a ad don. Wonder if it is related to that?

Version

2.2.0

Swatch config file

# REQUIRED: Define list of cameras that will be used for color detection.
cameras:
  # REQUIRED: Name of the camera
  autokatos:
    # OPTIONAL: Frequency in seconds to run detection on the camera.
    # a value of 0 disables auto detection (Default: shown below).
    auto_detect: 10
    # OPTIONAL: Configure the url and retention of snapshots. (Default: Shown Below)
    snapshot_config:
        # OPTIONAL: but highly recommended, setting the default url for a snapshot to be
        # processed by this camera. This is required for auto detection (Default: none).
        url: "http://xxxx/cgi-bin/api.cgi?cmd=Snap&channel=6&rs=qwerty&user=xxxxx&password=xxxx"
        # OPTIONAL: Whether or not to save the snapshots of confirmed detections (Default: shown below).
        save_detections: true
        # OPTIONAL: Whether or not to save the snapshots of missed detections (Default: shown below).
        save_misses: true
        # OPTIONAL: Variations of snapshots to keep. Options are all, mask, crop (Default: shown below).
        mode: "all"
        # OPTIONAL: Number of days of snapshots to keep (Default: shown below).
        retain_days: 7
    # REQUIRED: Zones are cropped areas where the object can be expected to be.
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      vasenpuoli:
        # REQUIRED: Coordinates to crop the zone by.
        # NOTE: The order of the coordinates are: y, y+h, x, x+w starting in the top left corner as 0, 0.
        coordinates: 0,500,0,500
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:
          - fiat
# REQUIRED: Define a list of objects that are expected to be seen. These can be specific
# to one camera or common between many / all cameras
objects:
  # REQUIRED: Name of the object
  fiat:
    # REQUIRED: the list of color variants that this object can be detected as. Useful for
    # different lighting conditions
    color_variants:
      name_of_variant:
        color_lower: 6, 21, 79
        color_upper: 255, 132, 252
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        #time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          #after: "00:00"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          #before: "24:00"
    # OPTIONAL: the min number of pixels with R, G, B values within the bounds to be
    # considered a true positive. This is recommended to be set as a super small amount
    # could be a false positive. (Default: shown below)
    #min_area: 1000
    # OPTIONAL: the max number of pixels with R, G, B values within the bounds to be
    # considered a true positive (Default: shown below).
    #max_area: 100000

Relevant log output

Starting SwatchApp
Importing SwatchApp Config
Verified SwatchApp Config
Starting migrations
There is nothing to migrate
Exception in thread Thread-1 (run):
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3113, in connect
    self._state.set_connection(self._connect())
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3453, in _connect
    conn = sqlite3.connect(self.database, timeout=self._timeout,
sqlite3.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.10/site-packages/playhouse/sqliteq.py", line 266, in run
    writer.run()
  File "/usr/local/lib/python3.10/site-packages/playhouse/sqliteq.py", line 128, in run
    conn = self.database.connection()
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3153, in connection
    self.connect()
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3112, in connect
    with __exception_wrapper__:
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 2950, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 191, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3113, in connect
    self._state.set_connection(self._connect())
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3453, in _connect
    conn = sqlite3.connect(self.database, timeout=self._timeout,
peewee.OperationalError: unable to open database file
Starting Auto Detection for autokatos
Starting snapshot cleanup
Starting Detection Cleanup

Any other information that may be helpful

No response

[Support]: colortest API fails with an internal error (500)

Describe the problem you are having

When trying to call the colortest API (/api/colortest/values) from postman with an image a 500 Internal Server Error is returned:

image

Version

3.1.0

Swatch config file

N/A

Relevant log output

<!doctype html>
<html lang=en>
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or
	there is an error in the application.</p>

Any other information that may be helpful

I have also tried using the Color Playground option from the UI, but after entering the URL of the camera I havenยดt found a way to crop the image as indicated in the text:

image

No response

[Support]: Error when trying to setup Swatch

Describe the problem you are having

I am getting the following error after setting up Swatch: requests.exceptions.MissingSchema: Invalid URL 'None': No scheme supplied. Perhaps you meant http://None?

Version

3.1.0

Swatch config file

# REQUIRED: Define a list of objects that are expected to be seen. These can be specific
# to one camera or common between many / all cameras
objects:
  # REQUIRED: Name of the object
  awning:
    # REQUIRED: the list of color variants that this object can be detected as. Useful for
    # different lighting conditions
    color_variants:
      # REQUIRED: the name of the color variant
      default:
        # REQUIRED: the lower R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_lower: 70, 70, 0
        # REQUIRED: the upper R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_upper: 110, 100, 50
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          after: "00:00"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          before: "24:00"
    # OPTIONAL: the min area of the bounding box around groups of matching R, G, B pixels
    # considered a true positive. This is not recommended to be set as a super small amount
    # could be a false positive. (Default: shown below)
    min_area: 1000
    # OPTIONAL: the max area of the bounding box around groups of pixels with R, G, B
    # values within the bounds to be considered a true positive (Default: shown below).
    max_area: 100000
    # OPTIONAL: the min ratio of width/height of bounding box for valid object detection (default: shown below).
    min_ratio: 0
     # OPTIONAL: the max ratio of width/height of bounding box for valid object detection (default: shown below).
    max_ratio: 24000000

# REQUIRED: Define list of cameras that will be used for color detection.
cameras:
  # REQUIRED: Name of the camera
  dahua_3:
    # OPTIONAL: Frequency in seconds to run detection on the camera.
    # a value of 0 disables auto detection (Default: shown below).
    auto_detect: 0
#    # OPTIONAL: Configure the url and retention of snapshots. (Default: Shown Below)
#    snapshot_config:
#        # OPTIONAL: but highly recommended, setting the default url for a snapshot to be
#        # processed by this camera. This is required for auto detection (Default: none).
#        url: "http://ip.ad.dr.ess/jpg"
#        # OPTIONAL: Whether or not to draw bounding boxes for confirmed objects in the snapshots (Default: shown below).
#        bounding_box: true
#        # OPTIONAL: Whether or not to save a clean png of the snapshot along with the annotated jpg (Default: shown below).
#        clean_snapshot: true
#        # OPTIONAL: Whether or not to save the snapshots of confirmed detections (Default: shown below).
#        save_detections: true
#        # OPTIONAL: Whether or not to save the snapshots of missed detections (Default: shown below).
#        save_misses: false
#        # OPTIONAL: Variations of snapshots to keep. Options are all, mask, crop (Default: shown below).
#        mode: "all"
#        # OPTIONAL: Number of days of snapshots to keep (Default: shown below).
#        retain_days: 7
    # REQUIRED: Zones are cropped areas where the object can be expected to be.
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      top:
        # REQUIRED: Coordinates to crop the zone by.
        # NOTE: The order of the coordinates are: x, y, x+w, y+h starting in the top left corner as 0, 0.
        coordinates: 360, 0, 5600, 80
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:
          - awning

Relevant log output

[2023-09-16 10:24:55,500]: ERROR - Exception on /dahua_3/snapshot.jpg [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1519, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/opt/swatch/swatch/http.py", line 342, in get_latest_camera_snapshot
    jpg_bytes = current_app.snapshot_processor.get_latest_camera_snapshot(camera_name)
  File "/opt/swatch/swatch/snapshot.py", line 175, in get_latest_camera_snapshot
    img_bytes = requests.get(
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 515, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 443, in prepare_request
    p.prepare(
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 318, in prepare
    self.prepare_url(url, params)
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 392, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'None': No scheme supplied. Perhaps you meant http://None?

Any other information that may be helpful

No response

[Support]:

Describe the problem you are having

Unable to view color picker screen in HomeAssistant Add-on

Version

latest

Swatch config file

# REQUIRED: Define a list of objects that are expected to be seen. These can be specific
# to one camera or common between many / all cameras
objects:
  # REQUIRED: Name of the object
  fireplace:
    # REQUIRED: the list of color variants that this object can be detected as. Useful for
    # different lighting conditions
    color_variants:
      # REQUIRED: the name of the color variant
      default:
        # REQUIRED: the lower R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_lower: 70, 70, 0
        # REQUIRED: the upper R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_upper: 110, 100, 50
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          after: "00:00"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          before: "24:00"
    # OPTIONAL: the min area of the bounding box around groups of matching R, G, B pixels
    # considered a true positive. This is not recommended to be set as a super small amount
    # could be a false positive. (Default: shown below)
    min_area: 1000
    # OPTIONAL: the max area of the bounding box around groups of pixels with R, G, B
    # values within the bounds to be considered a true positive (Default: shown below).
    max_area: 100000
    # OPTIONAL: the min ratio of width/height of bounding box for valid object detection (default: shown below).
    min_ratio:
      0
      # OPTIONAL: the max ratio of width/height of bounding box for valid object detection (default: shown below).
    max_ratio: 24000000

# REQUIRED: Define list of cameras that will be used for color detection.
cameras:
  # REQUIRED: Name of the camera
  living_room_cam:
    # OPTIONAL: Frequency in seconds to run detection on the camera.
    # a value of 0 disables auto detection (Default: shown below).
    auto_detect: 0
    # OPTIONAL: Configure the url and retention of snapshots. (Default: Shown Below)
    snapshot_config:
      # OPTIONAL: but highly recommended, setting the default url for a snapshot to be
      # processed by this camera. This is required for auto detection (Default: none).
      url: "https://wallpaperset.com/w/full/0/d/5/183330.jpg"
      # OPTIONAL: Whether or not to draw bounding boxes for confirmed objects in the snapshots (Default: shown below).
      bounding_box: true
      # OPTIONAL: Whether or not to save a clean png of the snapshot along with the annotated jpg (Default: shown below).
      clean_snapshot: true
      # OPTIONAL: Whether or not to save the snapshots of confirmed detections (Default: shown below).
      save_detections: true
      # OPTIONAL: Whether or not to save the snapshots of missed detections (Default: shown below).
      save_misses: false
      # OPTIONAL: Variations of snapshots to keep. Options are all, mask, crop (Default: shown below).
      mode: "all"
      # OPTIONAL: Number of days of snapshots to keep (Default: shown below).
      retain_days: 7
    # REQUIRED: Zones are cropped areas where the object can be expected to be.
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      street:
        # REQUIRED: Coordinates to crop the zone by.
        # NOTE: The order of the coordinates are: x, y, x+w, y+h starting in the top left corner as 0, 0.
        coordinates: 225, 540, 350, 620
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:
          - fireplace

Relevant log output

[2023-11-08 20:53:18,833]: INFO - Starting SwatchApp
[2023-11-08 20:53:18,838]: INFO - Importing SwatchApp Config
[2023-11-08 20:53:18,838]: INFO - Verified SwatchApp Config
Starting migrations
[2023-11-08 20:53:18,842]: INFO - Starting migrations
There is nothing to migrate
[2023-11-08 20:53:18,846]: INFO - There is nothing to migrate
[2023-11-08 20:53:18,846]: INFO - Starting snapshot cleanup
[2023-11-08 20:53:18,847]: INFO - Starting Detection Cleanup

Any other information that may be helpful

Dashboard view:
image

Color picker view:
image

Settings view:
image

Setting a source via the UI doesn't seem to do anything.

[Support]: Frontend doesn't work when passing through a reverse proxy

Describe the problem you are having

The frontend attempts to load from http://https/api/... when being passed through a reverse proxy.

Version

3.1.0

Swatch config file

Not relevant for this issue

Relevant log output

main.dart.js:36572 Mixed Content: The page at 'https://[redacted]/detections' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://https/api/detections'. This request has been blocked; the content must be served over HTTPS.

Any other information that may be helpful

No response

[Support]: Trouble Getting Into WebUI - 502 Bad Gateway error

Describe the problem you are having

Can't access WebUI - 502 bad gateway error

Repository has been added, and add-on installed. I have also installed the HACS integration. I tried to setup the normal integration (which is now showing up) but wasn't sure if I'm pointing to the right URL as I'm getting an error back on that.

Bigger issue seems to be with getting into the WebUI

Version

3.0.2

Swatch config file

# REQUIRED: Define a list of objects that are expected to be seen. These can be specific
# to one camera or common between many / all cameras
objects:
  # REQUIRED: Name of the object
  trash_can:
    # REQUIRED: the list of color variants that this object can be detected as. Useful for
    # different lighting conditions
    color_variants:
      # REQUIRED: the name of the color variant
      default:
        # REQUIRED: the lower R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_lower: 70, 70, 0
        # REQUIRED: the upper R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_upper: 110, 100, 50
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          after: "00:00"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          before: "24:00"
    # OPTIONAL: the min number of pixels with R, G, B values within the bounds to be
    # considered a true positive. This is recommended to be set as a super small amount
    # could be a false positive. (Default: shown below)
    min_area: 1000
    # OPTIONAL: the max number of pixels with R, G, B values within the bounds to be
    # considered a true positive (Default: shown below).
    max_area: 100000
    
# REQUIRED: Define list of cameras that will be used for color detection.
cameras:
  # REQUIRED: Name of the camera
  GR:
    # OPTIONAL: Frequency in seconds to run detection on the camera.
    # a value of 0 disables auto detection (Default: shown below).
    auto_detect: 0
    # OPTIONAL: Configure the url and retention of snapshots. (Default: Shown Below)
    snapshot_config:
        # OPTIONAL: but highly recommended, setting the default url for a snapshot to be
        # processed by this camera. This is required for auto detection (Default: none).
        url: "http://ip.ad.dr.ess/jpg"
        # OPTIONAL: Whether or not to draw bounding boxes for confirmed objects in the snapshots (Default: shown below).
        bounding_box: true
        # OPTIONAL: Whether or not to save a clean png of the snapshot along with the annotated jpg (Default: shown below).
        clean_snapshot: true
        # OPTIONAL: Whether or not to save the snapshots of confirmed detections (Default: shown below).
        save_detections: true
        # OPTIONAL: Whether or not to save the snapshots of missed detections (Default: shown below).
        save_misses: false
        # OPTIONAL: Variations of snapshots to keep. Options are all, mask, crop (Default: shown below).
        mode: "all"
        # OPTIONAL: Number of days of snapshots to keep (Default: shown below).
        retain_days: 7
    # REQUIRED: Zones are cropped areas where the object can be expected to be.
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      street:
        # REQUIRED: Coordinates to crop the zone by.
        # NOTE: The order of the coordinates are: x, y, x+w, y+h starting in the top left corner as 0, 0.
        coordinates: 225, 540, 350, 620
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:
          - trash_can

Relevant log output

[2022-06-08 14:13:47,455]: INFO - Starting SwatchApp
[2022-06-08 14:13:47,464]: INFO - Importing SwatchApp Config
[2022-06-08 14:13:47,464]: INFO - Verified SwatchApp Config
Starting migrations
[2022-06-08 14:13:47,480]: INFO - Starting migrations
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3113, in connect
    self._state.set_connection(self._connect())
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3453, in _connect
    conn = sqlite3.connect(self.database, timeout=self._timeout,
sqlite3.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3175, in execute_sql
    cursor = self.cursor(commit)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3159, in cursor
    self.connect()
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3112, in connect
    with __exception_wrapper__:
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 2950, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 191, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3113, in connect
    self._state.set_connection(self._connect())
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3453, in _connect
    conn = sqlite3.connect(self.database, timeout=self._timeout,
peewee.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/opt/swatch/swatch/__main__.py", line 14, in <module>
    swatch_app = SwatchApp()
  File "/opt/swatch/swatch/app.py", line 44, in __init__
    self.__init_db__()
  File "/opt/swatch/swatch/app.py", line 74, in __init_db__
    router.run()
  File "/usr/local/lib/python3.10/site-packages/peewee_migrate/router.py", line 201, in run
    diff = self.diff
  File "/usr/local/lib/python3.10/site-packages/peewee_migrate/router.py", line 75, in diff
    done = set(self.done)
  File "/usr/local/lib/python3.10/site-packages/peewee_migrate/router.py", line 70, in done
    return [mm.name for mm in self.model.select().order_by(self.model.id)]
  File "/usr/local/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/usr/local/lib/python3.10/site-packages/peewee_migrate/router.py", line 59, in model
    MigrateHistory.create_table(True)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 6758, in create_table
    cls._schema.create_all(safe, **options)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 5861, in create_all
    self.create_table(safe, **table_options)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 5716, in create_table
    self.database.execute(self._create_table(safe=safe, **options))
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3190, in execute
    return self.execute_sql(sql, params, commit=commit)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3174, in execute_sql
    with __exception_wrapper__:
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 2950, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 191, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3175, in execute_sql
    cursor = self.cursor(commit)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3159, in cursor
    self.connect()
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3112, in connect
    with __exception_wrapper__:
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 2950, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 191, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3113, in connect
    self._state.set_connection(self._connect())
  File "/usr/local/lib/python3.10/site-packages/peewee.py", line 3453, in _connect
    conn = sqlite3.connect(self.database, timeout=self._timeout,
peewee.OperationalError: unable to open database file

Any other information that may be helpful

No response

[Support]: Need help with tuning the color values

Describe the problem you are having

I used a python script to crop the images from my camera with the same coordinates provided in the config file for Swatch. I then uploaded the cropped images to Swatch to get the color values. Below are the results of this test as well as the result of running detect on the original uncropped pictures.

midday:
{
    "message": "The dominant color is (151, 36, 46) with a mixed palette as [(156, 39, 49), (183, 168, 169), (203, 139, 150), (85, 6, 13)]",
    "success": true
}

{
    "door": {
        "stop_sign": {
            "area": 81,
            "result": false
        }
    }
}

cropped_midday

night_lights_on:
{
    "message": "The dominant color is (64, 22, 26) with a mixed palette as [(62, 14, 18), (79, 74, 74), (130, 84, 90), (84, 60, 68)]",
    "success": true
}

{
    "door": {
        "stop_sign": {
            "area": 99,
            "result": false
        }
    }
}

cropped_night_lights_on_garage

night_spotlight:
{
    "message": "The dominant color is (121, 64, 79) with a mixed palette as [(119, 62, 77), (203, 137, 152), (165, 119, 150), (163, 120, 127)]",
    "success": true
}

{
    "door": {
        "stop_sign": {
            "area": 846,
            "result": false
        }
    }
}

cropped_spotllight_garage

night_door_open:
{
    "message": "The dominant color is (19, 20, 19) with a mixed palette as [(11, 12, 12), (19, 20, 19), (4, 4, 4), (28, 26, 27)]",
    "success": true
}

{
    "door": {
        "stop_sign": {
            "area": 111,
            "result": false
        }
    }
}

cropped_night_door_open_garage

I am not sure what lower and upper color values or min/max pixel thresholds I should use so that the first 3 situations are detected and the last one isn't. Any combination I use either one is incorrectly missed or incorrectly detected. For some reason, even when I had the lower RGB values larger than the values of the 4th situations, Swatch marked it as true.

Version

1.0.0

Swatch config file

# REQUIRED: Define a list of objects that are expected to be seen. These can be specific
# to one camera or common between many / all cameras
objects:
  # REQUIRED: Name of the object
  stop_sign:
    # REQUIRED: the lower R, G, B values that are considered a potential match for the object.
    color_lower: 64, 22, 26
    # REQUIRED: the upper R, G, B values that are considered a potential match for the object.
    color_upper: 151, 36, 46
    # OPTIONAL: the min number of pixels with R, G, B values within the bounds to be
    # considered a true positive. This is recommended to be set as a super small amount
    # could be a false positive. (Default: shown below)
    min_area: 1000
    # OPTIONAL: the max number of pixels with R, G, B values within the bounds to be
    # considered a true positive (Default: shown below).
    max_area: 100000

# REQUIRED: Define list of cameras that will be used for color detection.
cameras:
  # REQUIRED: Name of the camera
  garage_cam:
    # REQUIRED: Zones are cropped areas where the object can be expected to be. 
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      door:
        # REQUIRED: Coordinates to crop the zone by. 
        coordinates: 645, 712, 1368, 1434
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:
          - stop_sign

Relevant log output

N/A

Any other information that may be helpful

No response

[Support]: Bright red bin lid cant be detected

Describe the problem you are having

Hi all,
I have spent all day trying to get swatch to detect my bright red bin lid. As others have raised I cannot use the color playground so I have been cropping the image and using online/paint color picker to get a range of colors present on the lid however, whatever I do it will never detect the lid. I have tried changing the color ranges looser and looser until it detects the green bin but it will never detect the red. I must be misunderstanding something. I have also change min are to 0 and it just detects random stuff around the bin but never any red. I attached the crop i took of the top to try get the color palette
Main Scree bin n
Detection

Version

3.1.0 HA Addon

Swatch config file

objects:
  garbage_bin:
    color_variants:
      default:
        color_lower: 120, 20, 40
        color_upper: 200, 100, 140
    min_area: 100
    max_area: 3000
cameras:
  front_yard_camera:
    auto_detect: 10
    snapshot_config:
        url: "http://HA:8123/local/snapshots/bin.jpg"
        bounding_box: true
        clean_snapshot: false
        save_detections: true
        save_misses: true
        mode: "all"
        retain_days: 7
    zones:
      front_yard:
        coordinates: 127, 443, 320, 670
        objects:
          - garbage_bin

Relevant log output

[2024-05-08 16:00:56,415]: INFO - Starting migrations
There is nothing to migrate
[2024-05-08 16:00:56,419]: INFO - There is nothing to migrate
[2024-05-08 16:00:56,420]: INFO - Starting Auto Detection for front_yard_camera
[2024-05-08 16:00:56,420]: INFO - Starting snapshot cleanup
[2024-05-08 16:00:56,420]: INFO - Starting Detection Cleanup

Any other information that may be helpful

No response

[Support]: can't figure out what's wrong

Describe the problem you are having

I copied the example config and simply changed the camera name to reflect an existing HASS one, and adding it's valid snapshot URL.

Version

3.1.0-2717ec6

Swatch config file

# REQUIRED: Define a list of objects that are expected to be seen. These can be specific
# to one camera or common between many / all cameras
objects:
  # REQUIRED: Name of the object
  cancello1:
    # REQUIRED: the list of color variants that this object can be detected as. Useful for
    # different lighting conditions
    color_variants:
      # REQUIRED: the name of the color variant
      default:
        # REQUIRED: the lower R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_lower: 70, 70, 0
        # REQUIRED: the upper R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_upper: 110, 100, 50
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          after: "00:00"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          before: "24:00"
    # OPTIONAL: the min area of the bounding box around groups of matching R, G, B pixels
    # considered a true positive. This is not recommended to be set as a super small amount
    # could be a false positive. (Default: shown below)
    min_area: 1000
    # OPTIONAL: the max area of the bounding box around groups of pixels with R, G, B
    # values within the bounds to be considered a true positive (Default: shown below).
    max_area: 100000
    # OPTIONAL: the min ratio of width/height of bounding box for valid object detection (default: shown below).
    min_ratio: 0
     # OPTIONAL: the max ratio of width/height of bounding box for valid object detection (default: shown below).
    max_ratio: 24000000

# REQUIRED: Define list of cameras that will be used for color detection.
cameras:
  # REQUIRED: Name of the camera
  piazzale:
    # OPTIONAL: Frequency in seconds to run detection on the camera.
    # a value of 0 disables auto detection (Default: shown below).
    auto_detect: 0
    # OPTIONAL: Configure the url and retention of snapshots. (Default: Shown Below)
    snapshot_config:
        # OPTIONAL: but highly recommended, setting the default url for a snapshot to be
        # processed by this camera. This is required for auto detection (Default: none).
        url: "http://user:[email protected]/axis-cgi/jpg/image.cgi"
        # OPTIONAL: Whether or not to draw bounding boxes for confirmed objects in the snapshots (Default: shown below).
        bounding_box: true
        # OPTIONAL: Whether or not to save a clean png of the snapshot along with the annotated jpg (Default: shown below).
        clean_snapshot: true
        # OPTIONAL: Whether or not to save the snapshots of confirmed detections (Default: shown below).
        save_detections: true
        # OPTIONAL: Whether or not to save the snapshots of missed detections (Default: shown below).
        save_misses: false
        # OPTIONAL: Variations of snapshots to keep. Options are all, mask, crop (Default: shown below).
        mode: "all"
        # OPTIONAL: Number of days of snapshots to keep (Default: shown below).
        retain_days: 7
    # REQUIRED: Zones are cropped areas where the object can be expected to be.
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      street:
        # REQUIRED: Coordinates to crop the zone by.
        # NOTE: The order of the coordinates are: x, y, x+w, y+h starting in the top left corner as 0, 0.
        coordinates: 225, 540, 350, 620
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:
          - cancello1

Relevant log output

[2024-02-09 17:05:28,217]: INFO - Starting SwatchApp
[2024-02-09 17:05:28,226]: INFO - Importing SwatchApp Config
[2024-02-09 17:05:28,226]: INFO - Verified SwatchApp Config
Starting migrations
[2024-02-09 17:05:28,243]: INFO - Starting migrations
There is nothing to migrate
[2024-02-09 17:05:28,252]: INFO - There is nothing to migrate
[2024-02-09 17:05:28,254]: INFO - Starting snapshot cleanup
[2024-02-09 17:05:28,254]: INFO - Starting Detection Cleanup
[2024-02-09 17:06:05,185]: ERROR - Exception on /piazzale/street/snapshot.jpg [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1519, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/opt/swatch/swatch/http.py", line 385, in get_latest_zone_snapshot
    jpg_bytes = current_app.snapshot_processor.get_latest_zone_snapshot(
  File "/opt/swatch/swatch/snapshot.py", line 206, in get_latest_zone_snapshot
    crop = img[
TypeError: 'NoneType' object is not subscriptable
[2024-02-09 17:06:05,193]: ERROR - Exception on /piazzale/snapshot.jpg [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1519, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/opt/swatch/swatch/http.py", line 342, in get_latest_camera_snapshot
    jpg_bytes = current_app.snapshot_processor.get_latest_camera_snapshot(camera_name)
  File "/opt/swatch/swatch/snapshot.py", line 185, in get_latest_camera_snapshot
    _, jpg = cv2.imencode(".jpg", img, [int(cv2.IMWRITE_JPEG_QUALITY), 70])
cv2.error: OpenCV(4.6.0) /io/opencv/modules/imgcodecs/src/loadsave.cpp:976: error: (-215:Assertion failed) !image.empty() in function 'imencode'

Any other information that may be helpful

No response

Can't install

Describe the problem you are having

I get the following error when I try to install Swatch. I initially tried to upgrade to 3.1, when that didn't work I tried to uninstall and reinstall swatch.

Failed to install add-on
Can't install crzynik/swatch:3.1.0: 404 Client Error for http+docker://localhost/v1.41/images/create?tag=3.1.0&fromImage=crzynik%2Fswatch&platform=linux%2Famd64: Not Found ("manifest for crzynik/swatch:3.1.0 not found: manifest unknown: manifest unknown")

Updating home assistant doesn't help, restarting ha doesn't help. Restarting the machine doesn't help

I'd love to know what's going on.

Screenshot_20220708-203308_Home Assistant

Version

3.1

Swatch config file

objects:
  # REQUIRED: Name of the object
  tube_light:
    # REQUIRED: the list of color variants that this object can be detected as. Useful for
    # different lighting conditions
    color_variants:
      # REQUIRED: the name of the color variant
      default:
        # REQUIRED: the lower R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_lower: 70, 70, 0
        # REQUIRED: the upper R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_upper: 110, 100, 50
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          after: "00:00"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          before: "24:00"
    # OPTIONAL: the min area of the bounding box around groups of matching R, G, B pixels
    # considered a true positive. This is not recommended to be set as a super small amount
    # could be a false positive. (Default: shown below)
    min_area: 2
    # OPTIONAL: the max area of the bounding box around groups of pixels with R, G, B
    # values within the bounds to be considered a true positive (Default: shown below).
    max_area: 100000
    # OPTIONAL: the min ratio of width/height of bounding box for valid object detection (default: shown below).
    min_ratio: 0
     # OPTIONAL: the max ratio of width/height of bounding box for valid object detection (default: shown below).
    max_ratio: 24000000
    
cameras:
  # REQUIRED: Name of the camera
  greatroom_cam:
    # OPTIONAL: Frequency in seconds to run detection on the camera.
    # a value of 0 disables auto detection (Default: shown below).
    auto_detect: 30
    # OPTIONAL: Configure the url and retention of snapshots. (Default: Shown Below)
    snapshot_config:
        # OPTIONAL: but highly recommended, setting the default url for a snapshot to be
        # processed by this camera. This is required for auto detection (Default: none).
        url: "http://192.168.0.5:5000/snapshot/dog-cam.jpg"
        # OPTIONAL: Whether or not to draw bounding boxes for confirmed objects in the snapshots (Default: shown below).
        bounding_box: true
        # OPTIONAL: Whether or not to save a clean png of the snapshot along with the annotated jpg (Default: shown below).
        clean_snapshot: true
        # OPTIONAL: Whether or not to save the snapshots of confirmed detections (Default: shown below).
        save_detections: true
        # OPTIONAL: Whether or not to save the snapshots of missed detections (Default: shown below).
        save_misses: false
        # OPTIONAL: Variations of snapshots to keep. Options are all, mask, crop (Default: shown below).
        mode: "all"
        # OPTIONAL: Number of days of snapshots to keep (Default: shown below).
        retain_days: 7
    # REQUIRED: Zones are cropped areas where the object can be expected to be.
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      livingroom:
        # REQUIRED: Coordinates to crop the zone by.
        # NOTE: The order of the coordinates are: x, y, x+w, y+h starting in the top left corner as 0, 0.
        coordinates: 1000, 0, 1200, 125
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:
          - tube_light

Relevant log output

N/A

Any other information that may be helpful

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.