Hugin trunk 0.1
Loading...
Searching...
No Matches
LayoutRemapper.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
24#include "panoinc_WX.h"
25#include "panoinc.h"
26
27#include <cmath>
28
29#include "LayoutRemapper.h"
30#include "ViewState.h"
31
34 VisualizationState *visualization_state)
35 :MeshRemapper(m_pano, image, visualization_state),
36 m_layoutScale(0)
37
38{
39 // We'll never use any different texture coordinates, so record them now:
40 face.tex_c[0][0][0] = 0.0;
41 face.tex_c[0][0][1] = 0.0;
42 face.tex_c[0][1][0] = 0.0;
43 face.tex_c[0][1][1] = 1.0;
44 face.tex_c[1][0][0] = 1.0;
45 face.tex_c[1][0][1] = 0.0;
46 face.tex_c[1][1][0] = 1.0;
47 face.tex_c[1][1][1] = 1.0;
48}
49
51{
52// HuginBase::SrcPanoImage *src_img = visualization_state->GetSrcImage(image_number);
53
54 // find the image size.
55 double image_width = (double) image->getSize().width();
56 double image_height = (double) image->getSize().height();
57
58 // remap the middle of the image to find centre coordinates.
59 double centre_x, centre_y;
60 // create a transformation from source image to destination.
63 image_width / 2.0, image_height / 2.0);
72 // work out the size to draw the image
75 if (landscape)
76 {
79 } else {
82 }
83
84 // find bounds for image drawing
85 double offset_x = preview_width / 2.0;
86 double offset_y = preview_height / 2.0;
87
88 // find the roll of the image.
89 double angle = image->getRoll() * (M_PI / 180.0) + (M_PI / 2.0);
90 double rsin = std::sin(angle);
91 double rcos = std::cos(angle);
92
93 double rsin_x = rsin * offset_x;
94 double rcos_x = rcos * offset_x;
95 double rsin_y = rsin * offset_y;
96 double rcos_y = rcos * offset_y;
97
98 face.vertex_c[0][0][0] = -rsin_x - rcos_y + centre_x;
99 face.vertex_c[0][0][1] = rcos_x -rsin_y + centre_y;
100 face.vertex_c[0][1][0] = -rsin_x + rcos_y + centre_x;
101 face.vertex_c[0][1][1] = rcos_x + rsin_y + centre_y;
102 face.vertex_c[1][0][0] = rsin_x - rcos_y + centre_x;
103 face.vertex_c[1][0][1] = -rcos_x - rsin_y + centre_y;
104 face.vertex_c[1][1][0] = rsin_x + rcos_y + centre_x;
105 face.vertex_c[1][1][1] = -rcos_x + rsin_y + centre_y;
106
107 // Specify our one face next time GetNextFaceCoordinates is called.
108 done = false;
109}
110
112{
113 if (!done)
114 {
115 // point caller at our coordinates.
116 result->tex_c = face.tex_c;
117 result->vertex_c = face.vertex_c;
118 // record that they have seen this face.
119 done = true;
120 return true;
121 }
122 // We've specified the one face required. No need for more.
123 return false;
124}
125
#define M_PI
Define a remapper to use in the layout mode.
bool transformImgCoord(double &x_dest, double &y_dest, double x_src, double y_src) const
like transform, but return image coordinates, not cartesian coordinates
void createInvTransform(const vigra::Diff2D &srcSize, VariableMap srcVars, Lens::LensProjectionFormat srcProj, const vigra::Diff2D &destSize, PanoramaOptions::ProjectionFormat destProj, const std::vector< double > &destProjParam, double destHFOV, const vigra::Diff2D &origSrcSize)
create image->pano transformation
Model for a panorama.
Definition Panorama.h:153
All variables of a source image.
void setScale(double scale)
Set the size to draw the images.
virtual void UpdateAndResetIndex()
ArrayCoords face
LayoutRemapper(HuginBase::Panorama *m_pano, HuginBase::SrcPanoImage *image, VisualizationState *visualization_state)
virtual bool GetNextFaceCoordinates(Coords *result)
Get the texture and vertex coordinates for the next face.
double vertex_c[2][2][2]
A class for exchanging pointers to coordinates.
double(* vertex_c)[2][2]
The coordinate in the panorama, in its pixel space.
double(* tex_c)[2][2]
The coordinate in the source image ranging from 0 to 1.
An abstract base class for objects that calculate an approximate remap specified by quadrilatrials.
HuginBase::SrcPanoImage * image
HuginBase::PTools::Transform transform
A transform to use to remap the images.
VisualizationState * visualization_state
virtual HuginBase::PanoramaOptions * GetOptions()
include file for the hugin project
include file for the hugin project
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41