|
@@ -25,7 +25,7 @@ class SolarMonitor:
|
|
|
custom_oem=r'--oem 3 --psm 7'
|
|
custom_oem=r'--oem 3 --psm 7'
|
|
|
# https://github.com/adrianlazaro8/Tesseract_sevenSegmentsLetsGoDigital
|
|
# 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='lets', config=custom_oem, output_type=Output.DICT)
|
|
|
- #data = pytesseract.image_to_data(img, lang='letsgodigital', output_type=Output.DICT)
|
|
|
|
|
|
|
+ #data = pytesseract.image_to_data(img, lang='letsgodigital', config=custom_oem, output_type=Output.DICT)
|
|
|
print(data)
|
|
print(data)
|
|
|
results = []
|
|
results = []
|
|
|
for i in range(len(data['text'])):
|
|
for i in range(len(data['text'])):
|
|
@@ -35,7 +35,7 @@ class SolarMonitor:
|
|
|
results.append(text)
|
|
results.append(text)
|
|
|
if len(results) == 2:
|
|
if len(results) == 2:
|
|
|
results = list(map(lambda x: int(x) / 10.,results ))
|
|
results = list(map(lambda x: int(x) / 10.,results ))
|
|
|
- if results[0] < 100 and results[1] < 1000:
|
|
|
|
|
|
|
+ if results[0] < 80 and results[1] < 900:
|
|
|
return results
|
|
return results
|
|
|
return None
|
|
return None
|
|
|
def thresholding(self, image):
|
|
def thresholding(self, image):
|
|
@@ -85,10 +85,11 @@ class SolarMonitor:
|
|
|
# convolved and third parameter is the number
|
|
# convolved and third parameter is the number
|
|
|
# of iterations, which will determine how much
|
|
# of iterations, which will determine how much
|
|
|
# you want to erode/dilate a given image.
|
|
# you want to erode/dilate a given image.
|
|
|
|
|
+ image = cv2.convertScaleAbs(image, alpha=10.0, beta=-500)
|
|
|
#image = cv2.dilate(image, kernel, iterations=1)
|
|
#image = cv2.dilate(image, kernel, iterations=1)
|
|
|
#image = cv2.erode(image, kernel, iterations=1)
|
|
#image = cv2.erode(image, kernel, iterations=1)
|
|
|
- image = cv2.convertScaleAbs(image, alpha=2.5, beta=-210)
|
|
|
|
|
- image = (255 - image)
|
|
|
|
|
|
|
+ #image = cv2.convertScaleAbs(image, alpha=2.0, beta=-50)
|
|
|
|
|
+ #image = (255 - image)
|
|
|
image = cv2.medianBlur(image,3)
|
|
image = cv2.medianBlur(image,3)
|
|
|
#image = np.invert(image)
|
|
#image = np.invert(image)
|
|
|
return image
|
|
return image
|
|
@@ -99,10 +100,10 @@ class SolarMonitor:
|
|
|
#height= 60
|
|
#height= 60
|
|
|
#width=230
|
|
#width=230
|
|
|
#return image[top : (top + height) , left: (left + width)]
|
|
#return image[top : (top + height) , left: (left + width)]
|
|
|
- pt_A = [225, 394]
|
|
|
|
|
- pt_B = [225, 432]
|
|
|
|
|
- pt_C = [419, 426]
|
|
|
|
|
- pt_D = [420, 388]
|
|
|
|
|
|
|
+ pt_A = [225, 393]
|
|
|
|
|
+ pt_B = [223, 432]
|
|
|
|
|
+ pt_C = [420, 426]
|
|
|
|
|
+ pt_D = [422, 387]
|
|
|
width_AD = np.sqrt(((pt_A[0] - pt_D[0]) ** 2) + ((pt_A[1] - pt_D[1]) ** 2))
|
|
width_AD = np.sqrt(((pt_A[0] - pt_D[0]) ** 2) + ((pt_A[1] - pt_D[1]) ** 2))
|
|
|
width_BC = np.sqrt(((pt_B[0] - pt_C[0]) ** 2) + ((pt_B[1] - pt_C[1]) ** 2))
|
|
width_BC = np.sqrt(((pt_B[0] - pt_C[0]) ** 2) + ((pt_B[1] - pt_C[1]) ** 2))
|
|
|
maxWidth = max(int(width_AD), int(width_BC))
|
|
maxWidth = max(int(width_AD), int(width_BC))
|
|
@@ -127,7 +128,7 @@ class SolarMonitor:
|
|
|
)
|
|
)
|
|
|
self.camera.awb_mode = 'off'
|
|
self.camera.awb_mode = 'off'
|
|
|
self.camera.awb_gains = (1.5, 2.0)
|
|
self.camera.awb_gains = (1.5, 2.0)
|
|
|
- self.camera.shutter_speed = 50000
|
|
|
|
|
|
|
+ self.camera.shutter_speed = 10000
|
|
|
self.camera.iso = 800
|
|
self.camera.iso = 800
|
|
|
self.camera.rotation = 180
|
|
self.camera.rotation = 180
|
|
|
|
|
|
|
@@ -181,7 +182,7 @@ class SolarMonitor:
|
|
|
print(results)
|
|
print(results)
|
|
|
if results:
|
|
if results:
|
|
|
self.writeData(results)
|
|
self.writeData(results)
|
|
|
- img = cv2.putText(img, str(results), (75, 22), cv2.FONT_HERSHEY_SIMPLEX, 0.25, (0), 1, cv2.LINE_AA)
|
|
|
|
|
|
|
+ img = cv2.putText(img, str(results), (75, 22), cv2.FONT_HERSHEY_SIMPLEX, 0.25, (255), 1, cv2.LINE_AA)
|
|
|
cv2.imwrite(file + '_r.jpg', img, [cv2.IMWRITE_JPEG_QUALITY, 35])
|
|
cv2.imwrite(file + '_r.jpg', img, [cv2.IMWRITE_JPEG_QUALITY, 35])
|
|
|
time.sleep(5)
|
|
time.sleep(5)
|
|
|
|
|
|