Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
vpgl_geo_camera Class Reference

#include <vpgl_geo_camera.h>

Inheritance diagram for vpgl_geo_camera:
Inheritance graph
[legend]

Public Member Functions

 vpgl_geo_camera ()
 creates identity matrix and all zero tiepoints. More...
 
 vpgl_geo_camera (vnl_matrix< double > trans_matrix, vpgl_lvcs_sptr lvcs)
 if scale tag is false be sure that trans_matrix[0][0] and trans_matrix[1][1] is 1.0 otherwise set it to true. More...
 
 vpgl_geo_camera (vpgl_geo_camera const &rhs)
 
 vpgl_geo_camera (vpgl_camera< double > const &rhs)
 
 ~vpgl_geo_camera () override=default
 
std::string type_name () const override
 class identity functions for casting. More...
 
void set_utm (int utm_zone, unsigned northing)
 
void set_lvcs (vpgl_lvcs_sptr lvcs)
 
void set_scale_format (bool scale_tag)
 
vpgl_lvcs_sptr const lvcs ()
 
void project (const double x, const double y, const double z, double &u, double &v) const override
 Implementing the generic camera interface of vpgl_camera. More...
 
void backproject (const double u, const double v, double &x, double &y, double &z)
 backprojects an image point into local coordinates (based on lvcs_). More...
 
void translate (double tx, double ty, double z)
 
double pixel_spacing ()
 the lidar pixel size in meters assumes square pixels. More...
 
bool operator== (vpgl_geo_camera const &rhs) const
 
virtual std::string is_a () const
 Return a platform independent string identifying the class. More...
 
virtual bool is_class (std::string const &cls) const
 Return true if the argument matches the string identifying the class or any parent class. More...
 
void save_as_tfw (std::string const &tfw_filename)
 save the camera as tfw. More...
 
void img_to_global (const double i, const double j, double &lon, double &lat) const
 returns the corresponding geographical coordinates for a given pixel position (i,j). More...
 
void global_to_img (const double lon, const double lat, const double elev, double &u, double &v) const
 returns the corresponding pixel position for given geographical coordinates. More...
 
void img_to_global_utm (const double i, const double j, double &x, double &y) const
 returns the corresponding geographical coordinates for a given pixel position (i,j). More...
 
void global_utm_to_img (const double x, const double y, int zone, double elev, double &u, double &v) const
 returns the corresponding pixel position for given geographical coordinates. More...
 
void local_to_utm (const double x, const double y, const double z, double &e, double &n, int &utm_zone)
 returns the corresponding utm location for the given local position. More...
 
int utm_zone ()
 
bool img_four_corners_in_utm (const unsigned ni, const unsigned nj, double elev, double &e1, double &n1, double &e2, double &n2)
 
void img_to_wgs (unsigned i, unsigned j, unsigned k, double &lon, double &lat, double &elev)
 returns the corresponding geographical coordinate (lon, lat, elev) for a given pixel position (i,j,k). More...
 
vnl_matrix< double > trans_matrix ()
 
void b_write (vsl_b_ostream &os) const
 Binary save self to stream. More...
 
void b_read (vsl_b_istream &is)
 Binary load self from stream. More...
 
short version () const
 Return IO version number;. More...
 
void ref ()
 
void unref ()
 
long get_references () const
 
bool is_referenced () const
 

Static Public Member Functions

static bool init_geo_camera (vil_image_resource_sptr const &geotiff_img, const vpgl_lvcs_sptr &lvcs, vpgl_geo_camera *&camera)
 uses lvcs to convert local x-y to global longitude and latitude. More...
 
static bool init_geo_camera (vil_image_resource_sptr const geotiff_img, vpgl_geo_camera *&camera)
 Assumes geographic coordinates are global. More...
 
static bool init_geo_camera (const std::string &img_name, unsigned ni, unsigned nj, const vpgl_lvcs_sptr &lvcs, vpgl_geo_camera *&camera)
 warning, use this camera cautiously, the output of img_to_global method needs to be adjusted sign wise. More...
 
static bool init_geo_camera_from_filename (const std::string &img_name, unsigned ni, unsigned nj, const vpgl_lvcs_sptr &lvcs, vpgl_geo_camera *&camera)
 
