2 次代码提交 8dbdf2dad1 ... 12a372a80c

作者 SHA1 备注 提交日期
  Torsten Simon 12a372a80c Merge branch 'master' of https://git.server.tsgames.de/Raspberry/solar-monitor 2 年之前
  Torsten Simon 67a6dacc59 reader 2 年之前
共有 2 个文件被更改,包括 13 次插入8 次删除
  1. 4 1
      install.sh
  2. 9 7
      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 

+ 9 - 7
src/data-writer.py

@@ -72,7 +72,9 @@ 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)
         
         #kernel = np.ones((2, 2), np.uint8)
         # The first parameter is the original image,
@@ -85,7 +87,7 @@ class SolarMonitor:
         #image = cv2.convertScaleAbs(image, alpha=2.0, beta=-50)        
         #image = (255 - image)
         # image = self.getMasked(image)
-        #image = cv2.dilate(image, kernel, iterations=1)
+        # 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
@@ -104,10 +106,10 @@ class SolarMonitor:
         #height= 60
         #width=230
         #return image[top : (top + height) , left: (left + width)]
-        pt_TL = [280, 205]
-        pt_TR = [486, 205]
-        pt_BL = [280, 250]
-        pt_BR = [486, 250]
+        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))
@@ -186,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)