Controling the camera

I am trying to control the camera in OpenCASCADE. As
input I have the pose (position and rotation) of a
real camera and it\'s focal length. So, I\'m trying to
set up a camera in the exact same pose in OpenCASCADE
and with same focal length.

The following is a test I carried out to understand
how to control the camera.

By using a V3d_Viewer object, I set the ViewSize and
the projection method (V3d_PERSPECTIVE). I don\'t know
what SetDefaultViewProj() means, it seems to have no effect
on my images.

To create a V3d_View object, I call V3d_Viewer::CreateView();
This gives me access to set the camera eye and the view
point by calling the methods SetEye(x,y,z) and SetAt(x,y,z).
The focal length can be adjusted by calling SetDepth().

Now, the problem is in understanding the resulting images
I get. Let me explain by example:

SetEye(0,0,-100) // sets camera positions
SetAt(0,0,-99) // sets view direction

(using default values for other parameters not shown here, such
as the up-vector)

As I understand the model, this should give me an opening
angle of 90 degrees. So if I place a plane centered at (0,0,0)
with a height of 200, I should now be able to see exactly that
plane in the vertical direction of the image. But I see a bit more
than the plane. If I call SetDepth(1.5) I see exactly the
height of the plane. This doesn\'t make sence to me.

If I try to scale this by setting ViewSize to 8, I then assume
that the SetDepth() call should be scaled linearly according to
the change in ViewSize, so by using the 1.5 scale factor I guess
I should call SetDepth(4*1.5). But it turns out that I should
call it with 6.3 instead of 6 in order to see exactly
the plane.

Is there something about the view-model I need to know?

Any help appreciated.

Thorsten H's picture


sorry for answering after *that* long time ;)

But.. did you solve your Problem? I think I have a very similar one:

Thank you

Laszlo Kudela's picture

Hello all,

have you found a solution to you question?

I am trying to do similar things: I have a cylinder and create a view with parameters such that the image of the cylinder on the view should be exactly as wide as the size of the view. However, it is slightly smaller, and I can't figure out why...

It would be nice if some people from the developers could give us a hint there. (BTW, I know that in 6.8.0 the view manipulation is going to change, but I would be still interested how it works in the pre 6.8.0 versions)

Laszlo Kudela's picture

Okay, I might have figured it out.

When a new view is created, the default size of the window hosting the view (at least in my case) is 960*480, so the ratio is 2:1. Then I set the new view parameters and apply them, but I also resize the window to the size 1024*768, therefore the ratio changes to 4:3. Now, because the window changes size, I guess the view settings are getting kind of "messed up" during the redrawing procedure. I am no Computer Graphics expert, but I think the change in aspect ratio could cause the unexpected results.