From: <tm...@us...> - 2010-02-20 08:37:48
|
Revision: 5002 http://hugin.svn.sourceforge.net/hugin/?rev=5002&view=rev Author: tmodes Date: 2010-02-20 08:37:42 +0000 (Sat, 20 Feb 2010) Log Message: ----------- Better calculation of positive masks for non-overlapping images Modified Paths: -------------- hugin/trunk/src/hugin_base/panodata/Panorama.cpp Modified: hugin/trunk/src/hugin_base/panodata/Panorama.cpp =================================================================== --- hugin/trunk/src/hugin_base/panodata/Panorama.cpp 2010-02-20 07:42:53 UTC (rev 5001) +++ hugin/trunk/src/hugin_base/panodata/Panorama.cpp 2010-02-20 08:37:42 UTC (rev 5002) @@ -1030,18 +1030,27 @@ { if(i==k) continue; - //transform polygon in image space of other image - MaskPolygon targetMask=transformedMask; - PTools::Transform targetTrans; - targetTrans.createTransform(getImage(k),getOptions()); - targetMask.transformPolygon(targetTrans); - //now clip polygon to image rectangle, add mask only when polygon is inside image - if(targetMask.clipPolygon(vigra::Rect2D(-maskOffset,-maskOffset, - state.images[k]->getWidth()+maskOffset,state.images[k]->getHeight()+maskOffset))) + //check if images are overlapping + double maxShift = std::max(state.images[i]->getHFOV(),state.images[k]->getHFOV())*1.2; + double minShiftYaw = 360.0 - maxShift; + double minShiftPitch = 180.0 - maxShift; + double diffYaw=fabs(state.images[i]->getYaw()-state.images[k]->getYaw()); + double diffPitch=fabs(state.images[i]->getPitch()-state.images[k]->getPitch()); + if((diffYaw<maxShift || diffYaw>minShiftYaw) && (diffPitch<maxShift || diffPitch>minShiftPitch)) { - targetMask.setMaskType(MaskPolygon::Mask_negative); - targetMask.setImgNr(k); - state.images[k]->addActiveMask(targetMask); + //transform polygon in image space of other image only if images are overlapping + MaskPolygon targetMask=transformedMask; + PTools::Transform targetTrans; + targetTrans.createTransform(getImage(k),getOptions()); + targetMask.transformPolygon(targetTrans); + //now clip polygon to image rectangle, add mask only when polygon is inside image + if(targetMask.clipPolygon(vigra::Rect2D(-maskOffset,-maskOffset, + state.images[k]->getWidth()+maskOffset,state.images[k]->getHeight()+maskOffset))) + { + targetMask.setMaskType(MaskPolygon::Mask_negative); + targetMask.setImgNr(k); + state.images[k]->addActiveMask(targetMask); + }; }; }; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |