OutputProjectionInfo.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00023 #include "OutputProjectionInfo.h"
00024 
00025 OutputProjectionInfo::OutputProjectionInfo(HuginBase::PanoramaOptions *output)
00026 {
00027     proj = output;
00028     // create the transformation from lat/long to the output image.
00029     HuginBase::SrcPanoImage fake_image;
00030     fake_image.setProjection(HuginBase::SrcPanoImage::EQUIRECTANGULAR);
00031     fake_image.setSize(vigra::Size2D(360, 180));
00032     fake_image.setHFOV(360.0);
00033     transform.createInvTransform(fake_image, *output);
00034     // sometimes we want to go back again
00035     reverse_transform.createTransform(fake_image, *output);
00036     // now grab the frequently used values
00037     double x, y;
00038     transform.transformImgCoord(x, y, 0.0, 90.0);
00039     x_add_360 = x * -2.0 + output->getSize()->x;
00040     radius = -x + output->getSize()->x / 2.0;
00041     transform.transformImgCoord(x, y, 180.0, 0.0);
00042     y_add_360 = -y * 2.0 + output->getSize()->y;
00043     north_pole_x = x;
00044     north_pole_y = y;
00045     transform.transformImgCoord(x, y, 180.0, 180.0);
00046     south_pole_x = x;
00047     south_pole_y = y;
00048     transform.transformImgCoord(x, y, 180.0, 90.0);
00049     middle_x = x;
00050     middle_y = y;
00051     transform.transformImgCoord(x, y, 120.0, 90.0);
00052     lower_x = x;
00053     transform.transformImgCoord(x, y, 240.0, 90.0);
00054     upper_x = x;
00055     transform.transformImgCoord(x, y, 180.0, 60.0);
00056     lower_y = y;
00057     transform.transformImgCoord(x, y, 180.0, 120.0);
00058     upper_y = y;
00059     switch (output->getProjection())
00060     {
00061         case HuginBase::PanoramaOptions::TRANSVERSE_MERCATOR:
00062         case HuginBase::PanoramaOptions::STEREOGRAPHIC:
00063         case HuginBase::PanoramaOptions::LAMBERT_AZIMUTHAL:
00064         case HuginBase::PanoramaOptions::HAMMER_AITOFF:
00065         case HuginBase::PanoramaOptions::FULL_FRAME_FISHEYE:
00066         case HuginBase::PanoramaOptions::ARCHITECTURAL:
00067         case HuginBase::PanoramaOptions::ORTHOGRAPHIC:
00068         case HuginBase::PanoramaOptions::EQUISOLID:
00069         case HuginBase::PanoramaOptions::THOBY_PROJECTION:
00070             // The poles are on the sides.
00071             // ...or at least they can be detected from the sides (disk-likes)
00072             // I've offset the noth pole slightly as the detection rate was
00073             // not 100%
00074             transform.transformImgCoord(x, y, 0.5, 90.0);
00075             north_pole_x = x;
00076             north_pole_y = y;
00077             transform.transformImgCoord(x, y, 359.5, 90.0);
00078             south_pole_x = x;
00079             south_pole_y = y;
00080             break;
00081         default:
00082             break;
00083     }
00084 }
00085 
00086 // Some of the properties defined above change with height in some projections.
00087 // We have to convert an output point to elevation, and then find the boundaries
00088 // for +/- 180 degree seam detection at that elevation.
00089 const double OutputProjectionInfo::GetUpperX(const double y) const
00090 {
00091     double temp, pitch, result;
00092     reverse_transform.transformImgCoord(temp, pitch, 180, y);
00093     transform.transformImgCoord(result, temp, 240.0, pitch);
00094     return result;
00095 }
00096 
00097 const double OutputProjectionInfo::GetLowerX(const double y) const
00098 {
00099     double temp, pitch, result;
00100     reverse_transform.transformImgCoord(temp, pitch, 180, y);
00101     transform.transformImgCoord(result, temp, 120.0, pitch);
00102     return result;
00103 }
00104 
00105 // correction also changes, this is needed to move the detected vertices.
00106 const double OutputProjectionInfo::GetXAdd360(const double y) const
00107 {
00108     double temp, pitch, result;
00109     reverse_transform.transformImgCoord(temp, pitch, 180, y);
00110     transform.transformImgCoord(result, temp, 0.0, pitch);
00111     return result * -2.0 + proj->getSize()->x;
00112 }
00113 
00114 
00115 // Use the transformations to get arbitary points.
00116 
00117 bool OutputProjectionInfo::AngularToImage(double &image_x, double &image_y,
00118                                           double yaw, double pitch)
00119 {
00120     return transform.transformImgCoord(image_x, image_y,
00121                                        yaw + 180.0, pitch + 90.0);
00122 }
00123 
00124 bool OutputProjectionInfo::ImageToAngular(double &yaw, double &pitch,
00125                                           double image_x, double image_y)
00126 {
00127     bool r = reverse_transform.transformImgCoord(yaw, pitch, image_x, image_y);
00128     yaw -= 180.0;
00129     pitch -= 90.0;
00130     return r;
00131 }
00132 

Generated on 24 Oct 2014 for Hugintrunk by  doxygen 1.4.7