forked from Galaxia5987/FRCVision-2019
/
file_hsv.py
30 lines (23 loc) · 859 Bytes
/
file_hsv.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from file import File
class FileHSV:
"""HSV value handler that loads values from a file."""
def __init__(self, name):
"""
Instantiate a HSV value handler.
:param name: Target name
"""
self.file = File(name, {'H': (0, 255), 'S': (0, 255), 'V': (0, 255)}, 'hsv', 'json')
self.hsv_values = self.file.load_file()
def save_hsv_values(self):
"""Implement this method as a dry method because this handler doesn't save values."""
pass
def reload(self):
"""Reload the values from file."""
self.hsv_values = self.file.load_file()
def get_hsv(self) -> dict:
"""
Get current HSV.
This method is here to allow diversity, so we can use FileHSV and also Trackbars.
:return: Cached HSV values
"""
return self.hsv_values