File size: 854 Bytes
ab0a0fc
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import numpy as np, json, re
from PIL import Image
cfg = open('../src/config.js').read()
ex = {'desk-laptop': [((385,645),(808,483)),((838,282),(961,282))], 'bicycle-street': [((412,352),(419,812)),((208,588),(614,525))],
      'synthetic-room': [((208,606),(417,606)),((645,323),(645,570)),((591,447),(699,447))]}
for k, ms in ex.items():
    f = f'../public/examples/example-{k}.jpg'; w, h = Image.open(f).size
    P = np.load('/workspace/geometria3d-lab/_work/' + f.split('/')[-1] + '.points.npy'); H, W = P.shape[:2]
    def at(x, y):
        cx, cy = round(x * W / w - 0.5), round(y * H / h - 0.5)
        win = P[max(0,cy-1):cy+2, max(0,cx-1):cx+2].reshape(-1,3); return np.median(win, 0)
    for a, b in ms:
        A, B = at(*a), at(*b); print(k, a, b, round(float(np.linalg.norm(A-B)),3), 'zA', round(float(A[2]),2), 'zB', round(float(B[2]),2))