[vtkusers] Implementing my own camera class and wrapping it to Python

Skotheim , Oystein oystein.skotheim at tecnalia.com
Tue Mar 19 12:55:17 EDT 2013


Hello. I am trying to use VTK for Augmented Reality. I need to be able 
to manipulate the projection and modelview transform directly, and I 
could not find a convenient way to do it with vtkCamera or 
vtkOpenGLCamera (Is there any way to do it?).

For that reason, I have tried to implement a new camera class: 
vtkOpenCVCalibratedCamera, which basically is a copy of vtkOpenGLCamera 
but it contains functionality for setting the projection and model view 
matrices directly. I have gotten this to work in C++ now.

I would also like to be able to access this from Python. I tried to copy 
vtkOpenCVCalibratedCamera.{cxx,h} into the Rendering directory of the 
VTK source distribution, and then I appended vtkOpenCVCalibrated.cxx to 
the KitOpenGL_SRCS variable in the Rendering/CMakeLists.txt file. I am 
able to compile VTK including the Python wrapper and obtain a vtkpython 
file. However, when I try to import vtk I get the following error:

oystein at prtgb370:~/src/VTK-5.8.0/build/bin$ ./vtkpython
vtk version 5.8.0
Python 2.7.3 (default, Aug  1 2012, 05:27:35)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import vtk
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File 
"/home/oystein/src/VTK-5.8.0/build/Wrapping/Python/vtk/__init__.py", 
line 76, in <module>
     __helper.refine_import_err('hybrid', 'vtkHybridPython', exc)
   File 
"/home/oystein/src/VTK-5.8.0/build/Wrapping/Python/vtk/__helper.py", 
line 32, in refine_import_err
     raise LinkError, str(exc)
vtk.__helper.LinkError: 
/home/oystein/src/VTK-5.8.0/build/bin/libvtkRenderingPythonD.so.5.8: 
undefined symbol: 
_ZN25vtkOpenCVCalibratedCamera14UpdateViewportEP11vtkRenderer

Do you have any idea why this error is occurring? (My class contains an 
UpdateViewport method both in the header and the implementation file).

BTW. Is there any way I can add a Python interface to my new class 
without having to recompile the entire VTK? I tried to add a Python 
interface with SWIG, but I am unable e.g. to pass this 
vtkOpenCVCalibratedCamera (in vtk_extensions.pyd) to a vtkRenderer 
(contained in the main vtk Python wrapper). I guess this is not the way 
to do it, but where can I find information about how to wrap my class 
properly for Python?

Best regards,

-- 
Øystein Skotheim
Investigador Senior - Área de Negocio de Robótica
TECNALIA

-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkOpenCVCalibratedCamera.cxx
Type: text/x-c++src
Size: 6865 bytes
Desc: vtkOpenCVCalibratedCamera.cxx
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130319/bd694188/attachment.cxx>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkOpenCVCalibratedCamera.h
Type: text/x-chdr
Size: 1142 bytes
Desc: vtkOpenCVCalibratedCamera.h
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130319/bd694188/attachment.h>


More information about the vtkusers mailing list