freealise commited on
Commit
360fdc1
1 Parent(s): 307e865

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -13
app.py CHANGED
@@ -161,10 +161,10 @@ def make_video(video_path, outdir='./vis_video_depth', encoder='vits'):
161
 
162
  cv2.imwrite(f"f{count}.jpg", raw_frame)
163
  orig_frames.append(f"f{count}.jpg")
164
- masks.append(f"f{count}.jpg")
165
 
166
  cv2.imwrite(f"f{count}_dmap.jpg", depth_color)
167
  depth_frames.append(f"f{count}_dmap.jpg")
 
168
  count += 1
169
 
170
  final_vid = create_video(depth_frames, frame_rate, "depth")
@@ -241,8 +241,7 @@ def pano_depth_to_world_points(depth):
241
  def rgb2gray(rgb):
242
  return np.dot(rgb[...,:3], [0.333, 0.333, 0.333])
243
 
244
- def get_mesh(image, mask, blur_data, loadall):
245
- global depths
246
  global locations
247
  global mesh
248
  if loadall == False:
@@ -250,9 +249,8 @@ def get_mesh(image, mask, blur_data, loadall):
250
  fnum = frame_selected
251
 
252
  #print(depth["composite"])
253
- print(depths[fnum])
254
- blur_img = blur_image(mask["composite"], cv2.cvtColor(depths[fnum], cv2.COLOR_RGB2GRAY), blur_data)
255
- gdepth = rgb2gray(depths[fnum])
256
 
257
  print('depth to gray - ok')
258
  points = pano_depth_to_world_points(gdepth)
@@ -299,8 +297,8 @@ def blur_image(image, depth, blur_data):
299
  j = 0
300
  while j < 256:
301
  i = 255 - j
302
- blur_lo = i
303
- blur_hi = i+1
304
  blur_mask = cv2.inRange(depth, blur_lo, blur_hi)
305
 
306
  print(f'kernel size {int(blur_a[j])}')
@@ -352,12 +350,7 @@ def draw_mask(v, d, evt: gr.EventData):
352
  print(mask)
353
  mask0 = mask[0]
354
  newmask = np.where((mask0==2)|(mask0==0),1,0).astype('uint8')
355
-
356
- d["layers"][0][mask0==2] = (0,0,0,255)
357
- d["layers"][0][mask0==0] = (0,0,0,255)
358
  d["composite"] = cv2.cvtColor(rgb*newmask[:,:,np.newaxis], cv2.COLOR_RGB2RGBA)
359
- d["composite"][mask0==2] = (0,0,0,0)
360
- d["composite"][mask0==0] = (0,0,0,0)
361
 
362
  return gr.ImageEditor(value=d)
363
 
 
161
 
162
  cv2.imwrite(f"f{count}.jpg", raw_frame)
163
  orig_frames.append(f"f{count}.jpg")
 
164
 
165
  cv2.imwrite(f"f{count}_dmap.jpg", depth_color)
166
  depth_frames.append(f"f{count}_dmap.jpg")
167
+ masks.append(f"f{count}_dmap.jpg")
168
  count += 1
169
 
170
  final_vid = create_video(depth_frames, frame_rate, "depth")
 
241
  def rgb2gray(rgb):
242
  return np.dot(rgb[...,:3], [0.333, 0.333, 0.333])
243
 
244
+ def get_mesh(image, depth, blur_data, loadall):
 
245
  global locations
246
  global mesh
247
  if loadall == False:
 
249
  fnum = frame_selected
250
 
251
  #print(depth["composite"])
252
+ blur_img = blur_image(image[fnum][0], depth["composite"], blur_data)
253
+ gdepth = rgb2gray(depth["composite"])
 
254
 
255
  print('depth to gray - ok')
256
  points = pano_depth_to_world_points(gdepth)
 
297
  j = 0
298
  while j < 256:
299
  i = 255 - j
300
+ blur_lo = [i,i,i]
301
+ blur_hi = [i+1,i+1,i+1]
302
  blur_mask = cv2.inRange(depth, blur_lo, blur_hi)
303
 
304
  print(f'kernel size {int(blur_a[j])}')
 
350
  print(mask)
351
  mask0 = mask[0]
352
  newmask = np.where((mask0==2)|(mask0==0),1,0).astype('uint8')
 
 
 
353
  d["composite"] = cv2.cvtColor(rgb*newmask[:,:,np.newaxis], cv2.COLOR_RGB2RGBA)
 
 
354
 
355
  return gr.ImageEditor(value=d)
356