static bool init_geo_camera (const std::string &tfw_name, const vpgl_lvcs_sptr &lvcs, int utm_zone, unsigned northing, vpgl_geo_camera *&camera)
 init using a tfw file, reads the transformation matrix from the tfw. More...
 
static bool init_geo_camera (std::string tfw_name, int utm_zone, unsigned northing, vpgl_geo_camera *&camera)
 init without lvcs. Assumes geographic coordinates are global. More...
 
static bool comp_trans_matrix (double sx1, double sy1, double sz1, std::vector< std::vector< double > > tiepoints, vnl_matrix< double > &trans_matrix, bool scale_tag=false)
 

Private Attributes

vnl_matrix< double > trans_matrix_
 
vpgl_lvcs_sptr lvcs_
 lvcs of world parameters. More...
 
bool is_utm
 
int utm_zone_
 
int northing_
 
bool scale_tag_
 

Friends

std::ostream & operator<< (std::ostream &s, vpgl_geo_camera const &p)
 Write camera to stream. More...
 
std::istream & operator>> (std::istream &s, vpgl_geo_camera &p)
 Read camera from stream. More...
 

Detailed Description

Definition at line 29 of file vpgl_geo_camera.h.

Constructor & Destructor Documentation

◆ vpgl_geo_camera() [1/4]

vpgl_geo_camera::vpgl_geo_camera ( )

creates identity matrix and all zero tiepoints.

Definition at line 23 of file vpgl_geo_camera.cxx.

◆ vpgl_geo_camera() [2/4]

vpgl_geo_camera::vpgl_geo_camera ( vnl_matrix< double >  trans_matrix,
vpgl_lvcs_sptr  lvcs 
)
inline

if scale tag is false be sure that trans_matrix[0][0] and trans_matrix[1][1] is 1.0 otherwise set it to true.

Definition at line 36 of file vpgl_geo_camera.h.

◆ vpgl_geo_camera() [3/4]

vpgl_geo_camera::vpgl_geo_camera ( vpgl_geo_camera const &  rhs)

Definition at line 32 of file vpgl_geo_camera.cxx.

◆ vpgl_geo_camera() [4/4]

vpgl_geo_camera::vpgl_geo_camera ( vpgl_camera< double > const &  rhs)

◆ ~vpgl_geo_camera()

vpgl_geo_camera::~vpgl_geo_camera ( )
overridedefault

Member Function Documentation

◆ b_read()

void vpgl_geo_camera::b_read ( vsl_b_istream is)

Binary load self from stream.

Definition at line 640 of file vpgl_geo_camera.cxx.

◆ b_write()

void vpgl_geo_camera::b_write ( vsl_b_ostream os) const

Binary save self to stream.

Definition at line 622 of file vpgl_geo_camera.cxx.

◆ backproject()

void vpgl_geo_camera::backproject ( const double  u,
const double  v,
double &  x,
double &  y,
double &  z 
)

backprojects an image point into local coordinates (based on lvcs_).

Definition at line 322 of file vpgl_geo_camera.cxx.

◆ comp_trans_matrix()

bool vpgl_geo_camera::comp_trans_matrix ( double  sx1,
double  sy1,
double  sz1,
std::vector< std::vector< double > >  tiepoints,
vnl_matrix< double > &  trans_matrix,
bool  scale_tag = false 
)
static

Definition at line 567 of file vpgl_geo_camera.cxx.

◆ global_to_img()

void vpgl_geo_camera::global_to_img ( const double  lon,
const double  lat,
const double  gz,
double &  u,
double &  v 
) const

returns the corresponding pixel position for given geographical coordinates.

the input global coord is wgs84

The input global coord is wgs84

Definition at line 402 of file vpgl_geo_camera.cxx.

◆ global_utm_to_img()

void vpgl_geo_camera::global_utm_to_img ( const double  x,
const double  y,
int  zone,
double  elev,
double &  u,
double &  v 
) const

returns the corresponding pixel position for given geographical coordinates.

the input global coord is UTM: x east, for y north

The input global coord is UTM: x east, for y north

Definition at line 462 of file vpgl_geo_camera.cxx.

◆ img_four_corners_in_utm()

