Torsten Simon 2 år sedan
förälder
incheckning
67a6dacc59
2 ändrade filer med 18 tillägg och 15 borttagningar
  1. 4 1
      install.sh
  2. 14 14
      src/data-writer.py

+ 4 - 1
install.sh

@@ -19,4 +19,7 @@ sudo journalctl -fu solar
 
 sudo apt-get install -y libimlib2-dev
 git clone https://github.com/auerswal/ssocr
-cd ssocr && sudo make install
+cd ssocr && sudo make install
+
+#crontab -e
+# 0 * * * * find /home/pi/solar-monitor/src/images/ -name *.jpg -type f -mmin +60 -delete 

+ 14 - 14
src/data-writer.py

@@ -71,7 +71,7 @@ class SolarMonitor:
         return masked_image
     
     def thresholding2(self, image):
-        image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+        # image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
         # Taking a matrix of size 5 as the kernel
         kernel = np.ones((2, 2), np.uint8)
         
@@ -84,8 +84,8 @@ class SolarMonitor:
         #image = cv2.erode(image, kernel, iterations=1)
         #image = cv2.convertScaleAbs(image, alpha=2.0, beta=-50)        
         #image = (255 - image)
-        image = self.getMasked(image)
-        image = cv2.dilate(image, kernel, iterations=1)
+        # image = self.getMasked(image)
+        # image = cv2.dilate(image, kernel, iterations=1)
         image = cv2.medianBlur(image,3)
         #image = np.invert(image)
         return image
@@ -96,19 +96,19 @@ class SolarMonitor:
         #height= 60
         #width=230
         #return image[top : (top + height) , left: (left + width)]
-        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_BC = np.sqrt(((pt_B[0] - pt_C[0]) ** 2) + ((pt_B[1] - pt_C[1]) ** 2))
+        pt_TL = [260, 190]
+        pt_BL = [260, 242]
+        pt_BR = [500, 240]
+        pt_TR = [500, 190]
+        width_AD = np.sqrt(((pt_TL[0] - pt_TR[0]) ** 2) + ((pt_TL[1] - pt_TR[1]) ** 2))
+        width_BC = np.sqrt(((pt_BL[0] - pt_BR[0]) ** 2) + ((pt_BL[1] - pt_BR[1]) ** 2))
         maxWidth = max(int(width_AD), int(width_BC))
 
 
-        height_AB = np.sqrt(((pt_A[0] - pt_B[0]) ** 2) + ((pt_A[1] - pt_B[1]) ** 2))
-        height_CD = np.sqrt(((pt_C[0] - pt_D[0]) ** 2) + ((pt_C[1] - pt_D[1]) ** 2))
+        height_AB = np.sqrt(((pt_TL[0] - pt_BL[0]) ** 2) + ((pt_TL[1] - pt_BL[1]) ** 2))
+        height_CD = np.sqrt(((pt_BR[0] - pt_TR[0]) ** 2) + ((pt_BR[1] - pt_TR[1]) ** 2))
         maxHeight = max(int(height_AB), int(height_CD))
-        input_pts = np.float32([pt_A, pt_B, pt_C, pt_D])
+        input_pts = np.float32([pt_TL, pt_BL, pt_BR, pt_TR])
         output_pts = np.float32([[0, 0],
                         [0, maxHeight - 1],
                         [maxWidth - 1, maxHeight - 1],
@@ -126,7 +126,7 @@ class SolarMonitor:
         self.camera.awb_gains = (1.5, 2.0)
         self.camera.shutter_speed = 10000
         self.camera.iso = 800
-        self.camera.rotation = 180
+        self.camera.rotation = 0
 
     def capture(self): 
         from picamera.array import PiRGBArray
@@ -178,7 +178,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), 1, cv2.LINE_AA)
+                img = cv2.putText(img, str(results), (75, 22), cv2.FONT_HERSHEY_SIMPLEX, 0.25, (255, 255, 255), 1, cv2.LINE_AA)
             cv2.imwrite(file + '_r.jpg', img, [cv2.IMWRITE_JPEG_QUALITY, 35])
             time.sleep(5)