00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #pragma once
00027 #include <iostream>
00028 #include <iomanip>
00029 #include <string>
00030 #include <stdio.h>
00031 #include "plugins/SceneUnderstanding/EIEdgeImage/EIEdgeImage.h"
00032 #include "plugins/SceneUnderstanding/LFLineFitter/LFLineFitter.h"
00033 #include "LMDistanceImage.h"
00034
00035
00036
00037 class LMLineMatcher {
00038 public:
00039 LMLineMatcher();
00040 ~LMLineMatcher();
00041
00042 struct Rect
00043 {
00044 int x;
00045 int y;
00046 int width;
00047 int height;
00048 double distance;
00049
00050 Rect(int inX, int inY, int w, int h, double d) :
00051 x(inX), y(inY), width(w), height(h), distance(d)
00052 {}
00053 };
00054
00055
00056 void Configure(const char* fileName);
00057 void Init(const char* fileName,double db_scale=1.0);
00058
00059 std::vector<Rect> Match(int width, int height, int nLines, LFLineSegment* linesSegment);
00060
00061 void GetColorImage(string filename) {imageName_ = filename;};
00062
00063 double getCost(EIEdgeImage& tbImage, double ltrans[2], double factor, int& count);
00064 double getCost(int directionIdx, int sx, int sy, int ex, int ey, int count) const;
00065
00066 void computeIDT3(int width, int height, int nLines, LFLineSegment* linesSegment);
00067
00068
00069 private:
00070
00071 double MatchBruteForce(EIEdgeImage& dbImage, int index, int* iindices, int* indices, int* xIndex, int* yIndex, double* dIndex, double* sIndex, double* distances, int& counter, double& minCost);
00072 void DrawDetWind(IplImage *image,int x,int y,int detWindWidth,int detWindHeight,CvScalar scalar=cvScalar(0,255,0),int thickness=2);
00073 void DrawMatchTemplate(IplImage *image,EIEdgeImage &ei,int x,int y,double scale,CvScalar scalar=cvScalar(0,255,255),int thickness=1);
00074 void ISort(double* ra, int nVec, int* ira);
00075 void SafeRelease();
00076
00077
00078 private:
00079
00080
00081 double* distances_;
00082 int* indices_;
00083 int* xIndices_;
00084 int* yIndices_;
00085 double* sIndices_;
00086 double* dIndices_;
00087 int* iindices_;
00088 int* wIndices_;
00089 int* hIndices_;
00090 double scale_;
00091 EIEdgeImage* dbImages_;
00092
00093
00094 int ndbImages_;
00095 LMDistanceImage queryDistanceImage_;
00096
00097
00098 string imageName_;
00099 EIEdgeImage queryImage_;
00100
00101
00102
00103 int nDirections_;
00104 double maxCost_;
00105 float directionCost_;
00106
00107 double db_scale_;
00108
00109 double baseSearchScale_;
00110 double minSearchScale_;
00111 double maxSearchScale_;
00112
00113 int searchStepSize_;
00114 int searchBoundarySize_;
00115 double minCostRatio_;
00116 };