PCL viewer is blank until interacted with/Camera position bug
I'm currently trying to automate rendering a point cloud, setting the camera position, and taking a screenshot.
Using the code from http://pointclouds.org/documentation/tutorials/pcl_visualizer.php#pcl-visualizer, I created a viewer object, then called the set camera position method. However, when the viewer window actually appears, it remains black until I interact with it in some way (dragging the mouse around). Therefore, when I remove the while loop that keeps the window active and then call saveScreenshot, the screenshot is all black with just the FPS in the bottom left corner. Is there any way to make the window render without the user having to interact with it?
Additionally, the camera position and angle that I'm setting never seems to be consistent between runs. I'm using the same point cloud each time, but whenever I set the camera position the displayed point cloud always seems to have shifted a bit so that I need to manually readjust the camera again before I take the screenshot. Any advice? Relevant code below: