POV-Ray : Newsgroups : povray.general : Re: how to model a camera using pov ray Server Time
17 Nov 2024 23:14:22 EST (-0500)
  Re: how to model a camera using pov ray (Message 1 to 3 of 3)  
From: TinCanMan
Subject: Re: how to model a camera using pov ray
Date: 6 Dec 2002 15:22:40
Message: <3df10710@news.povray.org>
> 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))' )

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

-tgq


Post a reply to this message

From: ahrivera
Subject: Re: how to model a camera using pov ray
Date: 6 Dec 2002 19:10:05
Message: <web.3df13c38545447bbe9a0f03e0@news.povray.org>
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

From: TinCanMan
Subject: Re: how to model a camera using pov ray
Date: 7 Dec 2002 15:59:14
Message: <3df26122$1@news.povray.org>
>
> Why do you substract one here?
> >512/2-25-1 = 230

The pixel coordinates start at zero, so essentially the pixel runs from 230
to 231

>
>
> 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

actually all this was a bit unecessary.
By similar triangles, at 4x the focal distance (camera = 100mm, focal =
25mm), pixel resolution should be 4x larger (width, height 4x larger over
same number of pixels)
i.e., horizontal pix resolution at 100mm = 0.01 x 4 = 0.04 mm/pix
point <1,0,0> is transposed 1mm to the left, 1mm/0.04 mm/pix = 25pix
half image resolution = 512/2 = 256pix
subtract 25: 256-25=231pix
this is at the right side of the pixel, subtract one more to get left side
231-1 = 230pix
this is because the pixel coordinates run from 0 to 511

-tgq


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.