Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
daytonturner opened this issue Nov 16, 2023 · 0 comments
Open

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

daytonturner opened this issue Nov 16, 2023 · 0 comments
Labels
config Having to do with the configuration of swatch support Requesting support for swatch

Comments

@daytonturner
Copy link

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

@daytonturner daytonturner added config Having to do with the configuration of swatch support Requesting support for swatch labels Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Having to do with the configuration of swatch support Requesting support for swatch
Projects
None yet
Development

No branches or pull requests

1 participant