**The optimization model is like:**

minimize ∑||Hpi - pi’|| (sum of projective error)

subject to H = ∑θiHi (Hi is one estimation of H, all the Hi are known)

∑θi=1

0<= θi<=1

**And the corresponding code I write is:**

cvx_begin

variable Homog(3,3);

variable distnc;

variable distsum(1,col);

variable a(counter,1);

minimize distnc;

subject to

suma(a) == 1;

for i = 1:counter

0<=a(i);

a(i)<=1;

end

Homog(:,1)=sumVec(a,H_array,1);

Homog(:,2)=sumVec(a,H_array,2);

Homog(:,3)=sumVec(a,H_array,3);

distnc == sumdist(Homo,im1Pts,im2Pts);

cvx_end

**Function sumVec:**

function [summary] = sumVec(a,H_array,c)

[row,col] = size(a);

summary = zeros(3,1);

for i =1:row

cur_H = H_array{i}

summary = summary + a(i,:)% .* cur_H(:,c);

end

end

**Function sumdist:**

function [summary] = sumdist(Homo,im1Pts,im2Pts)

load(‘case1featurepoints.mat’, ‘data’);

corres = data{im1Pts,im2Pts};

[row,col] = size(corres);

summary = 0;

for i=1:col

summary = summary + disc(Homo * [corres(1,i);corres(2,i);1],[corres(4,i);corres(5,i);1]);

end

end

After a really long period of time, the matlab told me that this model is infeasible, but I don’t think it is infeasible. Meanwhile, every time I pause the running process trying to see where it is stuck at that takes so much time to run, I found it is always at the function cvx_id. I have no idea of how to solve this problem

You either need to declare `Homog`

as an expression per http://cvxr.com/cvx/doc/basics.html#assignment-and-expression-holders or if declared as a variable, use equality constraints `==`

rather than `=`

. Perhaps there’s more wrong with your program than that, but at least fix that.

If you get that fixed and still are getting infeeasible, try the suggestions in https://yalmip.github.io/debugginginfeasible/ , which also apply to CVX, except for item 1.