Pixel position is bigger than image dimension or negative using pinhole camera model
Mostra commenti meno recenti
Hi there
I am having a problem with a simple code that uses the pinhole camera model. The problem is when I am trying to locate the pixel position in the image plane of a certain point in the scene it gives me weird results such as negative value or a number byend the image dimension. here is my code where x,y and z are the coordinate of the point I am interested in camx,camy and camz are the coordinate of the camera in the scene all in mm.Image resolution has 1440* 960 pixels (width *height), focal length is 40 mm. rotation matrix is identity because the camera is facing the scene as shown in the image . From the coordination above, the point should be right infront of the camera (Y is the distance from the camera to the house, X is right in the middel of the front view of the hous and z is the height of the camera as shown in the image below) and as a result the pixels should be roughly in the middle of the image but the results is [w,h]= [2970.6, 636.2].
I think i am doing something wrong in the translation matrix but i cant know what is ,
any help please

x=1.067621626992524e+03;
y=-3.718505419300001e+03;
z=2848.17;
camx=-1871.14;
camy=-7763.71;
camz=2848.17;
F=40; % in millimetere
Pixelox=720;
Pixeloy=480;
Pixelx=0.025 ;
Pixely=0.025;
K=[F/Pixelx 0 0;0 F/Pixely 0;Pixelox Pixeloy 1];
R= [1 0 0;0 1 0;0 0 1];
t=[ x-camx y-camy z-camz];
P=[R;t]*K;
tem= [x y z 1]*P;
w=tem(1)/tem(3);
h=tem(2)/tem(3);
Risposta accettata
Più risposte (2)
Image Analyst
il 29 Dic 2018
0 voti
Not sure what you mean by "Y is the distance from the camera to the house, X is right in the middel of the front view of the hous and z is the height of the camera as shown in the image below" Isn't x and y the distances from the optic axis? If not, did you define a new frame of reference where the optic axis is not at (0, 0)? (This would complicate things.)
You say "x,y and z are the coordinate of the point I am interested in camx,camy and camz are the coordinate of the camera in the scene". Let's get this straight. Which set is in the scene (in front of the pinhole) and which set is in the "focal plane" which is where the image from the scene is landing?
Also you specify both of those so that pretty much nails everything else down.
You say "F=40; % in millimetere" but for a pinhole camera, there is no focal length. It's pinhole, so everything is in focus everywhere, regardless of how far behind the pinhole it is.
Also what's this talk about a rotation matrix? Since it's pinhole camera, why would there be any rotation? If the scene and focal plane were parallel, there would be no rotation matrix. Is your scene a plane and either your scene or focal plane not normal to the optic axis?
What are you trying to figure out exactly? h? w? R?
1 Commento
caesar
il 29 Dic 2018
Categorie
Scopri di più su MATLAB Support Package for USB Webcams in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!