Go to the documentation of this file.00001 #ifndef __MarkerRefiner__
00002 #define __MarkerRefiner__
00003
00004 #include <string>
00005 #include <fstream>
00006
00007 #include <opencv/cv.h>
00008
00009 #include "aruco/aruco.h"
00010
00011 #include "EdgeDetection/AdaptiveRasterizer.h"
00012 #include "EdgeDetection/MicroEdgeDetector.h"
00013 #include "EdgeDetection/MicroEdgeCorrectionTable.h"
00014 #include "EdgeDetection/PointCorrector.h"
00015 #include "EdgeDetection/MacroEdgeDetector.h"
00016 #include "EdgeDetection/Vector2.h"
00017
00018 class MarkerRefiner
00019 {
00020 private: static unsigned char microEdgeCorrectionTableData[];
00021
00022 private: EdgeDetection::Rasterizer* rasterizerFine;
00023 private: EdgeDetection::MicroEdgeDetector* microEdgeDetector;
00024 private: EdgeDetection::MicroEdgeCorrectionTable* microEdgeCorrectionTable;
00025 private: EdgeDetection::MacroEdgeDetector* macroEdgeDetector;
00026
00027 public: MarkerRefiner(std::string correctionTablePath, EdgeDetection::PointCorrector* pointCorrector)
00028 {
00029 this->rasterizerFine = new EdgeDetection::AdaptiveRasterizer(0.00000001);
00030 this->microEdgeDetector = new EdgeDetection::MicroEdgeDetector(rasterizerFine, 5);
00031 std::ifstream microEdgeCorrectionTableFile(correctionTablePath.c_str(), std::ifstream::in | std::ifstream::binary);
00032 this->microEdgeCorrectionTable = EdgeDetection::MicroEdgeCorrectionTable::Deserialize(µEdgeCorrectionTableFile);
00033 microEdgeCorrectionTableFile.close();
00034 this->macroEdgeDetector = new EdgeDetection::MacroEdgeDetector(microEdgeDetector, microEdgeCorrectionTable, pointCorrector);
00035 }
00036 public: MarkerRefiner(EdgeDetection::PointCorrector* pointCorrector)
00037 {
00038 this->rasterizerFine = new EdgeDetection::AdaptiveRasterizer(0.00000001);
00039 this->microEdgeDetector = new EdgeDetection::MicroEdgeDetector(rasterizerFine, 5);
00040 std::stringstream data(std::stringstream::in | std::stringstream::out | std::stringstream::binary);
00041 data.write((const char*)microEdgeCorrectionTableData, 40040);
00042 this->microEdgeCorrectionTable = EdgeDetection::MicroEdgeCorrectionTable::Deserialize(&data);
00043 this->macroEdgeDetector = new EdgeDetection::MacroEdgeDetector(microEdgeDetector, microEdgeCorrectionTable, pointCorrector);
00044 }
00045 public: ~MarkerRefiner()
00046 {
00047 delete rasterizerFine;
00048 delete microEdgeDetector;
00049 delete microEdgeCorrectionTable;
00050 delete macroEdgeDetector;
00051 }
00052
00053 public: aruco::Marker refineMarker(aruco::Marker marker, Mat matrixImage);
00054
00055 private: static bool isCloseToBorder(Mat matrixImage, EdgeDetection::Vector2 point);
00056 };
00057
00058 #endif