Discussion:
[vtkusers] vtkProjectedTexture example
audialc
2015-07-13 18:13:11 UTC
Permalink
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
Kilgus, Thomas
2015-07-14 09:31:40 UTC
Permalink
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:vtkusers-***@vtk.org] Im Auftrag von audialc
Gesendet: Montag, 13. Juli 2015 20:13
An: ***@vtk.org
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
audialc
2015-07-14 14:13:53 UTC
Permalink
Ok, thank you.
I'll try your code! Thank you so much!



--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkProjectedTexture-example-tp5723907p5732893.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
vinmean
2018-11-20 01:22:35 UTC
Permalink
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

Loading...