vtkProjectedTexture example

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

vtkProjectedTexture example

Affolter Martin

Hi vtk-users

 

I’m looking for a working example on how to use the vtkProjectedTexture class. I’ve been experimenting with it but I don’t get the expected results. Would anyone using this class be so kind to send me a short example, preferably in c++, but other languages will do as well.

 

Thank you!

Martin Affolter
MSc FHO in Engineering
Wissenschaftlicher Mitarbeiter
___________________________________________
NTB Interstaatliche Hochschule für Technik Buchs
Institut für Ingenieurinformatik
Schönauweg 4
CH-9013 St. Gallen

Tel:  +41 81 755 32 49

Web: http://www.ntb.ch

 


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: vtkProjectedTexture example

audialc
Hi,
I'm very interested too. I'm looking for an example that show me how to use this class, but I didn't find it. Have you ever used this class? Can you post here an example? Every language is ok. Thank you
Reply | Threaded
Open this post in threaded view
|

Re: vtkProjectedTexture example

Kilgus, Thomas
Hi there,

I used this class to project an RGB texture of a camera onto a CT surface. I figured it was working very well but not very straight forward to use. The documentation was insufficient for me (and two students), so we just did the math and solved everything more or by trial and error. The class produces very nice texture coordinates to map an image onto a polydata. Unfortunately, this was almost two years ago and I fear I don't remember details.

Here is my code anyway (I removed parts from our own toolkit and added comments):

    vtkSmartPointer<vtkProjectedTexture> projectedTexture = vtkSmartPointer<vtkProjectedTexture>::New();
    mitk::Surface* surfaceToComputeTextureOn = dynamic_cast<mitk::Surface*>(surfaceNodeToComputeTexture->GetData());
    mitk::Surface* surfaceToPutTextureOn = dynamic_cast<mitk::Surface*>(surfaceNodeToPutTextureOn->GetData());
    //Settings for vtkProjectedTexture
    projectedTexture->SetPosition(0,0,0);
    projectedTexture->SetFocalPoint(0,0,1);
    projectedTexture->SetUp(0,1,0);

    //RGB camera intrinsics. Width and Height are the resolution of the camera. See intrinsic camera calibration in literature
    projectedTexture->SetAspectRatio( -d->m_width, d->m_height, d->m_CameraIntrinsics->GetFocalLengthX() );
    float dx = ( (d->m_width/2.0f) - d->m_CameraIntrinsics->GetPrincipalPointX() ) / -d->m_width;
    float dy = ( (d->m_height/2.0f) - d->m_CameraIntrinsics->GetPrincipalPointY() ) / -d->m_height;

    projectedTexture->SetSRange(dx, 1+dx);
    projectedTexture->SetTRange(dy, 1+dy);
    projectedTexture->SetInputData( polyDataToComputeTextureOn ); //this can be the same as the one to project on
    projectedTexture->Update();
    //Map Texture on Surface
    polyDataToPutTextureOn->GetPointData()->SetTCoords(projectedTexture->GetOutput()->GetPointData()->GetTCoords()); //can be a different surface or the same

     //here is what you need in addition:
     vtkSmartPointer<vtkTexture> vtkTxture = vtkSmartPointer<vtkTexture>::New();
     vtkTxture->SetInputData( someVtkImageData ); //in my case an RGB camera image
     actor->SetTexture(vtkTxture); //your polydata actor


Bottom line the class works really well and I failed to submit an additional example or documentation to improve the usability. I hope this helps!

Regards,


Thomas Kilgus
German Cancer Research Center (DKFZ)
Div. Medical and Biological Informatics
Junior group: Computer-assisted Interventions (E131)
Im Neuenheimer Feld 280
69120 Heidelberg, Germany
Phone: +49(0) 6221-42-3545





-----Ursprüngliche Nachricht-----
Von: vtkusers [mailto:[hidden email]] Im Auftrag von audialc
Gesendet: Montag, 13. Juli 2015 20:13
An: [hidden email]
Betreff: Re: [vtkusers] vtkProjectedTexture example

Hi,
I'm very interested too. I'm looking for an example that show me how to use this class, but I didn't find it. Have you ever used this class? Can you post here an example? Every language is ok. Thank you



--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkProjectedTexture-example-tp5723907p5732867.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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkProjectedTexture example

audialc
Ok, thank you.
I'll try your code! Thank you so much!
Reply | Threaded
Open this post in threaded view
|

Re: vtkProjectedTexture example

vinmean
In reply to this post by Kilgus, Thomas
Hi, I am stuck with my texture projection application. The texture that I
project gets applied to the entire poly data. Do you know how to restrict
the projection within the region of focus?



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers