Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "HoughIndexCalculator.h"
00012
00013
00014
00015
00016 #include "Workers/Math/Math.h"
00017 #include "Workers/Puma2/GrayLevelImage8.h"
00018
00019 #include "ImageProperties.h"
00020
00021 #include "Workers/Math/vec2.h"
00022
00023 #include <algorithm>
00024 #include <assert.h>
00025 #include <map>
00026 #include <list>
00027 #include <math.h>
00028 #include <cstring>
00029
00030 #include <fstream>
00031
00032 using namespace std;
00033
00034 #define THIS HoughIndexCalculator
00035
00036 void THIS::calculateScaleIndex(double scaleQuotient, int& scaleIndexFloor, int& scaleIndexCeil)
00037 {
00038 int scaleBins = 1;
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 int maxOctaves=5;
00051 float scaleIndex = ( log2( scaleQuotient ) / (maxOctaves-1) / 2 + 0.5 ) * scaleBins;
00052
00053
00054 if ( scaleIndex >= scaleBins ) {
00055 scaleIndex = scaleBins-1;
00056 }
00057
00058 if ( scaleIndex < 0 ) {
00059 scaleIndex = 0;
00060 }
00061
00062 scaleIndexFloor = scaleIndex;
00063 scaleIndexCeil = scaleIndex+1;
00064
00065 if(scaleIndexCeil >= scaleBins)
00066 {
00067 scaleIndexCeil = scaleBins-1;
00068 }
00069 }
00070
00071 void THIS::calculateOrientationIndex(double turnAngle, int& orientationFloor, int& orientationCeil)
00072 {
00073 int orientationBins = 1;
00074
00075
00076
00077 if(turnAngle<-M_PI || turnAngle>M_PI)
00078 {
00079
00080 }
00081
00082
00083
00084
00085
00086 float orientationIndex = ( turnAngle+M_PI ) /M_PI/2.0 * orientationBins;
00087
00088 assert( orientationIndex >= 0.0 );
00089
00090
00091 orientationFloor = int(orientationIndex) % orientationBins;
00092 orientationCeil = ( orientationFloor+1 ) % orientationBins;
00093 }
00094
00095 void THIS::calculatePositionIndex(KeyPoint sceneKeyPoint, KeyPoint objectKeyPoint, Point2D center, int w, int h, int& xDistanceFloor, int& xDistanceCeil, int& yDistanceFloor, int& yDistanceCeil)
00096 {
00097 int xLocationBins = 10;
00098 int yLocationBins = 10;
00099
00100
00101 Point2D objectPoint = objectKeyPoint.position();
00102 Point2D scenePoint = sceneKeyPoint.position();
00103
00104
00105 Point2D v = center - objectPoint;
00106 v *= sceneKeyPoint.scale/ objectKeyPoint.scale;
00107 v.rotate ( Math::minTurnAngle(sceneKeyPoint.orientation, objectKeyPoint.orientation) );
00108
00109
00110 Point2D centerScene = v + scenePoint;
00111
00112
00113 float xPositionIndex = (centerScene.x()/w)*xLocationBins;
00114 float yPositionIndex = (centerScene.y()/h)*yLocationBins;
00115
00116
00117 xDistanceFloor = xPositionIndex;
00118 xDistanceCeil = xDistanceFloor+1;
00119
00120 yDistanceFloor = yPositionIndex;
00121 yDistanceCeil = yDistanceFloor+1;
00122 }
00123
00124 #undef THIS