Go to the documentation of this file.00001
00002
00003
00004 #include <opencv2/imgproc/imgproc.hpp>
00005 #include <opencv2/highgui/highgui.hpp>
00006 #include <string>
00007 #include <utility>
00008 using namespace cv;
00009 using namespace std;
00010
00011 namespace portrait_painter {
00033 class GetLines {
00034 public:
00036 GetLines();
00037
00050 vector<pair<CvPoint2D32f, vector<CvPoint2D32f> > > getLines(string& image);
00051
00057 vector<pair<CvPoint2D32f, vector<CvPoint2D32f> > > scaleTo(size_t size,
00058 bool preserveRatio);
00059
00067 void drawLines();
00068
00075 void drawPR2(float percentualHeightOfImage);
00076
00077 private:
00080 struct Lines {
00081 CvPoint2D32f start;
00082 CvPoint2D32f end;
00083 vector<CvPoint2D32f> relative;
00084 unsigned int id;
00085 };
00086
00094 void readInFile(string& image, vector<string>* output);
00095
00104 void minimize();
00105
00120 void eraseDoubleLines(size_t maxDistance);
00121
00127 void eraseNearestNeighbours(size_t maxDistance, size_t distance,
00128 vector<CvPoint2D32f>& absolutePoints);
00129
00140 vector<Lines> connectLines(size_t maxDistance,
00141 vector<pair<CvPoint2D32f, vector<CvPoint2D32f> > >& linesToConnect);
00142
00156 void minimizeLines(size_t maxDistance, size_t threshold);
00157
00162 void setPotraceParams(size_t turdSize, bool invert);
00163
00171 void setErasingParams(size_t maxDistanceBetweenPoints,
00172 size_t minDistanceWithinVector, float splitFactor,
00173 size_t minLineSize);
00174
00178 void setConnectingParams(size_t maxDistanceBetweenLines);
00179
00184 void setMinimizeLinesParams(size_t maxDistance, size_t threshold);
00185
00187 vector<pair<CvPoint2D32f, vector<CvPoint2D32f> > > lines;
00188
00190 int _size;
00191
00193 Mat src;
00194
00196 string image_name;
00197
00199 struct getLinesParams {
00200 size_t turdSize;
00201 bool invert;
00202 size_t maxDistanceBetweenPoints;
00203 size_t minDistanceWithinVector;
00204 float splitFactor;
00205 size_t minLineSize;
00206 size_t maxDistanceBetweenLines;
00207 size_t maxDistance;
00208 size_t threshold;
00209 };
00210
00212 getLinesParams params;
00213 };
00214 }