Visualisation changes camera resolution

Bug #687950 reported by Anne van Rossum
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Robot3D
New
Medium
Unassigned

Bug Description

In every sensor derived from CameraSensorBase the resolution is adjusted such that what it sees can be visualised in the right corner in the Robot3D window.

 dtCore::Camera *mCamera = dynamic_cast<dtCore::Camera*>(sensor.get());
 mCamera->GetOSGCamera()->setViewport(0, 0, (int) resolution.x(), (int) resolution.y());
 int screenWidth, screenHeight, winX, winY;
 GA->GetWindow()->GetPosition(winX, winY, screenWidth, screenHeight);
 float margin = 0.3;
 float width = (float) (0.25 * screenWidth - margin * 2);
 float height = width; //we want it square
 float xPos = (float) (0.75 * screenWidth + margin);
 float yPos = (float) (screenHeight - height - margin);
 mCamera->GetOSGCamera()->setViewport(xPos, yPos, width, height);

The problem is that the viewport will be set to the dimensions of the Robot3D window and not to the actual resolution parameters. When retrieving the images directly over YARP this is painfully obvious. When the user for example resizes the screen the camera even gets a different aspect ratio and the images send to the controller will get this different aspect ratio.

There are three things needed:
 (1) Only render one sensor at a time to the screen
 (2) Use a pbuffer for each sensor that preserves the proper resolution (and don't render it to the screen)
 (3) The rendering should be able to coarse grain e.g. a 32x32 image such that it fills up e.g. a 256x256 pixel space on a computer screen

Test case:

Use in ~/.robot3d/scene.xml the following robot and controller:

 <Robot name="robot_0" type="RobotKIT" x="-25" y="-30" z="1.2" h="-90" p="0" r="0" connected="0"/>

 <Controller name="cont0" type="YarpedRobot" robotToControl="robot_0"/>

And in the console:

    coproc yarpview /view; sleep 1; yarp connect /robot3d/robot_0/camera /view

Go in the yarp viewer to Image - Original aspect ratio, and you will see that effect in effect.

The only workaround now is not to display it on the screen. Even calling mCamera->GetOSGCamera()->setViewport(xPos, yPos, width, height); with the original resolution settings would namely rescale the images when the user resizes the window.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.