106 :
MeshRemapper(m_pano_in, image, visualization_state_in)
194 for (
short unsigned int x = 0; x < 2; x++)
196 for (
short unsigned int y = 0; y < 2; y++)
212 for (
short unsigned int x = 0; x < 2; x++)
214 for (
short unsigned int y = 0; y < 2; y++)
310 unsigned int stretch_x,
unsigned stretch_y)
314 unsigned int x, y, row_size, depth;
325 for (
unsigned short int i = 0; i < 2; i++)
327 for (
unsigned short int j = 0; j < 2; j++)
334 node->
verts[i][j][1],
340 if (i == x %2 && j == y%2 && depth)
343 node->
verts[i][j][0] = parent->verts[i][j][0];
344 node->
verts[i][j][1] = parent->verts[i][j][1];
346 }
else if (x % 2 && !i) {
348 node->
verts[0][j][0] = left->verts[1][j][0];
349 node->
verts[0][j][1] = left->verts[1][j][1];
351 }
else if (y % 2 && !j) {
353 node->
verts[i][0][0] = top->verts[i][1][0];
354 node->
verts[i][0][1] = top->verts[i][1][1];
362 y + j * (1 << stretch_y),
363 depth, x, y, node->
verts[i][j][0],
364 node->
verts[i][j][1]))
369 node->
verts[i][j][1],
394 node->
verts[i][1][0] = (parent->verts[0][1][0]
395 + parent->verts[1][1][0]) / 2.0;
396 node->
verts[i][1][1] = (parent->verts[0][1][1]
397 + parent->verts[1][1][1]) / 2.0;
407 node->
verts[1][j][0] = (parent->verts[1][0][0]
408 + parent->verts[1][1][0]) / 2.0;
409 node->
verts[1][j][1] = (parent->verts[1][0][1]
410 + parent->verts[1][1][1]) / 2.0;
424 for (
unsigned int i = 0; i < 2; i++)
426 for (
unsigned int j = 0; j < 2; j++)
455 stretch_x, stretch_y);
460 stretch_x, stretch_y);
466 stretch_x, stretch_y);
471 stretch_x, stretch_y);
480 unsigned int x, y, row_size, depth;
482 unsigned short int flags = 0;
501 do_not_split_x =
true;
502 do_not_split_y =
true;
508 do_not_split_x =
true;
512 do_not_split_y =
true;
518 do_not_split_x =
true;
522 do_not_split_y =
true;
533 if (ang_x < 0) ang_x = -ang_x;
534 if (ang_x >
M_PI) ang_x = 2 *
M_PI - ang_x;
535 float length_difference_x
537 if (length_difference_x < 0.0)
539 length_difference_x = -length_difference_x;
543 do_not_split_x =
true;
546 if (ang_y < 0) ang_y = -ang_y;
547 if (ang_y >
M_PI) ang_y = 2 *
M_PI - ang_y;
548 float length_difference_y
550 if (length_difference_y < 0.0)
552 length_difference_y = -length_difference_y;
556 do_not_split_y =
true;
567 bool all_left =
true, all_right =
true,
568 all_above =
true, all_bellow =
true;
569 for (
unsigned int ix = 0; ix < 2; ix++)
571 for (
unsigned int iy = 0; iy < 2; iy++)
573 if (node->
verts[ix][iy][0] > viewport.left())
575 if (node->
verts[ix][iy][0] < viewport.right())
577 if (node->
verts[ix][iy][1] > viewport.top())
579 if (node->
verts[ix][iy][1] < viewport.bottom())
583 if (all_left || all_right || all_bellow || all_above)
587 do_not_split_x =
true;
588 do_not_split_y =
true;
605 bool noncontinuous =
false;
641 noncontinuous =
true;
673 noncontinuous =
true;
704 noncontinuous =
true;
747 double dest_x, dest_y;
748 unsigned int subdiv_node;
751 x * 2, y * 2, dest_x, dest_y);
752 if (subdiv_node > node_id)
762 double dest_x, dest_y;
763 unsigned int subdiv_node;
766 x * 2, y * 2, dest_x, dest_y);
767 if (subdiv_node > node_id)
778 float xdx = node->
verts[0][0][0] - node->
verts[1][0][0],
779 xdy = node->
verts[0][0][1] - node->
verts[1][0][1],
780 ydx = node->
verts[0][0][0] - node->
verts[0][1][0],
781 ydy = node->
verts[0][0][1] - node->
verts[0][1][1];
787 node->
angle_x = atan2(xdy, xdx);
788 node->
angle_y = atan2(ydy, ydx);
794 unsigned int x, y, row_size, depth;
801 unsigned int row_size,
811 return GetIndex(x, y, row_size, depth);
816 unsigned int depth = 0, count = 0;
817 while (node_num > count)
820 count += 1 << (depth * 2);
826 unsigned int &x,
unsigned int &y,
827 unsigned int &row_size,
830 depth = GetDepth(node_num);
831 row_size = 1 << depth;
832 unsigned int sub = 0;
835 for (
unsigned int d = 0; d < depth; d++)
837 sub += (1 << (d * 2));
840 unsigned int position_id = node_num - sub;
841 x = position_id % row_size;
842 y = position_id / row_size;
846 const unsigned int y,
847 const unsigned int row_size,
850 unsigned int add = 0;
854 add += 1 << (depth * 2);
856 return add + x + y * row_size;
860 double coords[2][2][2])
866 unsigned int x, y, row_size, depth;
867 GetPosition(node_num, x, y, row_size, depth);
869 double row_spacing = 1.0 / (double) row_size;
870 coords[0][0][0] = row_spacing * (double) x;
871 coords[0][0][1] = row_spacing * (double) y;
875 bool scale_x =
false;
879 unsigned int parent_id = GetParentId(x, y, row_size, depth);
882 while (!(nodes[parent_id].
flags & split_flag_x))
884 parent_id = GetParentId(parent_id);
891 parent_id = GetParentId(parent_id);
897 coords[1][0][0] = coords[0][0][0] + (scale_x ? opp : row_spacing);
898 coords[1][0][1] = coords[0][0][1];
899 coords[0][1][0] = coords[0][0][0];
900 coords[0][1][1] = coords[0][0][1] + (scale_x ? row_spacing : opp);
901 coords[1][1][0] = coords[1][0][0];
902 coords[1][1][1] = coords[0][1][1];
905 for (
unsigned int i = 0; i < 2; i++)
907 for (
unsigned int j = 0; j < 2; j++)
909 coords[i][j][0] = coords[i][j][0] * x_crop_scale + x_crop_offs;
910 coords[i][j][1] = coords[i][j][1] * y_crop_scale + y_crop_offs;
923 unsigned int x, y, row_size, depth;
924 GetPosition(cur_tree_node, x, y, row_size, depth);
927 if (cur_tree_node != 0)
930 while (!done && cur_tree_node != 0)
932 unsigned int xd = x % 2;
933 unsigned int yd = y % 2;
938 cur_tree_node = GetIndex(x, y, row_size, depth);
939 if (cur_tree_node == 0 && xd == 1 && yd == 1)
945 bool sx = ((nodes[cur_tree_node].flags &
split_flag_x) != 0);
946 bool sy = ((nodes[cur_tree_node].flags &
split_flag_y) != 0);
948 if (!(((sx && xd) || !sx) && ((sy && yd) || !sy)))
956 if (sx && !xd && !yd) {
958 }
else if ((sx && xd && sy && !yd) || (!sx && sy && !yd)) {
960 }
else if (sx && sy && !xd && yd) {
963 cur_tree_node = GetIndex(x, y, row_size, depth);
966 if (cur_tree_node == 0)
980 cur_tree_node = GetIndex(x, y, row_size, depth);
982 return cur_tree_node;
987 unsigned int stop_x,
unsigned int stop_y,
988 double &dest_x,
double &dest_y)
993 unsigned int no_x = 0, no_y = 0, row_size = 1, depth = 0,
994 rem_x = src_x, rem_y = src_y,
996 node_id = GetIndex(no_x, no_y, row_size, depth);
997 while ( !( (rem_x == 0 || rem_x == step_x)
998 && (rem_y == 0 || rem_y == step_y))
1026 if (depth > max_depth)
return 0;
1027 node_id = GetIndex(no_x, no_y, row_size, depth);
1028 if (depth == max_depth && no_x >= stop_x && no_y >= stop_y)
return 0;
1043 double xf = (double) rem_x / (
double) step_x;
1044 double yf = (double) rem_y / (
double) step_y;
1046 double top_x = (1.0 - xf) * nodes[node_id].verts[0][0][0]
1047 + xf * nodes[node_id].verts[1][0][0],
1048 bottom_x = (1-.0 - xf) * nodes[node_id].verts[0][1][0]
1049 + xf * nodes[node_id].verts[1][1][0],
1050 top_y = (1.0 - xf) * nodes[node_id].verts[0][0][1]
1051 + xf * nodes[node_id].verts[1][0][1],
1052 bottom_y = (1.0 - xf) * nodes[node_id].verts[0][1][1]
1053 + xf * nodes[node_id].verts[1][1][1];
1054 dest_x = top_x * (1.0 - yf) + bottom_x * yf;
1055 dest_y = top_y * (1.0 - yf) + bottom_y* yf;
VertexCoordRemapper(HuginBase::Panorama *m_pano, HuginBase::SrcPanoImage *image, VisualizationState *visualization_state)
PanoramaOptions::ProjectionFormat getProjection() const
bool GiveClipFaceResult(Coords *result)
Get a face that was produced by ClipFace.
unsigned int GetDepth(const unsigned int nodenum)
An abstract base class for objects that calculate an approximate remap specified by quadrilatrials...
const double GetUpperY() const
double s_vertex_coords[2][2][2]
unsigned int GetIndex(const unsigned int x, const unsigned int y, const unsigned int row_size, unsigned int depth)
double tex_coords[2][2][2]
void SetLengthAndAngle(TreeNode *node)
A class for exchanging pointers to coordinates.
const unsigned short int split_flag_y
unsigned int getHeight() const
get panorama height
HuginBase::SrcPanoImage * image
const double GetRadius() const
virtual void UpdateAndResetIndex()
const double GetUpperX() const
void DiscontinuityFlip(double vertex_c[2])
include file for the hugin project
double(* tex_c)[2][2]
The coordinate in the source image ranging from 0 to 1.
void RecursiveUpdate(unsigned int node_id, unsigned int stretch_x, unsigned int stretch_y)
bool isInside(vigra::Point2D p, bool ignoreMasks=false) const
check if a coordinate is inside the source image
HuginBase::PanoramaOptions::ProjectionFormat output_projection
const double GetLowerY() const
VisualizationState * visualization_state
const unsigned short int split_flag_x
const double min_length_difference
const unsigned short int patch_flag_x
unsigned int tree_node_id
TreeNode nodes[1+4+16+64+256+1024+4096]
void ClipFace(Coords *face)
Crop a face to the source image, return true if there is anything left.
const double GetMiddleY() const
void SetCrop()
Fill the crop values of the MeshRemapper from the source image.
vigra::Rect2D GetVisibleArea()
double height
The sizes of the input images in pixels.
unsigned int GetParentId(const unsigned int nodenum)
void GetInputCoordinates(unsigned int node_num, double coords[2][2][2])
float scale
The number number of units between vertex coorinates that gives a pixel in the display.
const unsigned short int vertex_side_flag_start
const double GetMiddleX() const
virtual OutputProjectionInfo * GetProjectionInfo()
void GetPosition(const unsigned int nodenum, unsigned int &x, unsigned int &y, unsigned int &row_size, unsigned int &depth)
unsigned int GetTransform(unsigned int src_x, unsigned int src_y, unsigned int depth, unsigned int stop_x, unsigned int stop_y, double &dest_x, double &dest_y)
const double GetXAdd360() const
const double GetLowerX() const
HuginBase::PTools::Transform transform
A transform to use to remap the images.
unsigned int getWidth() const
include file for the hugin project
const unsigned int min_depth
const unsigned short int transform_fail_flag
const unsigned short int patch_flag_y
virtual HuginBase::PanoramaOptions * GetOptions()
const unsigned int max_depth
virtual bool GetNextFaceCoordinates(Coords *result)
Get the texture and vertex coordinates for the next face.
virtual void UpdateAndResetIndex()
static void info(const char *fmt,...)
unsigned short int discontinuity_flags
const double offscreen_safety_margin
double(* vertex_c)[2][2]
The coordinate in the panorama, in its pixel space.
All variables of a source image.
void TestSubdivide(unsigned int node_id)
const double GetYAdd360() const