How to rotate camera x degrees when using pcl::visualization::PCLVisualizer

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

How to rotate camera x degrees when using pcl::visualization::PCLVisualizer

Mike6000
I have seen several people asking about how to rotate a camera around the
focal point when using pcl::visualization::PCLVisualizer in a QVTKWidget

I found that by using methods in the underlying VTK class that
pcl::visualization::PCLVisualizer uses, a rotation can easily be achieved.
However in pcl::visualization::PCLVisualizer there is no rotate() method.

Also the rens_ collection is declared private in
pcl::visualization::PCLVisualizer so this can not be directly accessed if
one attempted to inherit from pcl::visualization::PCLVisualizer and define
own new method for rotating.

Here is my solution:
// In the .h file

//(Remember these includes in your header file)
#include <vtkRenderWindow.h>
#include <vtkCamera.h>



//In the .cpp file

//Rotate:
// The getRendererCollection() returns a pointer to the underlying VTK
renderer collection
// Now we can call the VTK methods directly by
->GetFirstRenderer()->GetActiveCamera()->Azimuth(50);
// https://www.vtk.org/doc/nightly/html/classvtkCamera.html

viewer->getRendererCollection()->GetFirstRenderer()->GetActiveCamera()->Azimuth(50);

//Now we need to refresh:
ui->qvtkWidget->update ();





--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: How to rotate camera x degrees when using pcl::visualization::PCLVisualizer

Sérgio Agostinho
Feel free to suggest the addition to the pcl visualizer class and submit a pull request. From my side it definely feels useful so I would endorse its addition. 

Cheers


--

On Sunday, Feb 04, 2018 at 12:12 PM, Mike6000 <[hidden email]> wrote:
I have seen several people asking about how to rotate a camera around the
focal point when using pcl::visualization::PCLVisualizer in a QVTKWidget

I found that by using methods in the underlying VTK class that
pcl::visualization::PCLVisualizer uses, a rotation can easily be achieved.
However in pcl::visualization::PCLVisualizer there is no rotate() method.

Also the rens_ collection is declared private in
pcl::visualization::PCLVisualizer so this can not be directly accessed if
one attempted to inherit from pcl::visualization::PCLVisualizer and define
own new method for rotating.

Here is my solution:
// In the .h file

//(Remember these includes in your header file)
#include <vtkRenderWindow.h>
#include <vtkCamera.h>



//In the .cpp file

//Rotate:
// The getRendererCollection() returns a pointer to the underlying VTK
renderer collection
// Now we can call the VTK methods directly by
->GetFirstRenderer()->GetActiveCamera()->Azimuth(50);
// https://www.vtk.org/doc/nightly/html/classvtkCamera.html

viewer->getRendererCollection()->GetFirstRenderer()->GetActiveCamera()->Azimuth(50);

//Now we need to refresh:
ui->qvtkWidget->update ();





--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users

signature.asc (882 bytes) Download Attachment