// // Created by mpapa on 05.12.2017. // #ifndef SOURCE_ABSTRACTIONLAYER_1_H #define SOURCE_ABSTRACTIONLAYER_1_H #include "AbstractionLayer_1_Properties.h" #include "../AbstraktionLayer_Base.h" #include #include #include #include #include #include #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include #include #include #include #include #include #define DISPLAY false #ifdef _WIN32 #define PATH "..\\..\\..\\pieces\\%04d.jpg" #elif defined __unix__ #define PATH "..//..//..//pieces//%04d.jpg" #elif defined __APPLE__ #define PATH "..//..//..//pieces//%04d.jpg" #endif #define IMG_SIZE 400 #define TOP 6 #define RIGHT 4 #define BOTTOM 2 #define LEFT 0 using namespace std; using namespace cv; class AbstractionLayer_1 : public AbstractionLayer_Base { public: bool PreProcessing(coor mySize, const vector* partArray) final ; bool EvaluateQuality ( coor constraintCoordinate, qualityVector& qVector)final; bool SetConstraintOnPosition( coor constraintCoordinate, AbstractionLayer_1_Properties constraint)final; bool RemoveConstraintOnPosition( coor constraintCoordinate)final; int RemoveSimilar(qualityVector&,uint8_t&); bool PlaceOfPartGood(coor myCoor, uint8_t& myPart); void shift(uint8_t& Part, int shifts); void setEdgeZero(); int PoempelSum(uint8_t constraint); void CreateRandomPuzzle(); qualityVector returnInBox(vector& PuzzleBox); void printConstraintMatrix(); private: }; class Details{ public: vector> getContour(){return contour;} Mat getImage(){return image;} Point getCenter(){return center;} vector getHierarchy(){return hierarchy;} unsigned char getTabs(){return tabs;} void setContour(vector> cont){contour = std::move(cont);} void setImage(Mat im){image = std::move(im);} void setCenter(const Point &c){center = c;} void setHierarchy(vector hier){hierarchy = std::move(hier);} void setCorners(vector cor){corners = std::move(cor);} void setTabs(unsigned char t){tabs = t;} vector getLen(){return len;} void setLens(vector l ){len = l;} Point getMidpoint(){return midpoint;} void setMidpoint(Point m ){midpoint = m;} vector getPoempelPosition(){return PoempelPosition;} void setPoempelPosition(vector& newPP){PoempelPosition=newPP;} vector getCorners(){return corners;} private: Mat image; vector PoempelPosition; vector corners; vector> contour; vector hierarchy; Point center; vector len; unsigned char tabs; Point midpoint; }; class analyseParts{ public: explicit analyseParts(int s = 1008): nr_parts(s){} Mat getImage(int i){if(i>= nr_parts)return masks[nr_parts-1].getImage(); else return masks[i].getImage();} vector> getContour(int i){if(i>= nr_parts)return masks[nr_parts-1].getContour(); else return masks[i].getContour();} Point getCenter(int i){if(i>= nr_parts)return masks[nr_parts-1].getCenter(); else return masks[i].getCenter();} vector getHierarchy(int i){if(i>= nr_parts)return masks[nr_parts-1].getHierarchy(); else return masks[i].getHierarchy();} unsigned char getTabs(int i){if(i>= nr_parts)return masks[nr_parts-1].getTabs(); else return masks[i].getTabs();} vector getLen(int i ){return masks[i].getLen();} vector getPoempelPosition(int i){return masks[i].getPoempelPosition();} vector analyseLens(vector, vector); Point calcMidpoint(vector); Point getMidpoint(int i){return masks[i].getMidpoint();} Point findCenter(Mat); vector findCorners(vector,Point); unsigned char analyseContour(vector, vector,vector&); Mat makeBorder(Mat&); Mat readImages(int); Mat morphDilateErode(Mat&); vector> findingContours(Mat&); Mat polyApprox(vector> &); bool getImages(); private: float lengthTwoPoints(Point, Point); float angle(Point, Point, Point); vector
masks; int nr_parts; }; #endif //SOURCE_ABSTRACTIONLAYER_1_H