| 517 | return mesh, info_on_pix, depth, image |
| 518 | |
| 519 | def fill_missing_node(mesh, info_on_pix, image, depth): |
| 520 | for x in range(mesh.graph['bord_up'], mesh.graph['bord_down']): |
| 521 | for y in range(mesh.graph['bord_left'], mesh.graph['bord_right']): |
| 522 | if info_on_pix.get((x, y)) is None: |
| 523 | print("fill missing node = ", x, y) |
| 524 | #import pdb; pdb.set_trace() |
| 525 | re_depth, re_count = 0, 0 |
| 526 | for ne in [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]: |
| 527 | if info_on_pix.get(ne) is not None: |
| 528 | re_depth += info_on_pix[ne][0]['depth'] |
| 529 | re_count += 1 |
| 530 | if re_count == 0: |
| 531 | re_depth = -abs(depth[x, y]) |
| 532 | else: |
| 533 | re_depth = re_depth / re_count |
| 534 | depth[x, y] = abs(re_depth) |
| 535 | info_on_pix[(x, y)] = [{'depth':re_depth, |
| 536 | 'color':image[x, y], |
| 537 | 'synthesis':False, |
| 538 | 'disp':1./re_depth}] |
| 539 | mesh.add_node((x, y, re_depth), color=image[x, y], |
| 540 | synthesis=False, |
| 541 | disp=1./re_depth, |
| 542 | cc_id=set()) |
| 543 | return mesh, info_on_pix, depth |
| 544 | |
| 545 | |
| 546 | |