如何在Python中求解线性方程组?

时间:2019-04-17 13:00:05

标签: numpy computer-vision linear-equation

上下文:我正在研究projection equations

我有 N 个投影矩阵(每个2D点),形状为(3, 4)

例如,假设P = [p_i] for 1 <= i <= n

import numpy as np
# p_i were initialised with dummy values
p1 = np.array([[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], dtype=float)
...
pn = np.array([[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], dtype=float)

然后我在摄像机框架中得到了 N 个2D点坐标(形状为(3, 1))。

# coords_i were initialised with dummy values for x, y and (z was set to 1 by design) as well
coords_1 = np.array([10, 20, 1], dtype=float)
...
coords_n = np.array([30, 40, 1], dtype=float)

例如,假设C = [coords_i] for 1 <= i <= n

任务是找到这样的X,它是单个(4, 1)向量,以便与p_i * X = coords_i相乘。

如何将这个系统传递给numpy的linalg solver

P * X = C

所以最终形状为P.shape = (3 * N, 4), X.shape = (4, 1), C.shape = (3 * N, 1)

0 个答案:

没有答案