PCLVisualizer - how to move camera 30 degrees along a circle without a mouse?

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

PCLVisualizer - how to move camera 30 degrees along a circle without a mouse?

Mike6000
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer - how to move camera 30 degrees along a circle without a mouse?

Richard Frank
There maybe another way but the easiest way I can see is to subclass pclvisualizer and add the following method


void pcl::visualization::PCLVisualizer::setCameraAzimuth (double azimuthDegrees , int viewport)

{

rens_->InitTraversal ();

vtkRenderer* renderer = NULL;

int i = 0;

while ((renderer = rens_->GetNextItem ()) != NULL)

{

// Modify all renderer's cameras

if (viewport == 0 || viewport == i)

{

vtkSmartPointer<vtkCamera> cam = renderer->GetActiveCamera ();

cam->SetAzimuth (azimuthDegrees):

}

++i;

}


The vtkCamera Azimuth is the rotation horizontally about the focal point


For vertical you would set Elevation.




Rick Frank
Dominion Software, Inc.
825 Beacon Street
Newton, MA 02459
Medical, Scientific, and Industrial Software

On Jan 27, 2018, at 5:04 AM, Mike6000 <[hidden email]> wrote:

I use PCLVisualizer in qt with qvtkwidget for visualizing a pointcloud.

Instead of using the mouse to click and rotate the camera, I would like to
be able to programmatically move the camera l degrees to the left, r degrees
to the right, u degrees up, d degrees down.

I have used setCameraPosition () to move the viewer like this:
viewer->setCameraPosition(73,-9242,-800,-21,-226,2703,0,0,1);
However, this is in a cartesian coordinate system.

I would like to give angles in degrees (or radians) instead. I imagine that
there would be possible to use some elegant matrix operation instead of
having to calculate this by moving along a circle etc.

Anyone that can help/ suggest how to move the camera specifying angles
(polar coordinate system)? Some example code would be great as well!



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

Re: PCLVisualizer - how to move camera 30 degrees along a circle without a mouse?

Mike6000
Hi @Richard Frank would it be possible for you to provide a more complete
example with a .h file, cpp file that would compile?  



--
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: PCLVisualizer - how to move camera 30 degrees along a circle without a mouse?

Sérgio Agostinho
I'm gonna assume your request comes from inexperience with C++ and its object oriented functionalities and not from pure laziness. 

http://www.cplusplus.com/doc/tutorial/inheritance/

Read the "inheritance between classes" and "what is inherited from the base class" sections. 

"[…] Teach a man how to fish..."

Cheers

--

On Saturday, Feb 03, 2018 at 12:19 PM, Mike6000 <[hidden email]> wrote:
Hi @Richard Frank would it be possible for you to provide a more complete
example with a .h file, cpp file that would compile?



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

Re: PCLVisualizer - how to move camera 30 degrees along a circle without a mouse?

Mike6000
This post was updated on .
Hi @Sérgio Agostinho

It looks like rens_ is declared private in the PCLVisualizer class?

https://github.com/PointCloudLibrary/pcl/blob/master/visualization/include/pcl/visualization/pcl_visualizer.h



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

Re: PCLVisualizer - how to move camera 30 degrees along a circle without a mouse?

Mike6000
This post was updated on .
In reply to this post by Richard Frank
Hi again. The _rens pointer apears to be private

However by inspecting the header file of pcl_visualizer it appears that
there are some public members that return pointers to the underlying Render
Window, Renderer Collection, CloudActorMap


        /** \brief Return a pointer to the underlying VTK Render Window used. */
        vtkSmartPointer<vtkRenderWindow>
        getRenderWindow ()
        {
          return (win_);
        }
       
        /** \brief Return a pointer to the underlying VTK Renderer Collection. */
        vtkSmartPointer<vtkRendererCollection>
        getRendererCollection ()
        {
          return (rens_);
        }
       
        /** \brief Return a pointer to the CloudActorMap this visualizer uses. */
        CloudActorMapPtr
        getCloudActorMap ()
        {
          return (cloud_actor_map_);
        }
       
        /** \brief Return a pointer to the ShapeActorMap this visualizer uses. */
        ShapeActorMapPtr
        getShapeActorMap ()
        {
          return (shape_actor_map_);
         }

This is the header file I inspected:
https://github.com/PointCloudLibrary/pcl/blob/master/visualization/include/pcl/visualization/pcl_visualizer.h

Question:
Would it be possible to help me get further by providing an example that compiles and uses these public methods?



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

Re: PCLVisualizer - how to move camera 30 degrees along a circle without a mouse?

Richard Frank
In VTK, off the top of my head, you should be able to chain together pointers to the active camera

vtkCamera * activeCamera = renderWindow->GetRenderers()->GetFirstRenderer()->GetActiveCamera();

activeCamera->SetAzimuth(degrees);
renderWindow->Render();


Rick Frank
Dominion Software, Inc.
825 Beacon Street
Newton, MA 02459
Medical, Scientific, and Industrial Software

> On Feb 3, 2018, at 7:46 AM, Mike6000 <[hidden email]> wrote:
>
> Hi again. The _rens apears to be private
>
> However by inspecting the header file of pcl_visualizer it appears that
> there are some public members that return pointers to the underlying Render
> Window, Renderer Collection, CloudActorMap
>
>
> /** \brief Return a pointer to the underlying VTK Render Window used. */
>        vtkSmartPointer<vtkRenderWindow>
>        getRenderWindow ()
>        {
>          return (win_);
>        }
>
>        /** \brief Return a pointer to the underlying VTK Renderer
> Collection. */
>        vtkSmartPointer<vtkRendererCollection>
>        getRendererCollection ()
>        {
>          return (rens_);
>        }
>
>        /** \brief Return a pointer to the CloudActorMap this visualizer
> uses. */
>        CloudActorMapPtr
>        getCloudActorMap ()
>        {
>          return (cloud_actor_map_);
>        }
>
>        /** \brief Return a pointer to the ShapeActorMap this visualizer
> uses. */
>        ShapeActorMapPtr
>        getShapeActorMap ()
>        {
>          return (shape_actor_map_);
>         }
>
>
> https://github.com/PointCloudLibrary/pcl/blob/master/visualization/include/pcl/visualization/pcl_visualizer.h
>
> Would it be possible to help me get further by providing an example that
> compiles uses these public methods?
>
>
>
> --
> 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