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

Add watched_plate arg #27

Closed
robmarkcole opened this issue Feb 24, 2021 · 2 comments
Closed

Add watched_plate arg #27

robmarkcole opened this issue Feb 24, 2021 · 2 comments

Comments

@robmarkcole
Copy link
Owner

robmarkcole commented Feb 24, 2021

Parallels robmarkcole/HASS-Sighthound#22

Add a watched_plate arg that is a list of plates to watch for, allowing fuzzy matching. I.e. a matched plate will be detected when there is a good match of characters using regex. For each plate an attribute is exposed which is a binary sensor indicating if the plate was in the last scanned imaged or not. Add a watched_plate event as well?

@robmarkcole
Copy link
Owner Author

robmarkcole commented Feb 26, 2021

The api returns the most likely plate, but also other candidate plates, and these can be matched against also:

[ 'plate': 'kfa8725',
  'region': {'code': 'us-pa', 'score': 0.979},
  'score': 0.899,
  'candidates': [{'score': 0.899, 'plate': 'kfa8725'},
   {'score': 0.779, 'plate': 'kfab725'}],

The following function returns all candidate plates, could just match on this:

from typing import List, Dict

def get_plates(results : List[Dict]) -> List[str]:
    """
    Return the list of candidate plates. 
    If no plates empty list returned.
    """
    plates = []
    candidates = [result['candidates'] for result in results]
    for candidate in candidates:
        cand_plates = [cand['plate'] for cand in candidate]
        for plate in cand_plates:
            plates.append(plate)
    return list(set(plates))

get_plates(response.json()['results'])

... ['kfa8726', 'kfa8725', 'kfab725', 'kfab726']

Could also count the number of letters that must exist in any detected plate, this could also be an arg? Too complicated

@robmarkcole
Copy link
Owner Author

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant