Camera pose in ECEF, camera matrix <--> View matrix, projection matrix #2369
-
Hello everyone, IntroI'm trying to use OsgEarth to generate images taken from specific points of view. Then, I'm also interested in recovering the geographic coordinates from screen coordinates, but that's another thing (see thread #2366) What I'm struggling withThe point of view I get in OsgEarth is slightly different from what I expect. This tells me that there's an error in the conversion from homogenous transform to view matrix. CodeHere's a snippet performing view matrix assignment. Do you see any flaws? Init // ========= Init =========
osgEarth::initialize();
osg::ArgumentParser arguments(&argc,argv);
if ( arguments.read("--help") )
return usage(argv[0]);
osgViewer::Viewer viewer(arguments);
// This is normally called by Viewer::run but we are running our frame loop manually so we need to call it here.
// viewer.setReleaseContextAtEndOfFrameHint(false);
// Tell the database pager to not modify the unref settings
viewer.getDatabasePager()->setUnrefImageDataAfterApplyPolicy( true, false );
// thread-safe initialization of the OSG wrapper manager. Calling this here
// prevents the "unsupported wrapper" messages from OSG
osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper("osg::Image");
// disable the small-feature culling
viewer.getCamera()->setSmallFeatureCullingPixelSize(-1.0f);
// Apply window of custom dimensions
viewer.apply(new osgViewer::SingleWindow(0, 0, MY_OSG_WIDTH, MY_OSG_HEIGHT));
viewer.realize();
// ========= Earth manipulator =========
// install our default manipulator (do this before calling load)
EarthManipulator* manip = new EarthManipulator();
viewer.setCameraManipulator(manip);
// load an earth file, and support all or our example command-line options
auto node = MapNodeHelper().load(arguments, &viewer);
if (!node.valid()) {
std::cerr << "Invalid OSG node!";
exit(1);
}
viewer.setSceneData( node );
View Matrix
Projection Matrix (THIS PART SHOULD BE OK)
Resultsbelow are what I should see (real), and what I actually see (osgearth). By looking at edges, you can see that images are not aligned. It looks as if the camera is looking from a higher altitude. This tells me that it's not a projection matrix assignment error. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
There are a few things you can try to figure out what is going on:
|
Beta Was this translation helpful? Give feedback.
-
#3 is likely to be the problem in my experience.
…On Tue, Oct 31, 2023 at 8:22 AM Jason Beverage ***@***.***> wrote:
There are a few things you can try to figure out what is going on:
1.
If you are going to use the EarthManipulator, turn off terrain
avoidance to make sure it's not moving the camera to avoid going under the
terrain. For example do something like this:
manip ->getSettings()->setTerrainAvoidanceEnabled( false );
2.
I'm not sure what the source of the data that you are loading is, but
make sure that you are using the correct vertical datum for the elevation.
Try adding egm96 to your elevation layer in your earth file and see if
things look like they line up better.
3.
Your projection matrix is using fixed values for the width and height.
Be certain that the window you are rendering to has the same dimensions or
else osg will resize the projection matrix and you'll get different results
than you are expecting.
—
Reply to this email directly, view it on GitHub
<#2369 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPFE3AEDIU7XUXLG4ZOBHDYCECSJAVCNFSM6AAAAAA6XQQTYWVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TIMZVHE2DA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
There are a few things you can try to figure out what is going on:
If you are going to use the EarthManipulator, turn off terrain avoidance to make sure it's not moving the camera to avoid going under the terrain. For example do something like this:
manip ->getSettings()->setTerrainAvoidanceEnabled( false );
I'm not sure what the source of the data that you are loading is, but make sure that you are using the correct vertical datum for the elevation. Try adding egm96 to your elevation layer in your earth file and see if things look like they line up better.
Your projection matrix is using fixed values for the width and height. Be certain that the window you are rendering to has the …