Marthee commited on
Commit
7c9bfe2
·
1 Parent(s): 917cc22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -85,7 +85,7 @@ def detectCircles(imgOriginal ):
85
  detected_circles = np.round(detected_circles[0, :]).astype("int")
86
  #DRAW CIRCLES
87
  for (x, y, r) in detected_circles:
88
- cv2.circle(im, (x, y), r, (255, 255, 255), 6)
89
  im=cv2.medianBlur(im,1)
90
  print('circles')
91
  # cv2_imshow(im)
@@ -143,7 +143,7 @@ def DashedPreprocessing(imgOriginal,imgnoSmall):
143
 
144
  def removeDashedLines(img4, imgBW ,max,min):
145
 
146
- imgLines= cv2.HoughLinesP(img4,1,np.pi/310,250,minLineLength=(max-min)//1.8,maxLineGap = 120) #was w-h , gap=150 0.99
147
  #1 120
148
 
149
  for i in range(len(imgLines)):
@@ -165,7 +165,7 @@ def removeSmallDashes(imgOriginal,green):
165
  img2=cv2.erode(img1, kernel3, iterations=2)
166
 
167
  smalldashes=cv2.medianBlur(img2,5)
168
- smalldashes=cv2.medianBlur(smalldashes,5)
169
  # cv2_imshow(smalldashes)
170
  smalldashesOut=green.copy()
171
  smalldashesOut=cv2.cvtColor(smalldashesOut,cv2.COLOR_GRAY2BGR)
@@ -174,7 +174,7 @@ def removeSmallDashes(imgOriginal,green):
174
  imgCopy=imgOriginal.copy()
175
  for i in range(len(imgLines)):
176
  for x1,y1,x2,y2 in imgLines[i]:
177
- cv2.line(smalldashesOut,(x1,y1),(x2,y2),(0,255,0),3)
178
 
179
 
180
  smalldashesOut=smalldashesOut[:,:,1]
@@ -194,13 +194,13 @@ def removeDashedLinesSmall(img4, imgBW ,max,min):
194
 
195
  imgBW=cv2.cvtColor(imgBW,cv2.COLOR_GRAY2BGR)
196
 
197
- imgLines= cv2.HoughLinesP(img4,1,np.pi/300,150,minLineLength=(max-min)//2.2,maxLineGap = 70) #2.1
198
 
199
  for i in range(len(imgLines)):
200
  for x1,y1,x2,y2 in imgLines[i]:
201
  dist=euclidian_distance((x1,y1), (x2,y2))
202
  # if dist > 1300 and dist <1450:
203
- if dist >= (max-min)//2.1 and dist < (max-min)//1.95: #1.4
204
  cv2.line(imgBW,(x1,y1),(x2,y2),(0,255,0),3)
205
 
206
  im_copy=imgBW.copy()
@@ -212,17 +212,17 @@ def ConnectBeamLines(smalldashesOut):
212
  green1=cv2.bitwise_not(smalldashesOut)
213
  green2=smalldashesOut.copy()
214
  green2=cv2.cvtColor(green2,cv2.COLOR_GRAY2BGR)
215
- imgLines= cv2.HoughLinesP(green1,0.05,np.pi/250,10,minLineLength=30,maxLineGap = 20) #was w-h , gap=150 #50
216
  for i in range(len(imgLines)):
217
  for x1,y1,x2,y2 in imgLines[i]:
218
- cv2.line(green2,(x1,y1),(x2,y2),(0,0,0),2)
219
 
220
- imgLines= cv2.HoughLinesP(green1,0.5,np.pi/360,10,minLineLength=30,maxLineGap = 20) #try 180
221
 
222
 
223
  for i in range(len(imgLines)):
224
  for x1,y1,x2,y2 in imgLines[i]:
225
- cv2.line(green2,(x1,y1),(x2,y2),(0,0,0),2)
226
  # cv2_imshow(green2)
227
  return green2
228
 
 
85
  detected_circles = np.round(detected_circles[0, :]).astype("int")
86
  #DRAW CIRCLES
87
  for (x, y, r) in detected_circles:
88
+ cv2.circle(im, (x, y), r, (255, 255, 255), 5)
89
  im=cv2.medianBlur(im,1)
90
  print('circles')
91
  # cv2_imshow(im)
 
143
 
144
  def removeDashedLines(img4, imgBW ,max,min):
145
 
146
+ imgLines= cv2.HoughLinesP(img4,1,np.pi/310,30,minLineLength=(max-min)//1.8,maxLineGap = 120) #was w-h , gap=150 0.99
147
  #1 120
148
 
149
  for i in range(len(imgLines)):
 
165
  img2=cv2.erode(img1, kernel3, iterations=2)
166
 
167
  smalldashes=cv2.medianBlur(img2,5)
168
+ smalldashes=cv2.medianBlur(smalldashes,7)
169
  # cv2_imshow(smalldashes)
170
  smalldashesOut=green.copy()
171
  smalldashesOut=cv2.cvtColor(smalldashesOut,cv2.COLOR_GRAY2BGR)
 
174
  imgCopy=imgOriginal.copy()
175
  for i in range(len(imgLines)):
176
  for x1,y1,x2,y2 in imgLines[i]:
177
+ cv2.line(smalldashesOut,(x1,y1),(x2,y2),(0,255,0),2)
178
 
179
 
180
  smalldashesOut=smalldashesOut[:,:,1]
 
194
 
195
  imgBW=cv2.cvtColor(imgBW,cv2.COLOR_GRAY2BGR)
196
 
197
+ imgLines= cv2.HoughLinesP(img4,1,np.pi/100,20,minLineLength=(max-min)//2.2,maxLineGap = 70) #2.1
198
 
199
  for i in range(len(imgLines)):
200
  for x1,y1,x2,y2 in imgLines[i]:
201
  dist=euclidian_distance((x1,y1), (x2,y2))
202
  # if dist > 1300 and dist <1450:
203
+ if dist >= (max-min)//2.1 and dist < (max-min)//1.9: #1.4
204
  cv2.line(imgBW,(x1,y1),(x2,y2),(0,255,0),3)
205
 
206
  im_copy=imgBW.copy()
 
212
  green1=cv2.bitwise_not(smalldashesOut)
213
  green2=smalldashesOut.copy()
214
  green2=cv2.cvtColor(green2,cv2.COLOR_GRAY2BGR)
215
+ imgLines= cv2.HoughLinesP(green1,0.05,np.pi/250,10,minLineLength=25,maxLineGap = 20) #was w-h , gap=150 #50
216
  for i in range(len(imgLines)):
217
  for x1,y1,x2,y2 in imgLines[i]:
218
+ cv2.line(green2,(x1,y1),(x2,y2),(0,0,0),1)
219
 
220
+ imgLines= cv2.HoughLinesP(green1,0.3,np.pi/360,10,minLineLength=25,maxLineGap = 20) #try 180
221
 
222
 
223
  for i in range(len(imgLines)):
224
  for x1,y1,x2,y2 in imgLines[i]:
225
+ cv2.line(green2,(x1,y1),(x2,y2),(0,0,0),1)
226
  # cv2_imshow(green2)
227
  return green2
228