Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Real world coordinate from pixel coordinate?

I have the intrinsic and extrinsic parameter of my calibrated camera. Now I want to convert from pixel coordinate to the world coordinate. The camera is placed at height of 145 cm from the floor and it is looking on the floor. I write a simple code but it does not give the accurate result:

%%%%%setting some parameters a=0;b=0;c=1;d=0;

%%%Intrinsic Parameter %---- Focal length: fc = [320.269142010037630 ; 319.966530766203500]; f=mean(fc);

clc; %----- Principal point: cc = [182.596545116467270 ; 115.011524736116240];

%-- Skew coefficient: alpha_c = 0.000000000000000;

% Extrinsic parameters: % Translation vector: T= [ -113.538953; 593.803124; 1493.638755 ];

% Rotation vector:
omc_ext = [ 2.284699 0.021157 -0.004369 ];

% Rotation matrix:
R = [ 0.999852 0.016768 0.003834; 0.013878 -0.654724 -0.755741; -0.010162 0.755682 -0.654860 ];

%%%Projecttion center as it inv(R)==R';

Oc=R'*T;

xi=10; yi=120; %%% pixel coordinates

ximc=(xi-cc(1))/fc(1); yimc=(yi-cc(2))/fc(2); zimc=f;

Ow=R'*([ximc;yimc;zimc]-T); Ow

%%%% Finding intersection point between a line in 3D and a Plane

Owapp(1)=Oc(1)+ (((d-(aOc(1)+bOc(2)+cOc(3)))(Ow(1)-Oc(1)))/(a(Ow(1)-Oc(1))+b(Ow(2)-Oc(2))+c(Ow(3)-Oc(3)))); Owapp(2)=Oc(2)+ (((d-(aOc(1)+bOc(2)+cOc(3)))(Ow(2)-Oc(2)))/(a(Ow(1)-Oc(1))+b(Ow(2)-Oc(2))+c(Ow(3)-Oc(3)))); Owapp(3)=Oc(3)+ (((d-(aOc(1)+bOc(2)+cOc(3)))(Ow(3)-Oc(3)))/(a(Ow(1)-Oc(1))+b(Ow(2)-Oc(2))+c*(Ow(3)-Oc(3))));

% % % % Owapp(1)=Oc(1) - (((aOc(1)+bOc(2)+cOc(3)+d)(Ow(1)-Oc(1)))/((a(Ow(1)-Oc(1)))+ (b(Ow(2)-Oc(2)))+ (c(Ow(3)-Oc(3))))); % % % % Owapp(2)=Oc(2) - (((aOc(1)+bOc(2)+cOc(3)+d)(Ow(2)-Oc(2)))/((a(Ow(1)-Oc(1)))+ (b(Ow(2)-Oc(2)))+ (c(Ow(3)-Oc(3))))); % % % % Owapp(3)=Oc(3) - (((aOc(1)+bOc(2)+cOc(3)+d)(Ow(3)-Oc(3)))/((a(Ow(1)-Oc(1)))+ (b(Ow(2)-Oc(2)))+ (c*(Ow(3)-Oc(3)))));

Owapp