bool vpgl_geo_camera::img_four_corners_in_utm ( const unsigned  ni,
const unsigned  nj,
double  elev,
double &  e1,
double &  n1,
double &  e2,
double &  n2 
)

Definition at line 520 of file vpgl_geo_camera.cxx.

◆ img_to_global()

void vpgl_geo_camera::img_to_global ( const double  i,
const double  j,
double &  lon,
double &  lat 
) const

returns the corresponding geographical coordinates for a given pixel position (i,j).

the output global coord is wgs84

The output global coord is wgs84

Definition at line 376 of file vpgl_geo_camera.cxx.

◆ img_to_global_utm()

void vpgl_geo_camera::img_to_global_utm ( const double  i,
const double  j,
double &  x,
double &  y 
) const

returns the corresponding geographical coordinates for a given pixel position (i,j).

the output global coord is UTM: x east, y north

The output global coord is UTM: x east, y north

Definition at line 437 of file vpgl_geo_camera.cxx.

◆ img_to_wgs()

void vpgl_geo_camera::img_to_wgs ( unsigned  i,
unsigned  j,
unsigned  k,
double &  lon,
double &  lat,
double &  elev 
)

returns the corresponding geographical coordinate (lon, lat, elev) for a given pixel position (i,j,k).

Note: not yet implemented – PVr, 16 aug 2012

Definition at line 616 of file vpgl_geo_camera.cxx.

◆ init_geo_camera() [1/5]

bool vpgl_geo_camera::init_geo_camera ( vil_image_resource_sptr const &  geotiff_img,
const vpgl_lvcs_sptr lvcs,
vpgl_geo_camera *&  camera 
)
static

uses lvcs to convert local x-y to global longitude and latitude.

Definition at line 41 of file vpgl_geo_camera.cxx.

◆ init_geo_camera() [2/5]

static bool vpgl_geo_camera::init_geo_camera ( vil_image_resource_sptr const  geotiff_img,
vpgl_geo_camera *&  camera 
)
inlinestatic

Assumes geographic coordinates are global.

Definition at line 51 of file vpgl_geo_camera.h.

◆ init_geo_camera() [3/5]

bool vpgl_geo_camera::init_geo_camera ( const std::string &  img_name,
unsigned  ni,
unsigned  nj,
const vpgl_lvcs_sptr lvcs,
vpgl_geo_camera *&  camera 
)
static

warning, use this camera cautiously, the output of img_to_global method needs to be adjusted sign wise.

define a geo_camera by the image file name (filename should have format such as xxx_N35W73_S0.6x0.6_xxx.tif).

for 'S' use -lat and for 'W' -lon

Todo:
: generalize geo_camera so that img_to_global method makes this adjustment internally if camera is created using this method

Definition at line 111 of file vpgl_geo_camera.cxx.

◆ init_geo_camera() [4/5]

bool vpgl_geo_camera::init_geo_camera ( const std::string &  tfw_name,
const vpgl_lvcs_sptr lvcs,
int  utm_zone,
unsigned  northing,
vpgl_geo_camera *&  camera 
)
static

init using a tfw file, reads the transformation matrix from the tfw.

Definition at line 265 of file vpgl_geo_camera.cxx.

◆ init_geo_camera() [5/5]

static bool vpgl_geo_camera::init_geo_camera ( std::string  tfw_name,
int  utm_zone,
unsigned  northing,
vpgl_geo_camera *&  camera 
)
inlinestatic

init without lvcs. Assumes geographic coordinates are global.

Definition at line 69 of file vpgl_geo_camera.h.

◆ init_geo_camera_from_filename()

bool vpgl_geo_camera::init_geo_camera_from_filename ( const std::string &  img_name,
unsigned  ni,
unsigned  nj,
const vpgl_lvcs_sptr lvcs,
vpgl_geo_camera *&  camera 
)
static

Definition at line 205 of file vpgl_geo_camera.cxx.

◆ is_a()

virtual std::string vpgl_geo_camera::is_a ( ) const
inlinevirtual

Return a platform independent string identifying the class.

Definition at line 108 of file vpgl_geo_camera.h.

◆ is_class()

virtual bool vpgl_geo_camera::is_class ( std::string const &  cls) const
inlinevirtual

Return true if the argument matches the string identifying the class or any parent class.

Definition at line 111 of file vpgl_geo_camera.h.

