Exemplo n.º 1
0
def form_poisson_equation_test_both_y():
    height = 2
    width = 2
    alpha = np.ones((height, width))
    depth = np.ones((height, width))
    depth[0, :] = 2
    normals = np.zeros((height, width, 3))
    normals[:, :, 1:] = 1 / np.sqrt(2)
    depth_weight = 1
    A, b = form_poisson_equation(height, width, alpha, normals, depth_weight,
                                 depth)
    solution = lsqr(A, b)
    assert np.allclose(solution[0], np.array([2, 2, 1, 1]))
Exemplo n.º 2
0
def form_poisson_equation_test_depth_x():
    height = 2
    width = 2
    alpha = np.ones((height, width))
    depth = np.ones((height, width))
    depth[:, 1] = 2
    normals = np.zeros((height, width, 3))
    normals[:, :, 2] = 1
    depth_weight = 1
    A, b = form_poisson_equation(height, width, alpha, None, depth_weight,
                                 depth)
    solution = lsqr(A, b)
    assert np.allclose(solution[0], np.array([1, 2, 1, 2]))
Exemplo n.º 3
0
    assert max(heights) - height <= data.mesh_downscale_factor
else:
    assert max(widths) - width <= data.stereo_downscale_factor
    assert max(heights) - height <= data.stereo_downscale_factor

if depth is not None:
    depth = depth[:height, :width]
if alpha is not None:
    alpha = alpha[:height, :width]
if normals is not None:
    normals = normals[:height, :width, :]

print('Initialized data in {0} seconds'.format(toc - tic))

tic = time.time()
A, b = form_poisson_equation(height, width, alpha, normals, depth_weight,
                             depth)
toc = time.time()

print('Set up linear system in {0} seconds'.format(toc - tic))

tic = time.time()
print('Solving...')
solution = lsqr(A, b)
x = solution[0]
depth = x.reshape(height, width)
toc = time.time()
print('Solve complete in {0} seconds'.format(toc - tic))

print('Save mesh to {0}'.format(data.mesh_ply.format(mode)))
save_mesh(K_right, width, height, albedo, normals, depth, alpha,
          data.mesh_ply.format(mode))
Exemplo n.º 4
0
height = min(heights)

assert max(widths) - width <= data.stereo_downscale_factor
assert max(heights) - height <= data.stereo_downscale_factor

if depth is not None:
    depth = depth[:height, :width]
if alpha is not None:
    alpha = alpha[:height, :width]
if normals is not None:
    normals = normals[:height, :width, :]

print 'Initialized data in {0} seconds'.format(toc - tic)

tic = time.time()
A, b = form_poisson_equation(
    height, width, alpha, normals, depth_weight, depth)
toc = time.time()

print 'Set up linear system in {0} seconds'.format(toc - tic)

tic = time.time()
print 'Solving...'
solution = lsqr(A, b)
x = solution[0]
depth = x.reshape(height, width)
toc = time.time()
print 'Solve complete in {0} seconds'.format(toc - tic)

print 'Save mesh to {0}'.format(data.mesh_ply.format(mode))
save_mesh(K_right, width, height, albedo, normals,
          depth, alpha, data.mesh_ply.format(mode))