|
![](/i/fill.gif) |
Hello TinCanMan,
I think I figure out my problem, but can you explain your calculations in
detail? I want to learn the way you reasoned the result.
This is what I was doing:
1)Transform the point from world coordinates to camera coordinates:
X Y Z C1 C2 C3
<1, 0, 0> --> <1, 0, 100>
2)Project the point using the following formula (and I think this is where
my error is)
u = f*C1/(f-C3)
v = f*C2/(f-C3)
(this is the issue of where is the image plane with respect to the image
coordinate system)
3)after I calculate u, v
u = -0.333333333mm
v = 0mm
4)I divide u by resolution_x and v by resolution_y to get the number of
pixels:
u = -33.33pxl
v = 0 pxl
5)Then express u,v in terms of the image plane coordinate system
u = -33.33 + 256 = 222.6666667
v = 0 + 240 = 240
But, if I use the following formula for the perspective projection in step
2:
u = -fC1/C3
v = -fC2/C3
Then I get:
u = -0.25mm
v = 0mm
after dividing by the resolution and adding the offset
u = 231
v = 240
Why do you substract one here?
>512/2-25-1 = 230
Thanks for your help!!
Alexis
>As far as I calculate, for your scene, <1,0,0> should be at <230,240>
>
>dx = 5.12
>1/2dx = 2.56
>@4x distance (100=4x25):
>1/2dx=10.24
>pix res = 2(10.24)/512 = 0.04 /pix
>point <1,0,0> projected = 1/0.04 = 25 pix
>512/2-25-1 = 230
>
TinCanMan wrote:
>> I'm trying to use POV Ray to simulate an image capture from a real camera.
>> For example, if my camera has a resolution of 512x480 pixels. Where the
>> horizonal pixel resolution is 0.01mm/pixel and the vertical pixel
>> resolution is 0.013mm/pixel. The focal length of the camera is 25mm. The
>> position of the camera is specified using the right hand rule with
>> counterclockwise rotations as positive rotations.
>>
>> My problem is that when I render the image, the projection of the object
>is
>> not where I expected them to be.
>>
>> Below is the code that I made to defined the camera. All I want to know
>is
>> if this way of defining the camera makes sense.
>>
>> #declare resolution_x = 0.010000;
>> #declare resolution_y = 0.013000;
>> #declare size_width = 512;
>> #declare size_height = 480;
>> #declare focal_length = 25.079910;
>> #declare aperture_value = 25.000000;
>> #declare fov_angle = 11.6934;
>>
>> #declare camera_position = <0, 100, 0>;
>> #declare viewing_direction = <0, -1, 0>;
>>
>> camera {
>> location camera_position
>> right <-size_width*resolution_x,0,0>
>> up <0,-(size_height*resolution_y),0.0>
>> angle fov_angle
>> look_at viewing_direction*20
>>
>>
>> }
>
>I'm not sure what you are doing wrong exactly, but perhaps you are
>misinterpreting what's going on
>First off, 'look_at' is the point the camera should be looking at rather
>than viewing direction as you are calling it, maybe just bad terminology on
>your part.
>
>You camera declaration is fine (I would have POV calculate fov_angle though,
>'#declare fov_angle =
>degrees(2*atan2(size_width*resolution_x/2,aperture_value))' )
>>-tgq
>
Post a reply to this message
|
![](/i/fill.gif) |