[vtkusers] VTK&OpenCV

David Gobbi david.gobbi at gmail.com
Mon Aug 8 18:25:10 EDT 2011


I'm not 100% sure what you are looking for, but I'm guessing that you
want to set the camera's view matrix directly.  Though I don't know
why SetViewTransformMatrix is not working for you, here is the way
that I would do it:

Any 3x3 camera matrix (if it is an orthogonal matrix) can be created
by setting the Position, FocalPoint, and ViewUp of the camera:

1) First, choose the camera position "p" to be whatever you need.

2) Extract the 3rd row of your matrix into a vector (call it vz).
    Set the camera focal point f to:
  f = p - d*vz (where d is an arbitrary positive distance)

3) Extract the 2nd row of your matrix into a vector (call it vy).
    Set the camera ViewUp to vy.

After taking the above steps, the 3x3 portion of the view transform
matrix will be the same as your original 3x3 matrix.  For more details
on the computation, look at the cxx code for:
vtkPerspectiveTransform::SetupCamera().

 - David

On Sat, Aug 6, 2011 at 3:15 PM, Elvis Chen <elvis.chen at gmail.com> wrote:
> I posted the exact question a few weeks back but did not get any reply.  I
> would also appreciate an answer to this.
>
> Thanks
>
> On 2011-08-06 1:22 PM, "tenshi8x" <neohack87 at yahoo.it> wrote:
>>
>> ood evening, I surfed the Internet for a long time without finding a
>> solution.
>> I have a 3x3 intrinsic parameter matrix obtained through calibration in
>> OpenCV; matrix values are all in pixel.
>> I need to set a vtkCamera with those intrinsic parameters, but I couldn't
>> find the right way to do it, even after trying with SetUserViewTransform
>> or
>> similar.
>> I'm using OpenGL as graphics library in VTK, and if possible I'd like to
>> change OpenGL camera coordinate system with another one rotated by 180°
>> around y-axis, i.e. camera z-axis must point outward view plane toward the
>> object to visualize.
>>
>> I tried to follow these instructions:
>>
>> http://opencv.willowgarage.com/wiki/Posit
>>
>> and even these:
>>
>> http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=211014
>>
>> but none seem to work.
>>
>> Every help will be appreciated.
>>
>> Have a nice day.
>>
>> --
>> View this message in context:
>> http://vtk.1045678.n5.nabble.com/VTK-OpenCV-tp4673083p4673083.html
>> Sent from the VTK - Users mailing list archive at Nabble.com.
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list