dmytromishkin commited on
Commit
9e478c8
·
verified ·
1 Parent(s): 98706c7

Update handcrafted_solution.py

Browse files
Files changed (1) hide show
  1. handcrafted_solution.py +3 -5
handcrafted_solution.py CHANGED
@@ -373,13 +373,14 @@ def get_sparse_depth(colmap_rec, img_id, K, R, t, depth):
373
  xyz = []
374
  rgb = []
375
  found = False
376
- print (img_id)
377
  for img_id_c, col_img in colmap_rec.images.items():
378
  print (col_img.name)
379
  if col_img.name == img_id:
380
  found = True
381
  break
382
  if not found:
 
383
  return np.zeros((H, W), dtype=np.float32), False
384
  mat4x4 = np.eye(4)
385
  mat4x4[:3 ] = col_img.cam_from_world.matrix()
@@ -435,10 +436,7 @@ def fit_scale_robust_median(depth, sparse_depth):
435
  k, b = params
436
  return np.median(np.abs(yvals - (k*xvals)))
437
 
438
- # 3. Get an initial guess from a standard least-squares fit
439
- # (this helps the optimizer start in a reasonable region)
440
- k_init, b_init = np.polyfit(X, Y, deg=1)
441
-
442
  # 4. Optimize using a derivative-free method (Nelder-Mead)
443
  res = minimize(
444
  fun=median_abs_resid,
 
373
  xyz = []
374
  rgb = []
375
  found = False
376
+ #print (img_id)
377
  for img_id_c, col_img in colmap_rec.images.items():
378
  print (col_img.name)
379
  if col_img.name == img_id:
380
  found = True
381
  break
382
  if not found:
383
+ print (f"{img_id} not found, returning empty depth")
384
  return np.zeros((H, W), dtype=np.float32), False
385
  mat4x4 = np.eye(4)
386
  mat4x4[:3 ] = col_img.cam_from_world.matrix()
 
436
  k, b = params
437
  return np.median(np.abs(yvals - (k*xvals)))
438
 
439
+ k_init, b_init = 1.0, 0.0
 
 
 
440
  # 4. Optimize using a derivative-free method (Nelder-Mead)
441
  res = minimize(
442
  fun=median_abs_resid,