|
|
@@ -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)
|
|
|
|