|
|
@@ -15,7 +15,7 @@ client = InfluxDBClient(host="localhost", port=8086, username="influxdb", passwo
|
|
|
client.create_database("influxdb")
|
|
|
client.switch_database('influxdb')
|
|
|
class SolarMonitor:
|
|
|
- BRIGHTNESS_THRESHOLD = 78 # 0-255
|
|
|
+ BRIGHTNESS_THRESHOLD = 50 # 0-255
|
|
|
camera = None
|
|
|
def __init__(self, test = False):
|
|
|
self.test = test
|
|
|
@@ -27,6 +27,7 @@ class SolarMonitor:
|
|
|
# https://github.com/adrianlazaro8/Tesseract_sevenSegmentsLetsGoDigital
|
|
|
data = pytesseract.image_to_data(img, lang='lets', config=custom_oem, output_type=Output.DICT)
|
|
|
#data = pytesseract.image_to_data(img, lang='letsgodigital', config=custom_oem, output_type=Output.DICT)
|
|
|
+ #data = pytesseract.image_to_data(img, config=custom_oem, output_type=Output.DICT)
|
|
|
print(data)
|
|
|
results = []
|
|
|
for i in range(len(data['text'])):
|
|
|
@@ -42,7 +43,7 @@ class SolarMonitor:
|
|
|
def getMasked(self, image):
|
|
|
pixel_values = image.reshape((-1, 1))
|
|
|
pixel_values = np.float32(pixel_values)
|
|
|
- _, result = cv2.threshold(image,self.BRIGHTNESS_THRESHOLD,255,cv2.THRESH_BINARY)
|
|
|
+ _, result = cv2.threshold(image,self.BRIGHTNESS_THRESHOLD,255,cv2.THRESH_TRUNC)
|
|
|
return result
|
|
|
# define stopping criteria
|
|
|
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 100, 0.2)
|
|
|
@@ -75,6 +76,7 @@ class SolarMonitor:
|
|
|
# Taking a matrix of size 5 as the kernel
|
|
|
kernel = np.ones((2, 2), np.uint8)
|
|
|
|
|
|
+ #kernel = np.ones((2, 2), np.uint8)
|
|
|
# The first parameter is the original image,
|
|
|
# kernel is the matrix with which image is
|
|
|
# convolved and third parameter is the number
|
|
|
@@ -87,6 +89,14 @@ class SolarMonitor:
|
|
|
# image = self.getMasked(image)
|
|
|
# image = cv2.dilate(image, kernel, iterations=1)
|
|
|
image = cv2.medianBlur(image,3)
|
|
|
+ #thresh = cv2.adaptiveThreshold(image,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,51,1)
|
|
|
+ # detect the contours on the binary image using cv2.CHAIN_APPROX_NONE
|
|
|
+ #contours, hierarchy = cv2.findContours(image=thresh, mode=cv2.RETR_TREE, method=cv2.CHAIN_APPROX_NONE)
|
|
|
+
|
|
|
+ #cv2.drawContours(image=image, contours=contours, contourIdx=-1, color=(255, 255, 255), thickness=1, lineType=cv2.LINE_AA)
|
|
|
+
|
|
|
+ #im2, contours = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
|
|
+ # cv2.drawContours(image, contours, -1, (0,255,0), 3)
|
|
|
#image = np.invert(image)
|
|
|
return image
|
|
|
|
|
|
@@ -178,7 +188,7 @@ class SolarMonitor:
|
|
|
print(results)
|
|
|
if results:
|
|
|
self.writeData(results)
|
|
|
- img = cv2.putText(img, str(results), (75, 22), cv2.FONT_HERSHEY_SIMPLEX, 0.25, (255, 255, 255), 1, cv2.LINE_AA)
|
|
|
+ img = cv2.putText(img, str(results), (75, 22), cv2.FONT_HERSHEY_SIMPLEX, 0.25, (255, 255, 255, 255, 255), 1, cv2.LINE_AA)
|
|
|
cv2.imwrite(file + '_r.jpg', img, [cv2.IMWRITE_JPEG_QUALITY, 35])
|
|
|
time.sleep(5)
|
|
|
|