freealise commited on
Commit
63d7636
1 Parent(s): 6945437

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -298,7 +298,7 @@ def get_mesh(image, depth, blur_data, loadall):
298
  clrs = [[128,128,128,0]]
299
 
300
  #for i in range(0,1): #(0,4)
301
- clrs = np.concatenate((clrs, colors), axis=0)
302
  #i = i+1
303
 
304
  #triangles = create_triangles(rgba.shape[0], rgba.shape[1])
@@ -438,25 +438,26 @@ def optimize(v, d):
438
  # convert to np.float32
439
  f = np.float32(frame.reshape((-1,3)))
440
  # define criteria, number of clusters(K) and apply kmeans()
441
- criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10, 1.0)
442
- ret,label,center=cv2.kmeans(f,l,None,criteria,10,cv2.KMEANS_RANDOM_CENTERS)
443
  # Now convert back into uint8, and make original image
444
  center = np.uint8(center)
445
  res = center[label.flatten()]
446
  frame = res.reshape((frame.shape))
447
 
448
- dcolor.append(bincount(frame))
 
 
449
  print(dcolor[k])
450
 
451
- mask = cv2.convertScaleAbs(cv2.Laplacian(cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY), ddepth, ksize=kernel_size))
452
- mask[mask>0] = 255
453
- frame[mask==0] = (0, 0, 0)
454
  cv2.imwrite(frames[k], frame)
455
 
456
- depth = cv2.imread(depths[k]).astype(np.uint8)
457
- depth[mask==0] = (255,255,255)
458
- #mask = cv2.inRange(frame, np.array([dcolor[k][0]-8, dcolor[k][1]-8, dcolor[k][2]-8]), np.array([dcolor[k][0]+8, dcolor[k][1]+8, dcolor[k][2]+8]))
459
- #depth[mask>0] = (255,255,255)
460
  depth[depth.shape[0]-1:depth.shape[0], 0:depth.shape[1]] = (160, 160, 160)
461
  depth[0:1, 0:depth.shape[1]] = (0, 0, 0)
462
  cv2.imwrite(depths[k], depth)
 
298
  clrs = [[128,128,128,0]]
299
 
300
  #for i in range(0,1): #(0,4)
301
+ clrs = np.concatenate((clrs, colors), axis=0)
302
  #i = i+1
303
 
304
  #triangles = create_triangles(rgba.shape[0], rgba.shape[1])
 
438
  # convert to np.float32
439
  f = np.float32(frame.reshape((-1,3)))
440
  # define criteria, number of clusters(K) and apply kmeans()
441
+ criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 4, 1.0)
442
+ ret,label,center=cv2.kmeans(f,l,None,criteria,4,cv2.KMEANS_RANDOM_CENTERS)
443
  # Now convert back into uint8, and make original image
444
  center = np.uint8(center)
445
  res = center[label.flatten()]
446
  frame = res.reshape((frame.shape))
447
 
448
+ depth = cv2.imread(depths[k]).astype(np.uint8)
449
+ sky = depth[(depth==0).all()]
450
+ dcolor.append(bincount(frame[sky>0]))
451
  print(dcolor[k])
452
 
453
+ #mask = cv2.convertScaleAbs(cv2.Laplacian(cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY), ddepth, ksize=kernel_size))
454
+ #mask[mask>0] = 255
455
+ #frame[mask==0] = (0, 0, 0)
456
  cv2.imwrite(frames[k], frame)
457
 
458
+ #depth[mask==0] = (255,255,255)
459
+ mask = cv2.inRange(frame, np.array([dcolor[k][0]-8, dcolor[k][1]-8, dcolor[k][2]-8]), np.array([dcolor[k][0]+8, dcolor[k][1]+8, dcolor[k][2]+8]))
460
+ depth[mask>0] = (255,255,255)
 
461
  depth[depth.shape[0]-1:depth.shape[0], 0:depth.shape[1]] = (160, 160, 160)
462
  depth[0:1, 0:depth.shape[1]] = (0, 0, 0)
463
  cv2.imwrite(depths[k], depth)