27 #include "../common/progress/TaskProgress.h"
28 #include "../sam/rtree.h"
32 #include <boost/shared_array.hpp>
54 == 1,
"Invalid number of raster 1 bands" );
56 == 1,
"Invalid number of raster 2 bands" );
59 "Invalid m_surfScalesNumber" );
62 "Invalid m_surfOctavesNumber" );
66 "Invalid m_surfMaxNormEuclideanDist" );
88 const double raster1ToRaster2TransfDMapError,
91 matchedInterestPoints.clear();
101 double raster1XRescFact = 1.0;
102 double raster1YRescFact = 1.0;
103 double raster2XRescFact = 1.0;
104 double raster2YRescFact = 1.0;
157 const double area1 = width1 * height1;
158 const double area2 = width2 * height2;
162 maxInterestPoints1 = (
unsigned int)( ((
double)maxInterestPoints1)*( area1 / area2 ) );
166 maxInterestPoints2 = (
unsigned int)( ((
double)maxInterestPoints2)*( area2 / area1 ) );
172 std::auto_ptr< te::common::TaskProgress > progressPtr;
176 progressPtr->setTotalSteps( 10 );
177 progressPtr->setMessage(
"Locating tie points" );
178 progressPtr->pulse();
179 if( ! progressPtr->isActive() )
return false;
189 std::vector< boost::shared_ptr< FloatsMatrix > > rasterData;
191 double achievedRescaleFactorX = 0;
192 double achievedRescaleFactorY = 0;
209 achievedRescaleFactorX,
210 achievedRescaleFactorY ) )
215 raster1XRescFact = achievedRescaleFactorX;
216 raster1YRescFact = achievedRescaleFactorY;
223 progressPtr->pulse();
224 if( ! progressPtr->isActive() )
return false;
232 integralRaster ),
"Integral image creation error" );
238 progressPtr->pulse();
239 if( ! progressPtr->isActive() )
return false;
251 raster1InterestPoints ),
252 "Error locating raster 1 interest points" );
258 progressPtr->pulse();
259 if( ! progressPtr->isActive() )
return false;
266 integralRaster, validInterestPoints, raster1Features ),
267 "Error generating raster features" );
271 raster1InterestPoints.clear();
274 InterestPointsSetT::iterator itB = validInterestPoints.begin();
275 const InterestPointsSetT::iterator itE = validInterestPoints.end();
281 auxIP.
m_x = ( auxIP.
m_x / raster1XRescFact ) +
283 auxIP.
m_y = ( auxIP.
m_y / raster1YRescFact ) +
286 raster1InterestPoints.insert( auxIP );
294 progressPtr->pulse();
295 if( ! progressPtr->isActive() )
return false;
307 std::vector< boost::shared_ptr< FloatsMatrix > > rasterData;
309 double achievedRescaleFactorX = 0;
310 double achievedRescaleFactorY = 0;
327 achievedRescaleFactorX,
328 achievedRescaleFactorY ) )
333 raster2XRescFact = achievedRescaleFactorX;
334 raster2YRescFact = achievedRescaleFactorY;
341 progressPtr->pulse();
342 if( ! progressPtr->isActive() )
return false;
350 integralRaster ),
"Integral image creation error" );
354 progressPtr->pulse();
355 if( ! progressPtr->isActive() )
return false;
369 raster2InterestPoints ),
370 "Error locating raster interest points" );
376 progressPtr->pulse();
377 if( ! progressPtr->isActive() )
return false;
383 integralRaster, validInterestPoints, raster2Features ),
384 "Error generating raster features" );
388 raster2InterestPoints.clear();
391 InterestPointsSetT::iterator itB = validInterestPoints.begin();
392 const InterestPointsSetT::iterator itE = validInterestPoints.end();
398 auxIP.
m_x = ( auxIP.
m_x / raster2XRescFact ) +
400 auxIP.
m_y = ( auxIP.
m_y / raster2YRescFact ) +
403 raster2InterestPoints.insert( auxIP );
411 progressPtr->pulse();
412 if( ! progressPtr->isActive() )
return false;
426 raster1InterestPoints,
427 raster2InterestPoints,
428 raster1ToRaster2TransfPtr,
429 raster1ToRaster2TransfDMapError,
430 internalMatchedInterestPoints ),
431 "Error matching features" );
435 progressPtr->pulse();
436 if( ! progressPtr->isActive() )
return false;
443 MatchedInterestPointsSetT::iterator it1 = internalMatchedInterestPoints.begin();
444 MatchedInterestPointsSetT::iterator it2;
445 MatchedInterestPointsSetT::iterator eraseIt;
447 while( it1 != internalMatchedInterestPoints.end() )
451 eraseIt = internalMatchedInterestPoints.end();
453 while( it2 != internalMatchedInterestPoints.end() )
456 ( it1->m_point1.m_x == it2->m_point1.m_x )
458 ( it1->m_point1.m_y == it2->m_point1.m_y )
460 ( it1->m_point2.m_x == it2->m_point2.m_x )
462 ( it1->m_point2.m_y == it2->m_point2.m_y )
465 if( it1->m_feature < it2->m_feature )
469 else if( it1->m_feature > it2->m_feature )
485 internalMatchedInterestPoints.erase( eraseIt );
487 else if( eraseIt != internalMatchedInterestPoints.end() )
489 internalMatchedInterestPoints.erase( eraseIt );
503 internalMatchedInterestPoints.erase( internalMatchedInterestPoints.begin() );
510 MatchedInterestPointsSetT::const_iterator itB = internalMatchedInterestPoints.begin();
511 const MatchedInterestPointsSetT::const_iterator itE = internalMatchedInterestPoints.end();
513 float minFeature1P1 = FLT_MAX;
514 float maxFeature1P1 = (-1.0) * FLT_MAX;
515 float minFeature1P2 = FLT_MAX;
516 float maxFeature1P2 = (-1.0) * FLT_MAX;
517 float minDist = FLT_MAX;
518 float maxDist = (-1.0 ) *FLT_MAX;
522 if( minFeature1P1 > itB->m_point1.m_feature1 )
524 if( maxFeature1P1 < itB->m_point1.m_feature1 )
525 maxFeature1P1 = itB->m_point1.m_feature1;
527 if( minFeature1P2 > itB->m_point2.m_feature1 )
528 minFeature1P2 = itB->m_point2.m_feature1;
529 if( maxFeature1P2 < itB->m_point2.m_feature1 )
530 maxFeature1P2 = itB->m_point2.m_feature1;
532 if( minDist > itB->m_feature )
533 minDist = itB->m_feature;
534 if( maxDist < itB->m_feature )
535 maxDist = itB->m_feature;
540 float feature1P1Range = maxFeature1P1 - minFeature1P1;
541 float feature1P2Range = maxFeature1P2 - minFeature1P2;
542 float distRange = maxDist - minDist;
544 if( ( feature1P1Range == 0.0 ) || ( feature1P2Range == 0.0 ) ||
545 ( distRange == 0.0 ) )
547 itB = internalMatchedInterestPoints.begin();
551 auxMatchedPoints = *itB;
554 matchedInterestPoints.insert( auxMatchedPoints );
561 itB = internalMatchedInterestPoints.begin();
565 auxMatchedPoints = *itB;
589 matchedInterestPoints.insert( auxMatchedPoints );
603 unsigned int returnValue = 0;
605 const unsigned int maxRastersArea = (
unsigned int)
632 returnValue = maxRastersArea /
633 ( filterWindowSize * filterWindowSize );
640 const double freeVMem = 0.4 * std::min( totalPhysMem, ( totalVMem - usedVMem ) );
642 const double featureElementsNumber = 65 * 65;
644 double maxFeaturesMemory =
649 (-2.0) * featureElementsNumber
652 ( 4.0 * featureElementsNumber * featureElementsNumber )
654 ( 4.0 * freeVMem / ((
double)
sizeof(
float ) ) )
663 (-2.0) * featureElementsNumber
666 ( 4.0 * featureElementsNumber * featureElementsNumber )
668 ( 4.0 * freeVMem / ((
double)
sizeof(
float ) ) )
673 returnValue = std::min( returnValue, (
unsigned int)maxFeaturesMemory );
687 unsigned int outCol = 0;
690 for(
unsigned int outLine = 0 ; outLine < nLines ; ++outLine )
691 for( outCol = 0; outCol < nCols ; ++outCol )
693 currSum = inputData[ outLine ][ outCol ];
696 currSum += outputData[ outLine - 1 ][ outCol ];
698 currSum += outputData[ outLine ][ outCol - 1 ];
699 if( outLine && outCol )
700 currSum -= outputData[ outLine - 1 ][ outCol - 1 ];
702 outputData[ outLine ][ outCol ] = currSum;
709 const unsigned int maxInterestPoints,
714 interestPoints.clear();
720 || ( integralRasterData.
getLinesNumber() < minIntegralRasterWidthHeigh ) )
727 bool returnValue =
true;
728 boost::mutex rastaDataAccessMutex;
729 boost::mutex interestPointsAccessMutex;
730 unsigned int nextRasterLinesBlockToProcess = 0;
731 std::vector< InterestPointsSetT > interestPointsSubSectors(
740 &nextRasterLinesBlockToProcess;
755 boost::thread_group threads;
760 threads.add_thread(
new boost::thread(
776 const unsigned int interestPointsSubSectorsSize = interestPointsSubSectors.size();
778 for(
unsigned int interestPointsSubSectorsIdx = 0 ; interestPointsSubSectorsIdx <
779 interestPointsSubSectorsSize ; ++interestPointsSubSectorsIdx )
781 interestPoints.insert(
782 interestPointsSubSectors[ interestPointsSubSectorsIdx ].begin(),
783 interestPointsSubSectors[ interestPointsSubSectorsIdx ].end() );
810 const unsigned int maxGausFilterRadius = maxGausFilterWidth / 2;
811 const unsigned int rasterBuffersLinesNumber = maxGausFilterWidth;
812 const unsigned int lastRasterBuffersLineIdx = rasterBuffersLinesNumber - 1;
814 const unsigned int rowsBySubSector = (
unsigned int)std::ceil(
817 ((
double)tiePointsSubSectorsSplitFactor) );
818 const unsigned int colsBySubSector = (
unsigned int)std::ceil(
821 ((
double)tiePointsSubSectorsSplitFactor) );
823 const unsigned int maxInterestPointsByScaleSubSector = maxInterestPointsBySubSector
827 const unsigned int rasterBufferLineSizeBytes =
sizeof( float ) *
832 const unsigned int maxLinesPerProcessingBlock = (
unsigned int)
834 ((
double)rasterLines)
836 ((
double)processingBlocksNumber)
844 boost::scoped_array< float* > rasterBufferHandler(
new float*[ rasterBuffersLinesNumber ] );
846 if( ! rasterBufferDataHandler.
reset( rasterBuffersLinesNumber, buffersCols,
855 for(
unsigned int rasterBufferDataHandlerLine = 0 ; rasterBufferDataHandlerLine <
856 rasterBuffersLinesNumber ; ++rasterBufferDataHandlerLine )
858 rasterBufferHandler[ rasterBufferDataHandlerLine ] = rasterBufferDataHandler[
859 rasterBufferDataHandlerLine ];
862 float** rasterBufferPtr = rasterBufferHandler.get();
868 boost::scoped_array< unsigned char* > maskRasterBufferHandler(
new unsigned char*[ rasterBuffersLinesNumber ] );
870 unsigned char** maskRasterBufferPtr = 0;
874 if( ! maskRasterBufferDataHandler.
reset( rasterBuffersLinesNumber, buffersCols,
883 for(
unsigned int maskRasterBufferDataHandlerLine = 0 ; maskRasterBufferDataHandlerLine <
884 rasterBuffersLinesNumber ; ++maskRasterBufferDataHandlerLine )
886 maskRasterBufferHandler[ maskRasterBufferDataHandlerLine ] = maskRasterBufferDataHandler[
887 maskRasterBufferDataHandlerLine ];
890 maskRasterBufferPtr = maskRasterBufferHandler.get();
896 std::vector< std::vector< boost::shared_array< float* > > >
897 octavesBufferHandlers;
899 const unsigned int octavesBufferDataHandlerLines =
901 if( ! octavesBufferDataHandler.
reset( octavesBufferDataHandlerLines ,
910 unsigned int octavesBufferDataHandlerLine = 0;
911 unsigned int octavesBufferDataHandlerCol = 0;
912 float* octavesBufferDataHandlerLinePtr = 0;
913 for( octavesBufferDataHandlerLine = 0; octavesBufferDataHandlerLine <
914 octavesBufferDataHandlerLines ; ++octavesBufferDataHandlerLine )
916 octavesBufferDataHandlerLinePtr = octavesBufferDataHandler[
917 octavesBufferDataHandlerLine ];
919 for( octavesBufferDataHandlerCol = 0; octavesBufferDataHandlerCol <
920 buffersCols ; ++octavesBufferDataHandlerCol )
922 octavesBufferDataHandlerLinePtr[ octavesBufferDataHandlerCol ] = 0.0;
926 octavesBufferDataHandlerLine = 0;
927 unsigned int scaleIdx = 0 ;
928 unsigned int octaveIdx = 0 ;
929 for( octaveIdx = 0 ; octaveIdx < paramsPtr->
m_octavesNumber ; ++octaveIdx )
931 octavesBufferHandlers.push_back( std::vector< boost::shared_array< float* > >() );
932 std::vector< boost::shared_array< float* > >&
933 currOctaveBuffersHandler = octavesBufferHandlers[ octaveIdx ];
935 for( scaleIdx = 0 ; scaleIdx < paramsPtr->
m_scalesNumber ; ++scaleIdx )
937 currOctaveBuffersHandler.push_back( boost::shared_array< float* >(
939 boost::shared_array< float* >& currOctavesBuffer =
940 currOctaveBuffersHandler[ scaleIdx ];
941 for(
unsigned int bufferLine = 0 ; bufferLine < 3 ; ++bufferLine )
943 assert( octavesBufferDataHandlerLine <
946 currOctavesBuffer[ bufferLine ] = octavesBufferDataHandler[
947 octavesBufferDataHandlerLine ];
949 ++octavesBufferDataHandlerLine;
958 std::vector< std::vector< boost::shared_array< unsigned char* > > >
959 laplacianSignBufferHandlers;
961 const unsigned int laplacianSignBufferDataHandlerLines =
963 if( ! laplacianSignBufferDataHandler.
reset( laplacianSignBufferDataHandlerLines ,
972 unsigned int laplacianSignBufferDataHandlerLine = 0;
973 unsigned int laplacianSignBufferDataHandlerCol = 0;
974 unsigned char* laplacianSignBufferDataHandlerLinePtr = 0;
975 for( laplacianSignBufferDataHandlerLine = 0; laplacianSignBufferDataHandlerLine <
976 laplacianSignBufferDataHandlerLines ; ++laplacianSignBufferDataHandlerLine )
978 laplacianSignBufferDataHandlerLinePtr = laplacianSignBufferDataHandler[
979 laplacianSignBufferDataHandlerLine ];
981 for( laplacianSignBufferDataHandlerCol = 0; laplacianSignBufferDataHandlerCol <
982 buffersCols ; ++laplacianSignBufferDataHandlerCol )
984 laplacianSignBufferDataHandlerLinePtr[ laplacianSignBufferDataHandlerCol ] =
989 laplacianSignBufferDataHandlerLine = 0;
990 unsigned int scaleIdx = 0 ;
991 unsigned int octaveIdx = 0 ;
992 for( octaveIdx = 0 ; octaveIdx < paramsPtr->
m_octavesNumber ; ++octaveIdx )
994 laplacianSignBufferHandlers.push_back( std::vector< boost::shared_array< unsigned char* > >() );
995 std::vector< boost::shared_array< unsigned char* > >&
996 currlaplacianSignBuffersHandler = laplacianSignBufferHandlers[ octaveIdx ];
998 for( scaleIdx = 0 ; scaleIdx < paramsPtr->
m_scalesNumber ; ++scaleIdx )
1000 currlaplacianSignBuffersHandler.push_back( boost::shared_array< unsigned char* >(
1001 new unsigned char*[ 3 ] ) );
1002 boost::shared_array< unsigned char* >& currlaplacianSignBuffer =
1003 currlaplacianSignBuffersHandler[ scaleIdx ];
1004 for(
unsigned int bufferLine = 0 ; bufferLine < 3 ; ++bufferLine )
1006 assert( laplacianSignBufferDataHandlerLine <
1009 currlaplacianSignBuffer[ bufferLine ] = laplacianSignBufferDataHandler[
1010 laplacianSignBufferDataHandlerLine ];
1012 ++laplacianSignBufferDataHandlerLine;
1020 const unsigned maxGausResponseFilterCenterBufferColBound = buffersCols -
1021 maxGausFilterRadius;
1022 const unsigned maxMaximaDetectionCenterBufferColBound = buffersCols -
1023 maxGausFilterRadius - 1;
1025 unsigned int scaleIdx = 0 ;
1026 unsigned int octaveIdx = 0 ;
1027 unsigned int subSectorIndex = 0;
1028 unsigned int scaleGlobalIndex = 0;
1030 std::vector< std::vector< InterestPointsSetT > > interestPointsSubSectors;
1032 std::vector< InterestPointsSetT > dummyIPointsContainer(
1039 for(
unsigned int rasterLinesBlockIdx = 0; rasterLinesBlockIdx <
1040 processingBlocksNumber ; ++rasterLinesBlockIdx )
1044 std::vector< InterestPointsSetT > blockMaximas( paramsPtr->
m_scalesNumber *
1057 const unsigned int rasterLinesStart =
1063 ((
int)(rasterLinesBlockIdx * maxLinesPerProcessingBlock ))
1065 ((
int)maxGausFilterRadius)
1070 const unsigned int rasterLinesEndBound =
1075 ( ( rasterLinesBlockIdx + 1 ) * maxLinesPerProcessingBlock )
1082 const unsigned int firstRasterLineToGenerateResponse =
1083 rasterLinesStart + maxGausFilterWidth - 1;
1084 const unsigned int firstRasterLineToLookForMaximas =
1085 rasterLinesStart + maxGausFilterWidth + 1;
1086 unsigned int filterWidth = 0;
1087 unsigned int filterLobeWidth = 0;
1088 unsigned int filterLobeRadius = 0;
1089 unsigned int filterCenterBufCol = 0 ;
1094 float** currScaleBufferPtr = 0;
1095 unsigned char** currLaplacianSignBufferPtr = 0;
1096 unsigned int lastScaleIdx = 0;
1097 unsigned int nextScaleIdx = 0;
1098 unsigned int prevResponseBufferColIdx = 0;
1099 unsigned int nextResponseBufferColIdx = 0;
1100 float windowCenterPixelValue = 0.0;
1101 float neighborMaximaDif_0_1 = 0.0;
1102 float neighborMaximaDif_0_2 = 0.0;
1103 float neighborMaximaDif_0_3 = 0.0;
1104 float neighborMaximaDif_0_4 = 0.0;
1105 float neighborMaximaDif_0_5 = 0.0;
1106 float neighborMaximaDif_0_6 = 0.0;
1107 float neighborMaximaDif_0_7 = 0.0;
1108 float neighborMaximaDif_0_8 = 0.0;
1109 float neighborMaximaDif_1_1 = 0.0;
1110 float neighborMaximaDif_1_2 = 0.0;
1111 float neighborMaximaDif_1_3 = 0.0;
1112 float neighborMaximaDif_1_4 = 0.0;
1113 float neighborMaximaDif_1_5 = 0.0;
1114 float neighborMaximaDif_1_6 = 0.0;
1115 float neighborMaximaDif_1_7 = 0.0;
1116 float neighborMaximaDif_1_8 = 0.0;
1117 float neighborMaximaDif_1_9 = 0.0;
1118 float neighborMaximaDif_2_1 = 0.0;
1119 float neighborMaximaDif_2_2 = 0.0;
1120 float neighborMaximaDif_2_3 = 0.0;
1121 float neighborMaximaDif_2_4 = 0.0;
1122 float neighborMaximaDif_2_5 = 0.0;
1123 float neighborMaximaDif_2_6 = 0.0;
1124 float neighborMaximaDif_2_7 = 0.0;
1125 float neighborMaximaDif_2_8 = 0.0;
1126 float neighborMaximaDif_2_9 = 0.0;
1130 for(
unsigned int rasterLine = rasterLinesStart; rasterLine < rasterLinesEndBound ;
1137 roolUpBuffer( rasterBufferPtr, rasterBuffersLinesNumber );
1139 memcpy( rasterBufferPtr[ lastRasterBuffersLineIdx ],
1141 rasterBufferLineSizeBytes );
1146 roolUpBuffer( maskRasterBufferPtr, rasterBuffersLinesNumber );
1147 memcpy( maskRasterBufferPtr[ lastRasterBuffersLineIdx ],
1149 maskRasterBufferLineSizeBytes );
1155 if( rasterLine >= firstRasterLineToGenerateResponse )
1157 for( octaveIdx = 0 ; octaveIdx < paramsPtr->
m_octavesNumber ; ++octaveIdx )
1162 assert( octavesBufferHandlers.size() > octaveIdx );
1163 assert( octavesBufferHandlers[ octaveIdx].size() > scaleIdx );
1164 currScaleBufferPtr = octavesBufferHandlers[ octaveIdx][ scaleIdx ].get();
1165 assert( currScaleBufferPtr );
1167 assert( laplacianSignBufferHandlers.size() > octaveIdx );
1168 assert( laplacianSignBufferHandlers[ octaveIdx].size() > scaleIdx );
1169 currLaplacianSignBufferPtr = laplacianSignBufferHandlers[ octaveIdx][ scaleIdx ].get();
1170 assert( currLaplacianSignBufferPtr );
1180 assert( filterWidth <= maxGausFilterWidth );
1182 filterLobeWidth = filterWidth / 3;
1183 filterLobeRadius = filterLobeWidth / 2;
1185 for( filterCenterBufCol = maxGausFilterRadius ;
1186 filterCenterBufCol < maxGausResponseFilterCenterBufferColBound ;
1187 ++filterCenterBufCol )
1190 maxGausFilterRadius, filterLobeWidth, filterLobeRadius);
1191 dYY /= (float)( filterWidth * filterWidth );
1194 maxGausFilterRadius, filterLobeWidth, filterLobeRadius);
1195 dXX /= (float)( filterWidth * filterWidth );
1198 maxGausFilterRadius, filterLobeWidth );
1199 dXY /= (float)( filterWidth * filterWidth );
1201 currScaleBufferPtr[ 2 ][ filterCenterBufCol ] =
1202 ( dXX * dYY ) - ( 0.81f * dXY * dXY );
1203 currLaplacianSignBufferPtr[ 2 ][ filterCenterBufCol ] =
1204 ( ( dXX + dYY ) >= 0.0 ) ? 1 : 0;
1213 if( rasterLine >= firstRasterLineToLookForMaximas )
1220 for(
unsigned int windCenterCol = maxGausFilterRadius + 1;
1221 windCenterCol < maxMaximaDetectionCenterBufferColBound ; ++windCenterCol )
1223 prevResponseBufferColIdx = windCenterCol - 1;
1224 nextResponseBufferColIdx = windCenterCol + 1;
1225 auxInterestPoint.
m_feature1 = (-1.0) * FLT_MAX;
1227 for( octaveIdx = 0 ; octaveIdx < paramsPtr->
m_octavesNumber ; ++octaveIdx )
1229 std::vector< boost::shared_array< float* > >&
1230 currOctaveBuffersHandler = octavesBufferHandlers[ octaveIdx ];
1232 for( scaleIdx = 1 ; scaleIdx < ( paramsPtr->
m_scalesNumber - 1 );
1235 windowCenterPixelValue = currOctaveBuffersHandler[
1236 scaleIdx ][ 1 ][ windCenterCol ];
1237 lastScaleIdx = scaleIdx - 1;
1238 nextScaleIdx = scaleIdx + 1;
1240 neighborMaximaDif_0_1 = windowCenterPixelValue - currOctaveBuffersHandler[
1241 scaleIdx ][ 0 ][ prevResponseBufferColIdx ];
1242 neighborMaximaDif_0_2 = windowCenterPixelValue - currOctaveBuffersHandler[
1243 scaleIdx ][ 0 ][ windCenterCol ];
1244 neighborMaximaDif_0_3 = windowCenterPixelValue - currOctaveBuffersHandler[
1245 scaleIdx ][ 0 ][ nextResponseBufferColIdx ];
1246 neighborMaximaDif_0_4 = windowCenterPixelValue - currOctaveBuffersHandler[
1247 scaleIdx ][ 1 ][ prevResponseBufferColIdx ];
1248 neighborMaximaDif_0_5 = windowCenterPixelValue - currOctaveBuffersHandler[
1249 scaleIdx ][ 1 ][ nextResponseBufferColIdx ];
1250 neighborMaximaDif_0_6 = windowCenterPixelValue - currOctaveBuffersHandler[
1251 scaleIdx ][ 2 ][ prevResponseBufferColIdx];
1252 neighborMaximaDif_0_7 = windowCenterPixelValue - currOctaveBuffersHandler[
1253 scaleIdx ][ 2 ][ windCenterCol ];
1254 neighborMaximaDif_0_8 = windowCenterPixelValue - currOctaveBuffersHandler[
1255 scaleIdx ][ 2 ][ nextResponseBufferColIdx ];
1258 ( windowCenterPixelValue > 0.0 )
1260 && ( neighborMaximaDif_0_1 > 0.0 )
1261 && ( neighborMaximaDif_0_2 > 0.0 )
1262 && ( neighborMaximaDif_0_3 > 0.0 )
1263 && ( neighborMaximaDif_0_4 > 0.0 )
1264 && ( neighborMaximaDif_0_5 > 0.0 )
1265 && ( neighborMaximaDif_0_6 > 0.0 )
1266 && ( neighborMaximaDif_0_7 > 0.0 )
1267 && ( neighborMaximaDif_0_8 > 0.0 )
1270 neighborMaximaDif_1_1 = windowCenterPixelValue - currOctaveBuffersHandler[
1271 lastScaleIdx ][ 0 ][ prevResponseBufferColIdx ];
1272 neighborMaximaDif_1_2 = windowCenterPixelValue - currOctaveBuffersHandler[
1273 lastScaleIdx ][ 0 ][ windCenterCol ];
1274 neighborMaximaDif_1_3 = windowCenterPixelValue - currOctaveBuffersHandler[
1275 lastScaleIdx ][ 0 ][ nextResponseBufferColIdx ];
1276 neighborMaximaDif_1_4 = windowCenterPixelValue - currOctaveBuffersHandler[
1277 lastScaleIdx ][ 1 ][ prevResponseBufferColIdx ];
1278 neighborMaximaDif_1_5 = windowCenterPixelValue - currOctaveBuffersHandler[
1279 lastScaleIdx ][ 1 ][ windCenterCol ];
1280 neighborMaximaDif_1_6 = windowCenterPixelValue - currOctaveBuffersHandler[
1281 lastScaleIdx ][ 1 ][ nextResponseBufferColIdx ];
1282 neighborMaximaDif_1_7 = windowCenterPixelValue - currOctaveBuffersHandler[
1283 lastScaleIdx ][ 2 ][ prevResponseBufferColIdx];
1284 neighborMaximaDif_1_8 = windowCenterPixelValue - currOctaveBuffersHandler[
1285 lastScaleIdx ][ 2 ][ windCenterCol ];
1286 neighborMaximaDif_1_9 = windowCenterPixelValue - currOctaveBuffersHandler[
1287 lastScaleIdx ][ 2 ][ nextResponseBufferColIdx ];
1291 ( neighborMaximaDif_1_1 > 0.0 )
1292 && ( neighborMaximaDif_1_2 > 0.0 )
1293 && ( neighborMaximaDif_1_3 > 0.0 )
1294 && ( neighborMaximaDif_1_4 > 0.0 )
1295 && ( neighborMaximaDif_1_5 > 0.0 )
1296 && ( neighborMaximaDif_1_6 > 0.0 )
1297 && ( neighborMaximaDif_1_7 > 0.0 )
1298 && ( neighborMaximaDif_1_8 > 0.0 )
1299 && ( neighborMaximaDif_1_9 > 0.0 )
1302 neighborMaximaDif_2_1 = windowCenterPixelValue - currOctaveBuffersHandler[
1303 nextScaleIdx ][ 0 ][ prevResponseBufferColIdx ];
1304 neighborMaximaDif_2_2 = windowCenterPixelValue - currOctaveBuffersHandler[
1305 nextScaleIdx ][ 0 ][ windCenterCol ];
1306 neighborMaximaDif_2_3 = windowCenterPixelValue - currOctaveBuffersHandler[
1307 nextScaleIdx ][ 0 ][ nextResponseBufferColIdx ];
1308 neighborMaximaDif_2_4 = windowCenterPixelValue - currOctaveBuffersHandler[
1309 nextScaleIdx ][ 1 ][ prevResponseBufferColIdx ];
1310 neighborMaximaDif_2_5 = windowCenterPixelValue - currOctaveBuffersHandler[
1311 nextScaleIdx ][ 1 ][ windCenterCol ];
1312 neighborMaximaDif_2_6 = windowCenterPixelValue - currOctaveBuffersHandler[
1313 nextScaleIdx ][ 1 ][ nextResponseBufferColIdx ];
1314 neighborMaximaDif_2_7 = windowCenterPixelValue - currOctaveBuffersHandler[
1315 nextScaleIdx ][ 2 ][ prevResponseBufferColIdx];
1316 neighborMaximaDif_2_8 = windowCenterPixelValue - currOctaveBuffersHandler[
1317 nextScaleIdx ][ 2 ][ windCenterCol ];
1318 neighborMaximaDif_2_9 = windowCenterPixelValue - currOctaveBuffersHandler[
1319 nextScaleIdx ][ 2 ][ nextResponseBufferColIdx ];
1323 ( neighborMaximaDif_2_1 > 0.0 )
1324 && ( neighborMaximaDif_2_2 > 0.0 )
1325 && ( neighborMaximaDif_2_3 > 0.0 )
1326 && ( neighborMaximaDif_2_4 > 0.0 )
1327 && ( neighborMaximaDif_2_5 > 0.0 )
1328 && ( neighborMaximaDif_2_6 > 0.0 )
1329 && ( neighborMaximaDif_2_7 > 0.0 )
1330 && ( neighborMaximaDif_2_8 > 0.0 )
1331 && ( neighborMaximaDif_2_9 > 0.0 )
1335 ( maskRasterBufferPtr[ 0 ][ windCenterCol ] != 0 )
1342 neighborMaximaDif_0_1
1343 + neighborMaximaDif_0_2
1344 + neighborMaximaDif_0_3
1345 + neighborMaximaDif_0_4
1346 + neighborMaximaDif_0_5
1347 + neighborMaximaDif_0_6
1348 + neighborMaximaDif_0_7
1349 + neighborMaximaDif_0_8
1350 + neighborMaximaDif_1_1
1351 + neighborMaximaDif_1_2
1352 + neighborMaximaDif_1_3
1353 + neighborMaximaDif_1_4
1354 + neighborMaximaDif_1_5
1355 + neighborMaximaDif_1_6
1356 + neighborMaximaDif_1_7
1357 + neighborMaximaDif_1_8
1358 + neighborMaximaDif_1_9
1359 + neighborMaximaDif_2_1
1360 + neighborMaximaDif_2_2
1361 + neighborMaximaDif_2_3
1362 + neighborMaximaDif_2_4
1363 + neighborMaximaDif_2_5
1364 + neighborMaximaDif_2_6
1365 + neighborMaximaDif_2_7
1366 + neighborMaximaDif_2_8
1367 + neighborMaximaDif_2_9;
1369 octaveIdx, scaleIdx );
1371 laplacianSignBufferHandlers[ octaveIdx ][ scaleIdx ][
1372 1 ][ windCenterCol ] ;
1374 auxInterestPoint.
m_x = windCenterCol;
1375 auxInterestPoint.
m_y = rasterLine - maxGausFilterRadius - 1;
1376 assert( auxInterestPoint.
m_x <
1378 assert( auxInterestPoint.
m_y <
1381 scaleGlobalIndex = ( octaveIdx *
1383 subSectorIndex = ( ( auxInterestPoint.
m_y /
1384 rowsBySubSector ) * tiePointsSubSectorsSplitFactor ) +
1385 ( auxInterestPoint.
m_x / colsBySubSector );
1386 assert( scaleGlobalIndex < interestPointsSubSectors.size() );
1387 assert( subSectorIndex < interestPointsSubSectors[ scaleGlobalIndex ].size() );
1389 interestPointsSubSectors[ scaleGlobalIndex ][
1390 subSectorIndex ].insert( auxInterestPoint);
1392 if( interestPointsSubSectors[ scaleGlobalIndex ][
1393 subSectorIndex ].size() > maxInterestPointsByScaleSubSector )
1395 interestPointsSubSectors[ scaleGlobalIndex ][
1396 subSectorIndex ].erase( interestPointsSubSectors[
1397 scaleGlobalIndex ][ subSectorIndex ].begin() );
1417 for( scaleGlobalIndex = 0 ; scaleGlobalIndex < interestPointsSubSectors.size() ;
1418 ++scaleGlobalIndex )
1420 for( subSectorIndex = 0 ; subSectorIndex < interestPointsSubSectors[
1421 scaleGlobalIndex ].size() ; ++subSectorIndex )
1425 interestPointsSubSectors[ scaleGlobalIndex ][ subSectorIndex ], x, y ),
1426 "Duplicated tie-points" );
1429 subSectorIndex ).
insert( interestPointsSubSectors[
1430 scaleGlobalIndex ][ subSectorIndex ].begin(),
1431 interestPointsSubSectors[ scaleGlobalIndex ][ subSectorIndex ].end() );
1434 subSectorIndex ).size() >
1435 maxInterestPointsBySubSector )
1438 subSectorIndex ).erase(
1440 subSectorIndex ).begin() );
1457 validInterestPoints.clear();
1460 InterestPointsSetT::const_iterator iPointsIt = interestPoints.begin();
1461 const InterestPointsSetT::const_iterator iPointsItEnd = interestPoints.end();
1463 while( iPointsIt != iPointsItEnd )
1467 const unsigned int& currIPointCenterX = iPointsIt->m_x;
1468 const unsigned int& currIPointCenterY = iPointsIt->m_y;
1469 const float currIPointScale = 1.2f * iPointsIt->m_feature2 / 9.0f;
1471 unsigned int featureWindowWidth = (
unsigned int)( 20.0 * currIPointScale );
1472 featureWindowWidth += ( ( featureWindowWidth % 2 ) ? 0 : 1 );
1474 const unsigned int feature90DegreeRotatedWindowRadius = (
unsigned int)
1481 ( (
double)featureWindowWidth )
1483 ( (double)featureWindowWidth )
1489 const unsigned int featureElementHaarWindowRadius =
1490 ((
unsigned int)( 2.0 * currIPointScale )) / 2;
1492 const unsigned int currIPointCenterXAllowedMin = featureElementHaarWindowRadius +
1493 feature90DegreeRotatedWindowRadius + 1;
1494 const unsigned int currIPointCenterXAllowedMax = integralRasterData.
getColumnsNumber() -
1495 currIPointCenterXAllowedMin - 1;
1496 const unsigned int currIPointCenterYAllowedMin = currIPointCenterXAllowedMin;
1497 const unsigned int currIPointCenterYAllowedMax = integralRasterData.
getLinesNumber() -
1498 currIPointCenterXAllowedMin - 1;
1500 if( ( currIPointCenterX > currIPointCenterXAllowedMin ) &&
1501 ( currIPointCenterX < currIPointCenterXAllowedMax ) &&
1502 ( currIPointCenterY > currIPointCenterYAllowedMin ) &&
1503 ( currIPointCenterY < currIPointCenterYAllowedMax ) )
1506 validInterestPoints.insert( *iPointsIt );
1514 "Cannot allocate features matrix" );
1518 float auxFeaturesBuffer[ 128 ];
1522 InterestPointsSetT::const_iterator iPointsIt = validInterestPoints.begin();
1523 const InterestPointsSetT::const_iterator iPointsItEnd = validInterestPoints.end();
1524 unsigned int interestPointIdx = 0;
1525 while( iPointsIt != iPointsItEnd )
1529 const unsigned int& currIPointCenterX = iPointsIt->m_x;
1530 const unsigned int& currIPointCenterY = iPointsIt->m_y;
1531 const float currIPointScale = 1.2f * iPointsIt->m_feature2 / 9.0f;
1533 unsigned int featureWindowWidth = (
unsigned int)( 20.0 * currIPointScale );
1534 featureWindowWidth += ( ( featureWindowWidth % 2 ) ? 0 : 1 );
1536 const unsigned int featureWindowRadius = featureWindowWidth / 2;
1537 const float featureWindowRadiusDouble = (float)featureWindowRadius;
1539 const unsigned int featureSubWindowWidth = featureWindowWidth / 4;
1541 const unsigned int featureElementHaarWindowRadius =
1542 ((
unsigned int)( 2.0 * currIPointScale )) / 2;
1544 const unsigned int featureWindowRasterXStart = currIPointCenterX -
1545 featureWindowRadius;
1546 const unsigned int featureWindowRasterYStart = currIPointCenterY -
1547 featureWindowRadius;
1551 unsigned int currentFeaturePtrStartIdx = 0;
1553 for( currentFeaturePtrStartIdx = 0; currentFeaturePtrStartIdx < 128 ;
1554 ++currentFeaturePtrStartIdx )
1555 auxFeaturesBuffer[ currentFeaturePtrStartIdx ] = 0.0;
1559 assert( ((
long int)currIPointCenterX) -
1560 ((
long int)featureWindowRadius) >= 0 );
1561 assert( ((
long int)currIPointCenterY) -
1562 ((
long int)featureWindowRadius) >= 0 );
1563 assert( currIPointCenterX +
1565 assert( currIPointCenterY +
1569 currIPointCenterY, featureWindowRadius );
1571 currIPointCenterY, featureWindowRadius );
1575 const float currIPointRotationNorm = std::sqrt( ( currIPointXIntensity * currIPointXIntensity ) +
1576 ( currIPointYIntensity * currIPointYIntensity ) );
1578 float currIPointRotationSin = 0;
1579 float currIPointRotationCos = 1.0;
1581 if( currIPointRotationNorm != 0.0 )
1583 currIPointRotationCos = currIPointXIntensity / currIPointRotationNorm;
1584 currIPointRotationSin = currIPointYIntensity / currIPointRotationNorm;
1587 assert( ( currIPointRotationCos >= -1.0 ) && ( currIPointRotationCos <= 1.0 ) );
1588 assert( ( currIPointRotationSin >= -1.0 ) && ( currIPointRotationSin <= 1.0 ) );
1606 unsigned int featureWindowYOffset = 0;
1607 unsigned int featureWindowXOffset = 0;
1608 float featureElementZeroCenteredOriginalXIdx = 0;
1609 float featureElementZeroCenteredOriginalYIdx = 0;
1610 float featureElementZeroCenteredRotatedXIdx = 0;
1611 float featureElementZeroCenteredRotatedYIdx = 0;
1612 float featureElementRotatedXIdx = 0;
1613 float featureElementRotatedYIdx = 0;
1614 unsigned int featureElementRasterRotatedXIdx = 0;
1615 unsigned int featureElementRasterRotatedYIdx = 0;
1616 float featureElementOriginalHaarXIntensity = 0;
1617 float featureElementOriginalHaarYIntensity = 0;
1618 float featureElementZeroCenteredOriginalHaarXIntensity = 0;
1619 float featureElementZeroCenteredOriginalHaarYIntensity = 0;
1620 float featureElementRotatedHaarXIntensity = 0;
1621 float featureElementRotatedHaarYIntensity = 0;
1622 float featureElementZeroCenteredRotatedHaarXIntensity = 0;
1623 float featureElementZeroCenteredRotatedHaarYIntensity = 0;
1624 unsigned int featureSubWindowYIdx = 0;
1625 unsigned int featureSubWindowXIdx = 0;
1627 for( featureWindowYOffset = 0 ; featureWindowYOffset < featureWindowWidth ;
1628 featureWindowYOffset += 5 )
1630 featureElementZeroCenteredOriginalYIdx = ((float)featureWindowYOffset)
1631 - featureWindowRadiusDouble;
1633 featureSubWindowYIdx = featureWindowYOffset / featureSubWindowWidth;
1635 for( featureWindowXOffset = 0 ; featureWindowXOffset < featureWindowWidth ;
1636 featureWindowXOffset += 5 )
1638 featureSubWindowXIdx = featureWindowXOffset / featureSubWindowWidth;
1640 currentFeaturePtrStartIdx = ( featureSubWindowYIdx * 4 ) +
1641 featureSubWindowXIdx;
1643 featureElementZeroCenteredOriginalXIdx = ((float)featureWindowXOffset)
1644 - featureWindowRadiusDouble;
1649 featureElementZeroCenteredRotatedXIdx =
1650 ( currIPointRotationCos * featureElementZeroCenteredOriginalXIdx ) +
1651 ( currIPointRotationSin * featureElementZeroCenteredOriginalYIdx );
1652 featureElementZeroCenteredRotatedYIdx =
1653 ( currIPointRotationCos * featureElementZeroCenteredOriginalYIdx )
1654 - ( currIPointRotationSin * featureElementZeroCenteredOriginalXIdx );
1656 featureElementRotatedXIdx = featureElementZeroCenteredRotatedXIdx +
1657 featureWindowRadiusDouble;
1658 featureElementRotatedYIdx = featureElementZeroCenteredRotatedYIdx +
1659 featureWindowRadiusDouble;
1661 featureElementRasterRotatedXIdx = featureWindowRasterXStart +
1662 (
unsigned int)
ROUND( featureElementRotatedXIdx );
1663 featureElementRasterRotatedYIdx = featureWindowRasterYStart +
1664 (
unsigned int)
ROUND( featureElementRotatedYIdx );
1666 assert( ((
long int)featureElementRasterRotatedXIdx) -
1667 ((
long int)featureElementHaarWindowRadius) >= 0 );
1668 assert( ((
long int)featureElementRasterRotatedYIdx) -
1669 ((
long int)featureElementHaarWindowRadius) >= 0 );
1670 assert( featureElementRasterRotatedXIdx +
1672 assert( featureElementRasterRotatedYIdx +
1673 featureElementHaarWindowRadius < integralRasterData.
getLinesNumber() );
1678 featureElementRasterRotatedXIdx, featureElementRasterRotatedYIdx,
1679 featureElementHaarWindowRadius );
1681 featureElementRasterRotatedXIdx, featureElementRasterRotatedYIdx,
1682 featureElementHaarWindowRadius );
1687 featureElementZeroCenteredOriginalHaarXIntensity = featureElementOriginalHaarXIntensity +
1688 featureElementZeroCenteredOriginalXIdx;
1689 featureElementZeroCenteredOriginalHaarYIntensity = featureElementOriginalHaarYIntensity +
1690 featureElementZeroCenteredOriginalYIdx;
1692 featureElementZeroCenteredRotatedHaarXIntensity =
1693 ( currIPointRotationCos * featureElementZeroCenteredOriginalHaarXIntensity ) +
1694 ( currIPointRotationSin * featureElementZeroCenteredOriginalHaarYIntensity );
1695 featureElementZeroCenteredRotatedHaarYIntensity =
1696 ( currIPointRotationCos * featureElementZeroCenteredOriginalHaarYIntensity )
1697 - ( currIPointRotationSin * featureElementZeroCenteredOriginalHaarXIntensity );
1699 featureElementRotatedHaarXIntensity = featureElementZeroCenteredRotatedHaarXIntensity
1700 - featureElementZeroCenteredRotatedXIdx;
1701 featureElementRotatedHaarYIntensity = featureElementZeroCenteredRotatedHaarYIntensity
1702 - featureElementZeroCenteredRotatedYIdx;
1706 assert( currentFeaturePtrStartIdx < 121 );
1708 auxFeaturesBuffer[ currentFeaturePtrStartIdx ] +=
1709 featureElementRotatedHaarXIntensity;
1710 auxFeaturesBuffer[ currentFeaturePtrStartIdx + 1 ] +=
1711 featureElementRotatedHaarYIntensity;
1712 auxFeaturesBuffer[ currentFeaturePtrStartIdx + 2 ] +=
1713 std::abs( featureElementRotatedHaarXIntensity );
1714 auxFeaturesBuffer[ currentFeaturePtrStartIdx + 3 ] +=
1715 std::abs( featureElementRotatedHaarYIntensity );
1716 if( featureElementRotatedHaarXIntensity < 0.0 )
1718 auxFeaturesBuffer[ currentFeaturePtrStartIdx + 4 ] +=
1719 featureElementRotatedHaarXIntensity;
1723 auxFeaturesBuffer[ currentFeaturePtrStartIdx + 5 ] +=
1724 featureElementRotatedHaarXIntensity;
1726 if( featureElementRotatedHaarYIntensity < 0.0 )
1728 auxFeaturesBuffer[ currentFeaturePtrStartIdx + 6 ] +=
1729 featureElementRotatedHaarYIntensity;
1733 auxFeaturesBuffer[ currentFeaturePtrStartIdx + 7 ] +=
1734 featureElementRotatedHaarYIntensity;
1741 float* currentFeaturePtr = features[ interestPointIdx ];
1743 float featureElementsNormalizeFactor = 0.0;
1745 for( currentFeaturePtrStartIdx = 0 ; currentFeaturePtrStartIdx < 128 ;
1746 ++currentFeaturePtrStartIdx )
1748 featureElementsNormalizeFactor += ( auxFeaturesBuffer[ currentFeaturePtrStartIdx ]
1749 * auxFeaturesBuffer[ currentFeaturePtrStartIdx ] );
1752 featureElementsNormalizeFactor = std::sqrt( featureElementsNormalizeFactor );
1754 if( featureElementsNormalizeFactor != 0.0 )
1756 featureElementsNormalizeFactor = 1.0f / featureElementsNormalizeFactor;
1759 for( currentFeaturePtrStartIdx = 0 ; currentFeaturePtrStartIdx < 128 ;
1760 ++currentFeaturePtrStartIdx )
1762 currentFeaturePtr[ currentFeaturePtrStartIdx ] = (
1763 auxFeaturesBuffer[ currentFeaturePtrStartIdx ] *
1764 featureElementsNormalizeFactor );
1766 currentFeaturePtr[ currentFeaturePtrStartIdx ] );
1768 currentFeaturePtr[ currentFeaturePtrStartIdx ] );
1784 const double raster1ToRaster2TransfDMapError,
1789 matchedPoints.clear();
1794 const unsigned int interestPointsSet1Size = interestPointsSet1.size();
1795 if( interestPointsSet1Size == 0 )
return true;
1797 const unsigned int interestPointsSet2Size = interestPointsSet2.size();
1798 if( interestPointsSet2Size == 0 )
return true;
1801 assert( featuresSet1.
getLinesNumber() == interestPointsSet1Size );
1802 assert( featuresSet2.
getLinesNumber() == interestPointsSet2Size );
1806 InterestPointsSetT::const_iterator it1 = interestPointsSet1.begin();
1807 boost::scoped_array< InterestPointT > internalInterestPointsSet1(
1809 for(
unsigned int idx1 = 0 ; idx1 < interestPointsSet1Size ; ++idx1 )
1811 internalInterestPointsSet1[ idx1 ] = *it1;
1815 InterestPointsSetT::const_iterator it2 = interestPointsSet2.begin();
1816 boost::scoped_array< InterestPointT > internalInterestPointsSet2(
1818 for(
unsigned int idx2 = 0 ; idx2 < interestPointsSet2Size ; ++idx2 )
1820 internalInterestPointsSet2[ idx2 ] = *it2;
1829 "Error crearting the correlation matrix" );
1831 unsigned int col = 0;
1832 unsigned int line = 0;
1835 for( line = 0 ; line < interestPointsSet1Size ; ++line )
1837 linePtr = distMatrix[ line ];
1839 for( col = 0 ; col < interestPointsSet2Size ; ++col )
1841 linePtr[ col ] = std::numeric_limits< float >::max();
1847 boost::mutex syncMutex;
1848 unsigned int nextFeatureIdx1ToProcess = 0;
1870 boost::thread_group threads;
1872 for(
unsigned int threadIdx = 0 ; threadIdx < procsNumber ;
1875 threads.add_thread(
new boost::thread(
1889 std::vector< float > eachLineMinValues( interestPointsSet1Size,
1891 std::vector< unsigned int > eachLineMinIndexes( interestPointsSet1Size,
1892 interestPointsSet2Size );
1893 std::vector< float > eachColMinValues( interestPointsSet2Size,
1895 std::vector< unsigned int > eachColMinIndexes( interestPointsSet2Size,
1896 interestPointsSet1Size );
1898 for( line = 0 ; line < interestPointsSet1Size ; ++line )
1900 linePtr = distMatrix[ line ];
1902 for( col = 0 ; col < interestPointsSet2Size ; ++col )
1904 const float& value = linePtr[ col ];
1906 if( value <= maxEuclideanDist )
1908 if( value < eachLineMinValues[ line ] )
1910 eachLineMinValues[ line ] = value;
1911 eachLineMinIndexes[ line ] = col;
1914 if( value < eachColMinValues[ col ] )
1916 eachColMinValues[ col ] = value;
1917 eachColMinIndexes[ col ] = line;
1927 for( line = 0 ; line < interestPointsSet1Size ; ++line )
1929 col = eachLineMinIndexes[ line ];
1931 if( ( col < interestPointsSet2Size ) &&
1932 ( eachColMinIndexes[ col ] == line ) )
1934 auxMatchedPoints.
m_point1 = internalInterestPointsSet1[ line ];
1935 auxMatchedPoints.
m_point2 = internalInterestPointsSet2[ col ],
1936 auxMatchedPoints.
m_feature = distMatrix( line, col );
1938 matchedPoints.insert( auxMatchedPoints );
1961 unsigned int feat2Idx = 0;
1962 float const* feat1Ptr = 0;
1963 float const* feat2Ptr = 0;
1964 float* corrMatrixLinePtr = 0;
1965 unsigned int featCol = 0;
1968 float euclideanDist = 0;
1972 std::auto_ptr< te::gm::GeometricTransformation > raster1ToRaster2TransfPtr;
1982 const unsigned int featuresSet1Size =
1984 const unsigned int featuresSet2Size =
1989 std::vector< unsigned int > selectedFeaturesSet2Indexes;
1990 unsigned int selectedFeaturesSet2IndexesSize = 0;
1994 for(
unsigned int feat2Idx = 0 ; feat2Idx < featuresSet2Size ; ++feat2Idx )
1996 interestPointsSet2RTree.
insert(
2007 selectedFeaturesSet2Indexes.resize( featuresSet2Size );
2008 selectedFeaturesSet2IndexesSize = featuresSet2Size;
2009 for(
unsigned int feat2Idx = 0 ; feat2Idx < featuresSet2Size ; ++feat2Idx )
2011 selectedFeaturesSet2Indexes[ feat2Idx ] = feat2Idx;
2017 for(
unsigned int feat1Idx = 0 ; feat1Idx < featuresSet1Size ; ++feat1Idx )
2029 raster1ToRaster2TransfPtr->directMap(
2033 auxEnvelope.
m_lly );
2038 auxEnvelope.
m_llx -= interestPointsSet2RTreeSearchRadius;
2039 auxEnvelope.
m_lly -= interestPointsSet2RTreeSearchRadius;
2040 auxEnvelope.
m_urx += interestPointsSet2RTreeSearchRadius;
2041 auxEnvelope.
m_ury += interestPointsSet2RTreeSearchRadius;
2043 selectedFeaturesSet2Indexes.clear();
2044 interestPointsSet2RTree.
search( auxEnvelope,
2045 selectedFeaturesSet2Indexes );
2047 selectedFeaturesSet2IndexesSize = selectedFeaturesSet2Indexes.size();
2050 corrMatrixLinePtr = paramsPtr->
m_distMatrixPtr->operator[]( feat1Idx );
2054 for(
unsigned int selectedFeaturesSet2IndexesIdx = 0 ;
2055 selectedFeaturesSet2IndexesIdx < selectedFeaturesSet2IndexesSize ;
2056 ++selectedFeaturesSet2IndexesIdx )
2058 feat2Idx = selectedFeaturesSet2Indexes[ selectedFeaturesSet2IndexesIdx ];
2070 euclideanDist = 0.0;
2072 for( featCol = 0 ; featCol < featureElementsNmb ; ++featCol )
2074 diff = feat1Ptr[ featCol ] - feat2Ptr[ featCol ];
2075 euclideanDist += ( diff * diff );
2078 euclideanDist = std::sqrt( euclideanDist );
2080 corrMatrixLinePtr[ feat2Idx ] = euclideanDist;
static bool createIntegralImage(const FloatsMatrix &inputData, FloatsMatrix &outputData)
Create an integral image.
static float getSurfDxyDerivative(float **bufferPtr, const unsigned int ¢erX, const unsigned int ¢erY, const unsigned int &lobeWidth)
Return a SURF box filter Dxy derivative centered over the given position from the given integral imag...
void reset()
Clear all internal allocated resources and go back to the initial not-initialized state...
te::gm::GeometricTransformation const * m_raster1ToRaster2TransfPtr
A pointer to a transformation direct mapping raster 1 indexed coords into raster 2 indexed coords...
TiePointsLocatorSURFStrategy()
A class that represents an R-tree.
~TiePointsLocatorSURFStrategy()
unsigned int m_y
Point Y coord.
double m_searchOptTreeSearchRadius
Optimization tree search radius (pixels).
This class can be used to inform the progress of a task.
unsigned int m_tiePointsSubSectorsSplitFactor
The number of sectors along each direction.
double m_urx
Upper right corner x-coordinate.
boost::mutex * m_syncMutexPtr
FloatsMatrix * m_distMatrixPtr
float m_feature
Matched interest feature.
Tie-Pointsr locator SURF strategy.
static float getSurfDyyDerivative(float **bufferPtr, const unsigned int ¢erX, const unsigned int ¢erY, const unsigned int &lobeWidth, const unsigned int &lobeRadius)
Return a SURF box filter Dxx derivative centered over the given position from the given integral imag...
unsigned int m_processingBlocksNumber
The raster data will be splitted into this number of blocks for processing.
MemoryPolicy getMemPolicy() const
Returns the current memory policy.
unsigned int m_x
Point X coord.
#define TERP_TRUE_OR_RETURN_FALSE(value, message)
Checks if value is true. For false values a warning message will be logged and a return of context wi...
unsigned int m_octavesNumber
The number of octaves to generate (minimum:1).
std::vector< InterestPointsSetT > * m_interestPointsSubSectorsPtr
A pointer to a valid interest points container (one element by subsector)..
static unsigned int getSurfOctaveBaseFilterSize(const unsigned int &octaveIndex)
Return the surf octave base filter size (width).
TECOMMONEXPORT unsigned int GetPhysProcNumber()
Returns the number of physical processors.
boost::mutex * m_rastaDataAccessMutexPtr
A pointer to a valid mutex to controle raster data access.
double m_llx
Lower left corner x-coordinate.
An Envelope defines a 2D rectangular region.
static unsigned int getSurfFilterSize(const unsigned int &octaveIndex, const unsigned int &scaleIndex)
Return the surf octave filter size (width).
TECOMMONEXPORT unsigned long int GetUsedVirtualMemory()
Returns the amount of used virtual memory (bytes) for the current process (physical + swapped)...
te::rp::TiePointsLocatorInputParameters m_inputParameters
Input parameters.
The parameters passed to the executeMatchingByEuclideanDistThreadEntry method.
static bool generateSurfFeatures(const InterestPointsSetT &interestPoints, const FloatsMatrix &integralRasterData, InterestPointsSetT &validInterestPoints, FloatsMatrix &features)
Generate a Surf features matrix for the given interes points.
unsigned int getColumnsNumber() const
The number of current matrix columns.
mydialect insert("+", new te::da::BinaryOpEncoder("+"))
FloatsMatrix const * m_featuresSet2Ptr
std::multiset< InterestPointT > InterestPointsSetT
bool getMatchedInterestPoints(te::gm::GeometricTransformation const *const raster1ToRaster2TransfPtr, const double raster1ToRaster2TransfDMapError, MatchedInterestPointsSetT &matchedInterestPoints)
Try to find matched interest points.
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
InterestPointT const * m_interestPointsSet2Ptr
static void executeMatchingByEuclideanDistThreadEntry(ExecuteMatchingByEuclideanDistThreadEntryParams *paramsPtr)
Correlation/Euclidean match thread entry.
static bool loadRasterData(te::rst::Raster const *rasterPtr, const std::vector< unsigned int > &rasterBands, te::rst::Raster const *maskRasterPtr, const unsigned int maskRasterBand, const unsigned int rasterTargetAreaLineStart, const unsigned int rasterTargetAreaColStart, const unsigned int rasterTargetAreaWidth, const unsigned int rasterTargetAreaHeight, const double desiredRescaleFactorX, const double desiredRescaleFactorY, const te::rst::Interpolator::Method rasterInterpMethod, const unsigned char maxMemPercentUsage, std::vector< boost::shared_ptr< FloatsMatrix > > &loadedRasterData, UCharsMatrix &loadedMaskRasterData, double &achievedRescaleFactorX, double &achievedRescaleFactorY)
Load rasters data (normalized between 0 and 1).
FloatsMatrix const * m_integralRasterDataPtr
The integral image raster data.
void reset()
Reset (clear) the active instance data.
double m_lly
Lower left corner y-coordinate.
static void roolUpBuffer(BufferElementT **bufferPtr, const unsigned int &bufferLinesNumber)
RoolUp a buffer of lines.
The parameters passed to the surfLocatorThreadEntry method.
void insert(const te::gm::Envelope &mbr, const DATATYPE &data)
It inserts an item into the tree.
double m_ury
Upper right corner y-coordinate.
float m_feature3
Interest point feature 3 value.
UCharsMatrix const * m_maskRasterDataPtr
The loaded mask raster data pointer (or zero if no mask is avaliable).
bool executeMatchingByEuclideanDist(const FloatsMatrix &featuresSet1, const FloatsMatrix &featuresSet2, const InterestPointsSetT &interestPointsSet1, const InterestPointsSetT &interestPointsSet2, te::gm::GeometricTransformation const *const raster1ToRaster2TransfPtr, const double raster1ToRaster2TransfDMapError, MatchedInterestPointsSetT &matchedPoints) const
Match each feature using eucliean distance.
InterestPointT const * m_interestPointsSet1Ptr
A generic template matrix.
TemplateElementType ElementTypeT
Public matrix element type definition.
InterestPointT m_point2
Interest point 2.
float m_feature2
Interest point feature 2 value.
#define ROUND(x)
Minimum of two values.
bool initialize(const te::rp::TiePointsLocatorInputParameters &inputParameters)
Initialize the strategy.
TECOMMONEXPORT unsigned long int GetTotalPhysicalMemory()
Returns the amount of total physical memory (bytes).
static void locateSurfInterestPointsThreadEntry(SurfLocatorThreadParams *paramsPtr)
Surf locator thread entry.
boost::mutex * m_interestPointsAccessMutexPtr
A pointer to a valid mutex to control the output interest points container access.
#define TERP_DEBUG_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
bool locateSurfInterestPoints(const unsigned int maxInterestPoints, const FloatsMatrix &integralRasterData, UCharsMatrix const *maskRasterDataPtr, InterestPointsSetT &interestPoints) const
SURF interest points locator.
FloatsMatrix const * m_featuresSet1Ptr
unsigned int m_maxInterestPointsBySubSector
The maximum number of interest points by sub-sector.
bool m_isInitialized
true if this instance is initialized.
unsigned int getAutoMaxTiePointsNumber() const
Returns a automatically calculated optimum maximum amount tie-points following the current parameters...
unsigned int * m_nextRasterLinesBlockToProcessValuePtr
A pointer to a valid counter to control the blocks processing sequence.
unsigned int * m_nextFeatureIdx1ToProcessPtr
static float getSurfDxxDerivative(float **bufferPtr, const unsigned int ¢erX, const unsigned int ¢erY, const unsigned int &lobeWidth, const unsigned int &lobeRadius)
Return a SURF box filter Dyy derivative centered over the given position from the given integral imag...
unsigned int getLinesNumber() const
The number of current matrix lines.
std::multiset< MatchedInterestPointsT > MatchedInterestPointsSetT
static bool checkForDuplicatedInterestPoints(const InterestPointsSetT &interestPoints, double &x, double &y)
Check for duplicated interest points.
#define TERP_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
unsigned int m_scalesNumber
Thread return value pointer.
InterestPointT m_point1
Interest point 1.
static float getHaarYVectorIntensity(BufferType &buffer, const unsigned int ¢erX, const unsigned int ¢erY, const unsigned int &radius)
Return a Haar Y intesity vector for the window centered at the given point.
TECOMMONEXPORT unsigned long int GetTotalVirtualMemory()
Returns the amount of total virtual memory (bytes) that can be claimed by the current process (physic...
static float getHaarXVectorIntensity(BufferType &buffer, const unsigned int ¢erX, const unsigned int ¢erY, const unsigned int &radius)
Return a Haar X intesity vector for the window centered at the given point.
float m_feature1
Interest point feature 1 value.