/
vw_position_extract.cc
64 lines (56 loc) · 2.19 KB
/
vw_position_extract.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// __BEGIN_LICENSE__
// Copyright (C) 2006-2011 United States Government as represented by
// the Administrator of the National Aeronautics and Space Administration.
// All Rights Reserved.
// __END_LICENSE__
#include <vw/Core.h>
#include <vw/Math/Vector.h>
#include <vw/Camera.h>
using namespace vw;
camera::CameraModel* load_camera( std::string file ) {
if ( boost::ends_with(file, ".cahvore") ) {
return new camera::CAHVOREModel( file );
} else if ( boost::ends_with(file, ".cahvor") ||
boost::ends_with(file, ".cmod") ) {
return new camera::CAHVORModel( file );
} else if ( boost::ends_with(file, ".cahv") ||
boost::ends_with(file, ".pin") ) {
return new camera::CAHVModel( file );
} else if ( boost::ends_with(file, ".pinhole") ||
boost::ends_with(file, ".tsai") ) {
return new camera::PinholeModel( file );
} else {
vw_throw( ArgumentErr() << "Unknown camera \"" << file << "\".\n" );
}
// Should never be hit;
return NULL;
}
int main( int argc, char* argv[] ) {
Vector2i image_size;
boost::shared_ptr<camera::CameraModel> camera_model;
if ( argc == 2 ) {
camera_model = boost::shared_ptr<camera::CameraModel>( load_camera( argv[1] ) );
} else if ( argc == 3 ) {
// hangle adjust camera
if ( boost::ends_with( argv[1], ".adjust" ) ) {
camera::AdjustedCameraModel* adjusted =
new camera::AdjustedCameraModel( boost::shared_ptr<camera::CameraModel>(
load_camera( argv[2] )));
adjusted->read( argv[1] );
camera_model = boost::shared_ptr<camera::CameraModel>( adjusted );
} else {
camera::AdjustedCameraModel* adjusted =
new camera::AdjustedCameraModel( boost::shared_ptr<camera::CameraModel>(
load_camera( argv[1] )));
adjusted->read( argv[2] );
camera_model = boost::shared_ptr<camera::CameraModel>( adjusted );
}
} else {
return 1;
}
Vector3 camera_position =
camera_model->camera_center(Vector2());
std::cout << std::setprecision(15) << camera_position[0] << " "
<< camera_position[1] << " " << camera_position[2] << "\n";
return 0;
}