From: Pablo d'A. <da...@us...> - 2006-11-11 21:29:30
|
Update of /cvsroot/hugin/hugin/src/include/hugin In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv17708/include/hugin Modified Files: CPEditorPanel.h CPImageCtrl.h LensPanel.h wxPanoCommand.h Log Message: new feature: determine roll from exif data. Rotate image in control point editor according to the roll value. Started implementation of the makefile generation for support of new panotools programs and smartblend (not finished yet). Index: CPImageCtrl.h =================================================================== RCS file: /cvsroot/hugin/hugin/src/include/hugin/CPImageCtrl.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- CPImageCtrl.h 5 May 2005 21:37:57 -0000 1.20 +++ CPImageCtrl.h 11 Nov 2006 21:29:25 -0000 1.21 @@ -115,12 +115,18 @@ */ ~CPImageCtrl(); + /** image rotation. + * Useful to display images depending on their roll setting. + * rotation is clockwise + */ + enum ImageRotation { ROT0=0, ROT90, ROT180, ROT270 }; + /// associate a zoomed display with this image void SetZoomView(CPZoomDisplayPanel * display); /// display img. every CPImageCtrl has a wxBitmap with /// its current image - void setImage (const std::string & filename); + void setImage (const std::string & filename, ImageRotation rot); /// control point inside this image void setCtrlPoints(const std::vector<FDiff2D> & points); @@ -276,6 +282,51 @@ return wxPoint(utils::roundi(p.x), utils::roundi(p.y)); } + // rotate coordinate to fit possibly rotated image display + // useful for drawing something on the rotated display + template <class T> + T applyRot(const T & p) const + { + switch (m_imgRotation) { + case ROT0: + return p; + break; + case ROT90: + return T(m_realSize.GetHeight()-1 - p.y, p.x); + break; + case ROT180: + return T(m_realSize.GetWidth()-1 - p.x, m_realSize.GetHeight()-1 - p.y); + break; + case ROT270: + return T(p.y, m_realSize.GetWidth()-1 - p.x); + break; + default: + return p; + break; + } + } + + // rotate coordinate to fit possibly rotated image display + // useful for converting rotated display coordinates to image coordinates + template <class T> + T applyRotInv(const T & p) const + { + switch (m_imgRotation) { + case ROT90: + return T(p.y, m_realSize.GetHeight()-1 - p.x); + break; + case ROT180: + return T(m_realSize.GetWidth()-1 - p.x, m_realSize.GetHeight()-1 - p.y); + break; + case ROT270: + return T(m_realSize.GetWidth()-1 - p.y, p.x); + break; + case ROT0: + default: + return p; + break; + } + } // this is only valid during MOVE_POINT unsigned int selectedPointNr; @@ -364,6 +415,8 @@ CPZoomDisplayPanel * m_zoomDisplay; + ImageRotation m_imgRotation; + DECLARE_EVENT_TABLE(); }; Index: CPEditorPanel.h =================================================================== RCS file: /cvsroot/hugin/hugin/src/include/hugin/CPEditorPanel.h,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- CPEditorPanel.h 10 Aug 2005 22:05:45 -0000 1.52 +++ CPEditorPanel.h 11 Nov 2006 21:29:25 -0000 1.53 @@ -251,6 +251,8 @@ CPCreationState OTHER_POINT, CPCreationState OTHER_POINT_RETRY); + /** calculate rotation required for upright image display from roll, pitch and yaw angles */ + CPImageCtrl::ImageRotation GetRot(double yaw, double roll, double pitch); CPCreationState cpCreationState; @@ -304,6 +306,9 @@ bool m_restoreLayoutOnResize; + CPImageCtrl::ImageRotation m_leftRot; + CPImageCtrl::ImageRotation m_rightRot; + // needed for receiving events. DECLARE_EVENT_TABLE(); }; Index: wxPanoCommand.h =================================================================== RCS file: /cvsroot/hugin/hugin/src/include/hugin/wxPanoCommand.h,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- wxPanoCommand.h 9 Aug 2006 20:55:39 -0000 1.32 +++ wxPanoCommand.h 11 Nov 2006 21:29:25 -0000 1.33 @@ -82,7 +82,8 @@ const std::string &filename = *it; Lens lens; - initLensFromFile(filename, cropFactor, lens); + double roll=0; + initLensFromFile(filename, cropFactor, lens, roll); if( lens.getImageSize().x == 0) { // if image size is invalid, do not add image. pano.changeFinished(); @@ -116,6 +117,8 @@ VariableMap vars; fillVariableMap(vars); + // set roll angle read from EXIF + map_get(vars,"r").setValue(roll); DEBUG_ASSERT(matchingLensNr >= 0); PanoImage img(filename, lens.getImageSize().x, lens.getImageSize().y, (unsigned int) matchingLensNr); @@ -213,13 +216,14 @@ // check if script contains invalid HFOV unsigned lNr = pano.getImage(i).getLensNr(); Lens cLens = pano.getLens(lNr); + double roll = 0; double hfov = const_map_get(pano.getVariables()[i], "v").getValue(); if (cLens.getProjection() == Lens::RECTILINEAR && hfov >= 180) { // try to load hfov from exif info initLensFromFile(pano.getImage(i).getFilename(), - defaultCropFactor, cLens); + defaultCropFactor, cLens, roll); if ( cLens.getImageSize().x == 0) { // if image size is invalid, abort script reading Index: LensPanel.h =================================================================== RCS file: /cvsroot/hugin/hugin/src/include/hugin/LensPanel.h,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- LensPanel.h 4 May 2006 06:25:40 -0000 1.39 +++ LensPanel.h 11 Nov 2006 21:29:25 -0000 1.40 @@ -147,7 +147,7 @@ }; /** try to read the lens spec from the exif info. */ -bool initLensFromFile(const std::string & filename, double & cropFactor, Lens & l); +bool initLensFromFile(const std::string & filename, double & cropFactor, Lens & l, double & roll); #endif // _LENSPANEL_H |