MicroEdgeMap.cpp
Go to the documentation of this file.
00001 #include "EdgeDetection/MicroEdgeMap.h"
00002 
00003 #include "EdgeDetection/EdgeImage.h"
00004 #include "EdgeDetection/Image.h"
00005 
00006 namespace EdgeDetection
00007 {
00008         Edge MicroEdgeMap::FindRealEdge(Edge measuredEdge)
00009         {
00010                 Edge bestEdge = Edge(0, 0);
00011                 Edge bestEdgeMeasured = MeasureEdge(bestEdge);
00012 
00013                 for (size_t index = 0; index < entries.size(); index++)
00014                 {
00015                         Edge sampleEdge = entries[index].GetRealEdge();
00016                         Edge sampleEdgeMeasured = entries[index].GetMeasuredEdge();
00017                 
00018                         if (Edge::GetDistance(measuredEdge, sampleEdgeMeasured) <= Edge::GetDistance(measuredEdge, bestEdgeMeasured))
00019                         {
00020                                 bestEdge = sampleEdge;
00021                                 bestEdgeMeasured = sampleEdgeMeasured;
00022                         }
00023                 }
00024 
00025                 return bestEdge;
00026         }
00027 
00028         void MicroEdgeMap::PopulateTable(Rectangle area, int offsetCount, int angleCount)
00029         {
00030                 if (area.GetLeft() < -1 || area.GetRight() > +1 || area.GetTop() < -M_PI || area.GetBottom() > +M_PI) throw "The parameter 'area' was out of range.";
00031                 if (offsetCount <= 0) throw "The parameter 'offsetCount' was out of range.";
00032                 if (angleCount <= 0) throw "The parameter 'angleCount' was out of range.";
00033 
00034                 for (int offsetIndex = 0; offsetIndex < offsetCount; offsetIndex++)
00035                         for (int angleIndex = 0; angleIndex < angleCount; angleIndex++)
00036                         {
00037                                 double offset = area.GetLeft() + offsetIndex * (area.GetWidth() / (offsetCount - 1));
00038                                 double angle = area.GetTop() + angleIndex * (area.GetHeight() / (angleCount - 1));
00039 
00040                                 Edge realEdge = Edge(offset, angle);
00041                                 Edge measuredEdge = MeasureEdge(realEdge);
00042 
00043                                 entries.push_back(Entry(realEdge, measuredEdge));
00044                         }
00045         }
00046         Edge MicroEdgeMap::MeasureEdge(Edge realEdge)
00047         {       
00048                 EdgeImage* realEdgeImage = new EdgeImage(Line::FromEdge(realEdge), Rectangle(-1, +1, -1, +1));
00049                 Image* image = rasterizer->Rasterize(realEdgeImage, microEdgeDetector->GetSize(), microEdgeDetector->GetSize());
00050                 Edge measuredEdge = microEdgeDetector->DetectEdge(image);
00051         
00052                 delete realEdgeImage;
00053                 delete image;
00054         
00055                 return measuredEdge;
00056         }
00057 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


aruco_pose
Author(s): Julian Brunner
autogenerated on Thu May 23 2013 12:15:46