|
@@ -99,10 +99,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 = [228, 392]
|
|
|
|
|
- pt_B = [228, 430]
|
|
|
|
|
- pt_C = [419, 424]
|
|
|
|
|
- pt_D = [420, 386]
|
|
|
|
|
|
|
+ pt_A = [225, 394]
|
|
|
|
|
+ pt_B = [225, 432]
|
|
|
|
|
+ pt_C = [419, 426]
|
|
|
|
|
+ pt_D = [420, 388]
|
|
|
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))
|
|
@@ -123,7 +123,7 @@ class SolarMonitor:
|
|
|
def initCamera(self):
|
|
def initCamera(self):
|
|
|
from picamera import PiCamera
|
|
from picamera import PiCamera
|
|
|
self.camera = PiCamera(
|
|
self.camera = PiCamera(
|
|
|
- resolution=(800, 600)
|
|
|
|
|
|
|
+ resolution=(800, 608)
|
|
|
)
|
|
)
|
|
|
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)
|
|
@@ -132,11 +132,13 @@ class SolarMonitor:
|
|
|
self.camera.rotation = 180
|
|
self.camera.rotation = 180
|
|
|
|
|
|
|
|
def capture(self):
|
|
def capture(self):
|
|
|
|
|
+ from picamera.array import PiRGBArray
|
|
|
|
|
+ rawCapture = PiRGBArray(self.camera)
|
|
|
file = "images/" + str(datetime.now()) + ".jpg"
|
|
file = "images/" + str(datetime.now()) + ".jpg"
|
|
|
- self.camera.capture(file, format="jpeg", quality=10)
|
|
|
|
|
- print("Captured.")
|
|
|
|
|
- img = cv2.imread(file)
|
|
|
|
|
|
|
+ self.camera.capture(rawCapture, format="bgr")
|
|
|
|
|
+ img = rawCapture.array
|
|
|
img = self.crop(img)
|
|
img = self.crop(img)
|
|
|
|
|
+ print("Captured.")
|
|
|
return [file, img]
|
|
return [file, img]
|
|
|
|
|
|
|
|
def writeData(self, results):
|
|
def writeData(self, results):
|
|
@@ -179,9 +181,8 @@ class SolarMonitor:
|
|
|
print(results)
|
|
print(results)
|
|
|
if results:
|
|
if results:
|
|
|
self.writeData(results)
|
|
self.writeData(results)
|
|
|
- img = cv2.putText(img, str(results), (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (255,255,255), 2, cv2.LINE_AA)
|
|
|
|
|
|
|
+ img = cv2.putText(img, str(results), (75, 22), cv2.FONT_HERSHEY_SIMPLEX, 0.25, (0), 1, cv2.LINE_AA)
|
|
|
cv2.imwrite(file + '_r.jpg', img, [cv2.IMWRITE_JPEG_QUALITY, 85])
|
|
cv2.imwrite(file + '_r.jpg', img, [cv2.IMWRITE_JPEG_QUALITY, 85])
|
|
|
- #os.unlink(file)
|
|
|
|
|
time.sleep(5)
|
|
time.sleep(5)
|
|
|
|
|
|
|
|
solar = SolarMonitor(test = False)
|
|
solar = SolarMonitor(test = False)
|