This forum has been archived. All content is frozen. Please use KDE Discuss instead.

a problem in transfering code from matlab to c++ EIGEN

Tags: None
(comma "," separated)
hesamipp
Registered Member
Posts
2
Karma
0
hi all
can somebody help me?
how can i do this by c++ funcs or eigen?

it's my code and i'm trying to rewrite it in c++ Eigen:
MATLAB:
[x,y] = meshgrid([1:w]-w/2, [1:h]-h/2);
pos = reshape(cat(2, ones(h*w,1),x(:),y(:)) ...
* [p(1,:) p(2,:); p(3:4,:) p(5:6,:)], [h,w,n,2]); % it's a 64x32x600x2 mat
wimg = interp2(img, pos(:,:,:,1), pos(:,:,:,2)); % THE PROBLEM IS HERE

my c++ code:
MatrixXd X=(MatrixXd)RowVectorXd::LinSpaced(w,1-w/2,w-w/2).replicate(h,1);
MatrixXd Y=(MatrixXd)VectorXd::LinSpaced(h,1-h/2,h-h/2).replicate(1,w);

MatrixXd mul1=MatrixXd::Ones(X.rows()*X.cols(),3);
mul1.col(1)=Map<MatrixXd>(X.data(),X.rows()*X.cols(),1);
mul1.col(2)=Map<MatrixXd>(Y.data(),Y.rows()*Y.cols(),1);

MatrixXd mul2=MatrixXd::Zero(3,P.cols()*2);
mul2.row(0)<<P.row(0),P.row(1);
mul2.row(1)<<P.row(2),P.row(4);
mul2.row(2)<<P.row(3),P.row(5);

MatrixXd res=MatrixXd::Zero(X.rows()*X.cols(),P.cols()*2);
res=mul1*mul2;
......


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]