vpgl_io_proj_camera.hxx
Go to the documentation of this file.
1 #ifndef vpgl_io_proj_camera_hxx_
2 #define vpgl_io_proj_camera_hxx_
3 
4 #include "vpgl_io_proj_camera.h"
5 //:
6 // \file
9 
10 template <class T>
12 {
13  if (!os) return;
14  unsigned version = 1;
15  vsl_b_write(os, version);
16  vsl_b_write(os, camera.get_matrix());
17 }
18 
19 //: Binary load camera from stream.
20 template <class T>
22 {
23  if (!is) return;
24  short ver;
25  vsl_b_read(is, ver);
27  switch (ver)
28  {
29  case 1:
30  vsl_b_read(is, Pnew);
31  camera.set_matrix(Pnew);
32  break;
33  default:
34  std::cerr << "I/O ERROR: vpgl_proj_camera::b_read(vsl_b_istream&)\n"
35  << " Unknown version number "<< ver << '\n';
36  is.is().clear(std::ios::badbit); // Set an unrecoverable IO error on stream
37  return;
38  }
39 }
40 
41 //: Print human readable summary of object to a stream
42 template <class T>
43 void vsl_print_summary(std::ostream& os,const vpgl_proj_camera<T> & c)
44 {
45  os << c << '\n';
46 }
47 
48 
49 #define VPGL_IO_PROJ_CAMERA_INSTANTIATE(T) \
50 template void vsl_b_write(vsl_b_ostream & os, vpgl_proj_camera<T > const& camera); \
51 template void vsl_b_read(vsl_b_istream & is, vpgl_proj_camera<T > &camera); \
52 template void vsl_print_summary(std::ostream& os,const vpgl_proj_camera<T > & b)
53 
54 #endif // vpgl_io_proj_camera_hxx_
std::istream & is() const
virtual bool set_matrix(const vnl_matrix_fixed< T, 3, 4 > &new_camera_matrix)
Setters mirror the constructors and return true if the setting was successful.
void vsl_b_write(vsl_b_ostream &os, vpgl_proj_camera< T > const &camera)
Binary save camera to stream.
A camera model using the standard 3x4 matrix representation.
const vnl_matrix_fixed< T, 3, 4 > & get_matrix() const
Return a copy of the camera matrix.
void vsl_print_summary(std::ostream &os, const vpgl_proj_camera< T > &c)
Print human readable summary of object to a stream.
void vsl_b_read(vsl_b_istream &is, vpgl_proj_camera< T > &camera)
Binary load camera from stream.