Setting pose of Viz3d changes camera parameters

asked 2017-08-11 03:17:22 -0500

dustsigns gravatar image

updated 2017-08-11 04:04:17 -0500

When I call Viz3d::setViewerPose, the camera parameters of the Viz3d window change. In particular, it seems to zoom out significantly, even when the pose that I set is unchanged, i.e., when I set the one I can obtain with Viz3d::getViewerPose. The following code illustrates the issue:

#include <iostream>
#include <opencv2/viz.hpp>

using namespace std;
using namespace cv;
using namespace cv::viz;

int main()
{
  Viz3d visualization("Test");
  visualization.showWidget("Test object", WCone(1, 0.5, 100));
  /*const auto pose = visualization.getViewerPose();
  visualization.setViewerPose(pose);*/ //Uncomment this line and the one above it to see the described effect

  //cout << visualization.getCamera().getClip() << endl; //Debugging (uncomment this for an even stranger effect)

  visualization.spinOnce(1, true);
  while (!visualization.wasStopped())
    visualization.spinOnce(1, true);
  return 0;
}

When the two lines of code above are commented, the window looks like this: Code commented (no effect)

When the two lines of code above are uncommented, the window looks like this: Code uncommented (effect visible)

To pinpoint the issue, I added a line that outputs the changing camera parameter (which I found after some debugging). Printing this camera parameter gives different results, depending on whether setViewerPose is called, i.e., whether the two lines above it are commented. The strange thing, however, is, that just calling Viz3d::getCamera() (here, for printing) makes the "zoom" effect I described above disappear.

I don't know whether either of the two effects are identended and I don't know how to make them go away. In a more complex example, I tried to adjust the pose in the same way, but I could not do so because the camera kept "zooming" when I just read some parameters, making it impossible to set or change values in a meaningful way. Is this a bug, perhaps?

edit retag flag offensive close merge delete