◆ local_to_utm()

void vpgl_geo_camera::local_to_utm ( const double  x,
const double  y,
const double  z,
double &  e,
double &  n,
int &  utm_zone 
)

returns the corresponding utm location for the given local position.

Definition at line 497 of file vpgl_geo_camera.cxx.

◆ lvcs()

vpgl_lvcs_sptr const vpgl_geo_camera::lvcs ( )
inline

Definition at line 84 of file vpgl_geo_camera.h.

◆ operator==()

bool vpgl_geo_camera::operator== ( vpgl_geo_camera const &  rhs) const

Definition at line 536 of file vpgl_geo_camera.cxx.

◆ pixel_spacing()

double vpgl_geo_camera::pixel_spacing ( )
inline

the lidar pixel size in meters assumes square pixels.

Definition at line 97 of file vpgl_geo_camera.h.

◆ project()

void vpgl_geo_camera::project ( const double  x,
const double  y,
const double  z,
double &  u,
double &  v 
) const
overridevirtual

Implementing the generic camera interface of vpgl_camera.

transforms a given local 3d world point to image plane.

x,y,z are in local coordinates, u represents image column, v image row

Implements vpgl_camera< double >.

Definition at line 294 of file vpgl_geo_camera.cxx.

◆ save_as_tfw()

void vpgl_geo_camera::save_as_tfw ( std::string const &  tfw_filename)

save the camera as tfw.

Definition at line 507 of file vpgl_geo_camera.cxx.

◆ set_lvcs()

void vpgl_geo_camera::set_lvcs ( vpgl_lvcs_sptr  lvcs)
inline

Definition at line 80 of file vpgl_geo_camera.h.

◆ set_scale_format()

void vpgl_geo_camera::set_scale_format ( bool  scale_tag)
inline

Definition at line 82 of file vpgl_geo_camera.h.

◆ set_utm()

void vpgl_geo_camera::set_utm ( int  utm_zone,
unsigned  northing 
)
inline

Definition at line 78 of file vpgl_geo_camera.h.

◆ trans_matrix()

vnl_matrix<double> vpgl_geo_camera::trans_matrix ( )
inline

Definition at line 154 of file vpgl_geo_camera.h.

◆ translate()

void vpgl_geo_camera::translate ( double  tx,
double  ty,
double  z 
)

Definition at line 360 of file vpgl_geo_camera.cxx.

◆ type_name()

std::string vpgl_geo_camera::type_name ( ) const
inlineoverridevirtual

class identity functions for casting.

Reimplemented from vpgl_camera< double >.

Definition at line 75 of file vpgl_geo_camera.h.

◆ utm_zone()

int vpgl_geo_camera::utm_zone ( )
inline

Definition at line 146 of file vpgl_geo_camera.h.

◆ version()

short vpgl_geo_camera::version ( ) const
inline

Return IO version number;.

Definition at line 169 of file vpgl_geo_camera.h.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  s,
vpgl_geo_camera const &  p 
)
friend

Write camera to stream.

Definition at line 543 of file vpgl_geo_camera.cxx.

◆ operator>>

std::istream& operator>> ( std::istream &  s,
vpgl_geo_camera p 
)
friend

Read camera from stream.

Definition at line 556 of file vpgl_geo_camera.cxx.

Member Data Documentation

◆ is_utm

bool vpgl_geo_camera::is_utm
private

Definition at line 176 of file vpgl_geo_camera.h.

◆ lvcs_

vpgl_lvcs_sptr vpgl_geo_camera::lvcs_
private

lvcs of world parameters.

Definition at line 175 of file vpgl_geo_camera.h.

◆ northing_

int vpgl_geo_camera::northing_
private

Definition at line 178 of file vpgl_geo_camera.h.

◆ scale_tag_

bool vpgl_geo_camera::scale_tag_
private

Definition at line 179 of file vpgl_geo_camera.h.

◆ trans_matrix_

vnl_matrix<double> vpgl_geo_camera::trans_matrix_
private

Definition at line 173 of file vpgl_geo_camera.h.

◆ utm_zone_

int vpgl_geo_camera::utm_zone_
private

Definition at line 177 of file vpgl_geo_camera.h.


The documentation for this class was generated from the following files: