ajayramesh
ajayramesh

Reputation: 3804

Solving Least squares in numpy/scipy?

Lucas Kanade Implementation

I am trying to implement the Lucas Kanade algorithm for some project without using any library. I am following this guide from opencv.

I am stuck in translating least square equation which is below. least square

I am not sure below code is correct method to compute equation?

My Code

inv(X)*np.matrix(T)

where

X = X

T = T

If yes please acknowledge me. If not please provide show how to do it using numpy or scipy.

I am not sure how to validate the correctness of least square. Otherwise I would not have asked this question

Upvotes: 2

Views: 1117

Answers (1)

Ritesh
Ritesh

Reputation: 56

I am assuming you have created the two matrices (the first matrix X and the second matrix T) on the right hand side of the equation. Once you have the two matrices, you can do something like this

import numpy as np

uvVector = np.dot(np.linalg.inv(X), T)

np.dot does matrix multiplication.

Upvotes: 3

Related Questions