NickM-27 / swatch

Color detection in images to capture presense of known objects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Support]: Possible Config Issues/ No Detections Firing

ssryan9 opened this issue · comments

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

I don't see min_area defined, default value is 1000 and that looks like it will need to be lowered a lot (maybe try 0 just to see what happens, but that's generally not recommended)

Still getting nothing despite adding min_area. Currently have it set at 0

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

Did you use the color playground to get those color values?

Yes I did. I can give it another shot

Oh I just realized the issue, auto_detect is 0 by default so the detections will not be done automatically. You'll want to set that to how ever many seconds it should do detections

That did the trick - don't know how I missed it. Thank you!!

How often do the sensors update as part of the integration? I've removed the orange from the image and the sensor hasn't updated. How often are detections cleared out? I assume as frequently as I have the auto-detect set to?

Noticed some errors in the logs as well:

[2022-06-09 09:13:13,447]: INFO - Starting SwatchApp
[2022-06-09 09:13:13,463]: INFO - Importing SwatchApp Config
[2022-06-09 09:13:13,464]: INFO - Verified SwatchApp Config
Starting migrations
[2022-06-09 09:13:13,469]: INFO - Starting migrations
There is nothing to migrate
[2022-06-09 09:13:13,491]: INFO - There is nothing to migrate
[2022-06-09 09:13:13,496]: INFO - Starting Auto Detection for BB_Camera
[2022-06-09 09:13:13,498]: INFO - Starting snapshot cleanup
[2022-06-09 09:13:13,499]: INFO - Starting Detection Cleanup
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/opt/swatch/swatch/detection.py", line 123, in run
self.handle_detections(result)
File "/opt/swatch/swatch/detection.py", line 86, in handle_detections
self.obj_data[non_unique_id]["variant"] = object_result["variant"]
KeyError: 'variant'

How often do the sensors update as part of the integration?

Every 30 seconds or when the detect service is manually run through HA. It uses host:4500/api/all/latest when checking every 30 seconds

How often are detections cleared out? I assume as frequently as I have the auto-detect set to?

Not sure what you mean by cleared out, but if it does the auto detect and doesn't see it then the detection event ends

Noticed some errors in the logs as well:

Interesting, I'll fix that

Every 30 seconds or when the detect service is manually run through HA. It uses host:4500/api/all/latest when checking every 30 seconds

The sensor is not updating when the object is removed from the frame.

Updated to the newly released version and now getting this error:
[2022-06-09 10:39:30,724]: INFO - Starting SwatchApp
[2022-06-09 10:39:30,735]: INFO - Importing SwatchApp Config
[2022-06-09 10:39:30,735]: INFO - Verified SwatchApp Config
Starting migrations
[2022-06-09 10:39:30,743]: INFO - Starting migrations
There is nothing to migrate
[2022-06-09 10:39:30,758]: INFO - There is nothing to migrate
[2022-06-09 10:39:30,762]: INFO - Starting Auto Detection for BB_Camera
[2022-06-09 10:39:30,763]: INFO - Starting snapshot cleanup
[2022-06-09 10:39:30,764]: INFO - Starting Detection Cleanup
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/opt/swatch/swatch/detection.py", line 125, in run
self.handle_detections(result)
File "/opt/swatch/swatch/detection.py", line 111, in handle_detections
if object_result["result"]:
KeyError: 'result'

I see, odds are it's not being removed because it's crashing, and seems to be something weird going on with it crashing. I have not been able to reproduce this

3.0.4 should be working

Yep it's fixed now. Thank you!