freealise commited on
Commit
5772aff
·
verified ·
1 Parent(s): 18e385b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -150,13 +150,15 @@ def remove_bg(fl):
150
  element = cv2.getStructuringElement(cv2.MORPH_RECT, (2*b+1, 2*b+1), (b,b))
151
  frame_ = cv2.erode(cv2.dilate(frame_, element), element)
152
 
 
153
  #correct hue against light
154
  bg_gray = cv2.cvtColor(cv2.cvtColor(bg, cv2.COLOR_BGR2GRAY), cv2.COLOR_GRAY2BGR)
155
  bg_diff = (bg-bg_gray).astype(np.int16)
156
  frame_c = (frame.astype(np.int16)-bg_diff).astype(np.uint8)
 
157
 
158
  #remove regions of low saturation and lightness (get scene without shadow)
159
- m = cv2.inRange(cv2.cvtColor(frame_c, cv2.COLOR_RGB2HSV), np.array([0,0,0]), np.array([180,32,127]))
160
  frame[m>0] = (127,127,127)
161
  frame = cv2.medianBlur(frame, b)
162
 
 
150
  element = cv2.getStructuringElement(cv2.MORPH_RECT, (2*b+1, 2*b+1), (b,b))
151
  frame_ = cv2.erode(cv2.dilate(frame_, element), element)
152
 
153
+
154
  #correct hue against light
155
  bg_gray = cv2.cvtColor(cv2.cvtColor(bg, cv2.COLOR_BGR2GRAY), cv2.COLOR_GRAY2BGR)
156
  bg_diff = (bg-bg_gray).astype(np.int16)
157
  frame_c = (frame.astype(np.int16)-bg_diff).astype(np.uint8)
158
+
159
 
160
  #remove regions of low saturation and lightness (get scene without shadow)
161
+ m = cv2.inRange(cv2.cvtColor(frame_c, cv2.COLOR_RGB2HSV), np.array([0,0,0]), np.array([180,32,64]))
162
  frame[m>0] = (127,127,127)
163
  frame = cv2.medianBlur(frame, b)
164