From dd69066c760b01e56f025eda1f3127c6f7cb62fb Mon Sep 17 00:00:00 2001 From: Raphael Maenle <17550607+g-spacewhale@users.noreply.github.com> Date: Tue, 30 Jan 2018 18:45:54 +0100 Subject: [PATCH] Added KantenLaenge --- Source/CMakeLists.txt | 2 +- .../DestructionPower/DestructionPower.h | 2 +- .../Layer1/AbstractionLayer_1.cpp | 20 +- .../Layer1/AbstractionLayer_1.h | 6 +- .../AbstractionLayer_KantenLaenge.cpp | 90 +++++++++ .../AbstractionLayer_KantenLaenge.h | 22 +++ ...AbstractionLayer_KantenLaenge_Properties.h | 19 ++ .../AbstractionLayer_Histogram.cpp | 176 ------------------ .../AbstractionLayer_Histogram.h | 43 ----- .../AbstractionLayer_Histogram_Properties.h | 29 --- Source/functions/solve/puzzleExtension.cpp | 4 +- Source/functions/solve/structure.cpp | 36 ++-- Source/header/input.h | 4 +- Source/header/solve.h | 6 +- 14 files changed, 179 insertions(+), 280 deletions(-) create mode 100644 Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge.cpp create mode 100644 Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge.h create mode 100644 Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge_Properties.h delete mode 100644 Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram.cpp delete mode 100644 Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram.h delete mode 100644 Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram_Properties.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 6cacb59..8e1718c 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -14,7 +14,7 @@ set(SOURCE_FILES functions/AbstractionLayers/Layer_SURFFeatures/AbstractionLayer_SURFFeatures.cpp functions/AbstractionLayers/Layer_ColorMatching/AbstractionLayer_ColorMatching.cpp functions/AbstractionLayers/DestructionPower/DestructionPower.cpp - functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram.cpp + functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge.cpp header/solve.h header/input.h functions/solve/puzzleExtension.cpp) diff --git a/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h index 8d8eb9f..288af80 100644 --- a/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h +++ b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h @@ -1,6 +1,6 @@ #pragma once //TODO!! increase Destructioncount -#define DESTRUCTION_COUNT 1 +#define DESTRUCTION_COUNT 3 #include "DestructionPower_Properties.h" #include "../AbstraktionLayer_Base.h" diff --git a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp index b5e335b..339f784 100644 --- a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp +++ b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp @@ -27,8 +27,10 @@ bool AbstractionLayer_1::PreProcessing(coor mySize, const vector* partAr { ref_partArray[iterator]->m_a1.m_connections=poempel; ref_partArray[iterator]->m_a3.SideLength=analyse.getPoempelPosition(i); //do abstraction Layer 3 check + ref_partArray[iterator]->m_a2.SideLength=analyse.getKantenLaenge(i);//do abstraction Layer 2 check shift(poempel,1); ref_partArray[iterator]->m_a3.shift(j);//rotate information + ref_partArray[iterator]->m_a2.shift(j);//rotate information iterator++; } } @@ -432,7 +434,9 @@ bool analyseParts::getImages(){ } mask.setCorners(corners); vector tmpPoempelPosition={0,0,0,0,0,0,0,0};//TODO somehow make this code section bearable - mask.setTabs(analyseContour(corners,contours[0],tmpPoempelPosition)); + vector tmpKantenLaenge= {0,0,0,0,0,0,0,0}; + mask.setTabs(analyseContour(corners,contours[0],tmpPoempelPosition,tmpKantenLaenge)); + mask.setKantenLaenge(tmpKantenLaenge); mask.setPoempelPosition(tmpPoempelPosition); mask.setLens(analyseLens(lens, corners)); mask.setMidpoint(calcMidpoint(corners)); @@ -638,7 +642,7 @@ vector analyseParts::findCorners(vector contour, Point center){ if(DISPLAY) imshow("draw",drawing); return corners; } -unsigned char analyseParts::analyseContour(vector corners, vector contour,vector& PoempelPosition){ +unsigned char analyseParts::analyseContour(vector corners, vector contour,vector& PoempelPosition, vector& KantenLaenge){ vector contour_right; vector contour_top; @@ -1078,6 +1082,7 @@ unsigned char analyseParts::analyseContour(vector corners, vector diff = corners[0] - contour_right_new[max_dist_idx]; PoempelPosition[3] = cv::sqrt(diff.x*diff.x + diff.y*diff.y); + /*-------------------------------------*/ unsigned char tabs = 0; int poembel_threshold = 15; @@ -1160,7 +1165,7 @@ unsigned char analyseParts::analyseContour(vector corners, vector max_dist_idx = i; } } - //saves length between Corners and Poempel left + //saves length between Corners and Poempel bottom diff = corners[0] - contour_bottom_new[max_dist_idx]; PoempelPosition[4] = cv::sqrt(diff.x*diff.x + diff.y*diff.y); diff = corners[1] - contour_bottom_new[max_dist_idx]; @@ -1175,6 +1180,15 @@ unsigned char analyseParts::analyseContour(vector corners, vector if (abs(ref_bottom - contour_bottom_new[max_dist_idx].y) < poembel_threshold) { tabs |= (0 << BOTTOM); } + + diff=corners[2] - corners[0]; + KantenLaenge[2] = cv::sqrt(diff.x*diff.x + diff.y*diff.y);//right + diff=corners[1] - corners[3]; + KantenLaenge[6] = cv::sqrt(diff.x*diff.x + diff.y*diff.y);//left + diff=corners[0] - corners[1]; + KantenLaenge[4] = cv::sqrt(diff.x*diff.x + diff.y*diff.y); + diff=corners[3] - corners[2]; + KantenLaenge[0] = cv::sqrt(diff.x*diff.x + diff.y*diff.y); return tabs; } diff --git a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h index 66ea9f2..fd36c10 100644 --- a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h +++ b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h @@ -79,12 +79,15 @@ public: Point getMidpoint(){return midpoint;} void setMidpoint(Point m ){midpoint = m;} vector getPoempelPosition(){return PoempelPosition;} + vector getKantenLaenge(){return KantenLaenge;} void setPoempelPosition(vector& newPP){PoempelPosition=newPP;} + void setKantenLaenge(vector& newKL){KantenLaenge=newKL;} vector getCorners(){return corners;} private: Mat image; vector PoempelPosition; + vector KantenLaenge; vector corners; vector> contour; vector hierarchy; @@ -104,12 +107,13 @@ public: 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 getKantenLaenge(int i){return masks[i].getKantenLaenge();} 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&); + unsigned char analyseContour(vector, vector,vector&,vector&); Mat makeBorder(Mat&); Mat readImages(int); Mat morphDilateErode(Mat&); diff --git a/Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge.cpp b/Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge.cpp new file mode 100644 index 0000000..cbcca34 --- /dev/null +++ b/Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge.cpp @@ -0,0 +1,90 @@ +#include "AbstractionLayer_KantenLaenge.h" +#include "../../../header.h" + +bool AbstractionLayer_KantenLaenge::PreProcessing(coor mySize, const vector* partArray) +{ + //get layer information here + cout << "Abstraction Poempel Position Preprocessing... " << flush; + + InitialiseConstraintMatrixSize(mySize.col, mySize.row); + + cout << "Done" << endl; + return true; +} + +//it through qualityVector and removes all that do not trigger PlaceOfPartGood +bool AbstractionLayer_KantenLaenge::EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector) +{ + for(int i = 0;im_a2.SideLength); + qVector[i].first=value; + } +} + +bool AbstractionLayer_KantenLaenge::SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_KantenLaenge_Properties constraint) +{ + m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].SideLength=constraint.SideLength; +} + +bool AbstractionLayer_KantenLaenge::RemoveConstraintOnPosition(const coor constraintCoordinate) +{ + m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].SideLength={0,0,0,0,0,0,0,0}; +} + +float AbstractionLayer_KantenLaenge::PlaceOfPartGood(coor myCoor, vector myPart) +{ + vector comparePosition={0,0,0,0,0,0,0,0}; + float sum=0; + //create negativePart, watch out for edges + if(myCoor.col>0 && m_constraintMatrix[myCoor.col-1][myCoor.row].SideLength[3])//get right data from left + { + comparePosition[6]=m_constraintMatrix[myCoor.col-1][myCoor.row].SideLength[3]; + comparePosition[7]=m_constraintMatrix[myCoor.col-1][myCoor.row].SideLength[2]; + //sum absolute difference + sum+=abs(comparePosition[6]-myPart[6]); + sum+=abs(comparePosition[7]-myPart[7]); + } + if(myCoor.row>0 && m_constraintMatrix[myCoor.col][myCoor.row-1].SideLength[5])//get bot data from top + { + comparePosition[0]=m_constraintMatrix[myCoor.col][myCoor.row-1].SideLength[5]; + comparePosition[1]=m_constraintMatrix[myCoor.col][myCoor.row-1].SideLength[4]; + //sum absolute difference + sum+=abs(comparePosition[0]-myPart[0]); + sum+=abs(comparePosition[1]-myPart[1]); + + } + if(myCoor.col500) + return 0; + if(sum==0) + return 1; + sum/=500; + return 1-sum; + //check vector against negative part, use sad + //return of well it fits within threshold +} + +//shifts vector i steps to the right (8-2i to the left) +void AbstractionLayer_KantenLaenge_Properties::shift(int i) +{ + rotate(SideLength.begin(),SideLength.begin()+(8-2*i),SideLength.end()); +} diff --git a/Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge.h b/Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge.h new file mode 100644 index 0000000..9dcb753 --- /dev/null +++ b/Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge.h @@ -0,0 +1,22 @@ +#pragma once + +#include "AbstractionLayer_KantenLaenge_Properties.h" +#include "../AbstraktionLayer_Base.h" +#include "opencv2/highgui/highgui.hpp" +#include "opencv2/imgproc/imgproc.hpp" + +using namespace std; +using namespace cv; + +class AbstractionLayer_KantenLaenge : public AbstractionLayer_Base +{ +public: + bool PreProcessing(coor mySize, const vector* partArray) final ; + bool EvaluateQuality ( coor constraintCoordinate, qualityVector& qVector)final; + bool SetConstraintOnPosition( coor constraintCoordinate, AbstractionLayer_KantenLaenge_Properties constraint)final; + bool RemoveConstraintOnPosition( coor constraintCoordinate)final; + + float PlaceOfPartGood(coor myCoor, vector myPart); + +private: +}; \ No newline at end of file diff --git a/Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge_Properties.h b/Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge_Properties.h new file mode 100644 index 0000000..08a20e8 --- /dev/null +++ b/Source/functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge_Properties.h @@ -0,0 +1,19 @@ + +#pragma once +#include +using namespace std; +class AbstractionLayer_KantenLaenge_Properties +{ +public: + AbstractionLayer_KantenLaenge_Properties():SideLength({0,0,0,0,0,0,0,0}){} + float getSideLength(int i){if (i<8 && i>=0)return SideLength[i]; else return -1;}; + void shift(int i); +private: + + vector SideLength; + friend class AbstractionLayer_KantenLaenge; + friend class AbstractionLayer_PoempelPosition; + friend class AbstractionLayer_1; +}; + + diff --git a/Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram.cpp b/Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram.cpp deleted file mode 100644 index 6b9f864..0000000 --- a/Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram.cpp +++ /dev/null @@ -1,176 +0,0 @@ -// -// Created by Niko on 1/11/2018. -// -#include "../../../header.h" -#include "AbstractionLayer_Histogram.h" - -using namespace cv; - -Mat HistogramComparer::readImages(int count) -{ - char name[100]; - Mat corr; - Mat ref_gray; - - sprintf(name, PATH, count); - Mat src = imread(name, 1); - // namedWindow("UP1", WINDOW_AUTOSIZE); - //imshow("UP1",src); - if (!src.data) - { - cerr << "Problem loading image!!!" << endl; - return src; - } - - if(DISPLAY)imshow("src",src); - - Mat im_color; - cvtColor(src, im_color, COLOR_BGR2HSV); - return im_color; - -} - -bool AbstractionLayer_Histogram::PreProcessing(coor mySize, const vector* partArray){ - // HistogramComparer localImage; - cout << "Abstraction 2 Preprocessing... " << flush; - const vector& ref_partArray = *partArray; - HistogramComparer analyse(mySize.row*mySize.col); - Part buf; - int iterator=0; - if(!analyse.getImages()) - { - cerr << "Error occured in getImages!" << endl; - return false; - } - else // hier werden alle vier verschiedenen Rotationsarten 'gleichzeitig' abgespeichert - //TODO rows and cols - - for(int i = 0; i < mySize.row*mySize.col; i++) - { - Mat src_img1 = analyse.readImages(i); - Mat hsv_img1; - /// Convert to HSV - cvtColor(src_img1, hsv_img1, COLOR_BGR2HSV); - - /// Using 50 bins for hue and 60 for saturation - int h_bins = 50; - int s_bins = 60; - int histSize[] = {h_bins, s_bins}; - - // hue varies from 0 to 179, saturation from 0 to 255 - float h_ranges[] = {0, 180}; - float s_ranges[] = {0, 256}; - - const float *ranges[] = {h_ranges, s_ranges}; - - // Use the o-th and 1-st channels - int channels[] = {0, 1}; - - /// Histograms - MatND hist_img1; - - /// Calculate the histograms for the HSV images - calcHist(&hsv_img1, 1, channels, Mat(), hist_img1, 2, histSize, ranges, true, false); - // normalize(hist_img1, hist_img1, 0, 1, NORM_MINMAX, -1, Mat()); - - ref_partArray[iterator]->m_his.image=hsv_img1; - iterator++; - - } - - - InitialiseConstraintMatrixSize(mySize.col, mySize.row); //col row switched in this function - - cout << "Done!" << endl; - return true; - -} - -bool AbstractionLayer_Histogram::EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector){ - - //evaluateQuality = evaluateProbabilaty - for(int i = 0;i < qVector.size();i++) - { - if(PlaceOfPartGood(constraintCoordinate, qVector[i].second->m_his.image)) - { - qVector[i].first=1; - continue; - } - if(constraintCoordinate.row<1 || constraintCoordinate.col < 1 ) - qVector[i].first=0.8; - else - qVector[i].first=0; - } - - -} -bool AbstractionLayer_Histogram::PlaceOfPartGood(coor myCoor, Mat& myPart) -{ - //sets coordinates to correct position for layer - - - if( myCoor.row == 1 && myCoor.col == 1){return true;} - else if(myCoor.col == 1 && myCoor.row >1){ - if(CompareHistogram(m_constraintMatrix[myCoor.col][myCoor.row-1].image, myPart)){ - return true; - } - else return false; - } - - else if( myCoor.row == 1 && myCoor.col >1){ - if(CompareHistogram(m_constraintMatrix[myCoor.col-1][myCoor.row].image, myPart)){ - return true; - } - else return false; - } - else if (myCoor.col > 1 && myCoor.row >1){ - if( CompareHistogram(m_constraintMatrix[myCoor.col][myCoor.row-1].image, myPart) && - CompareHistogram(m_constraintMatrix[myCoor.col-1][myCoor.row].image, myPart)){ - - return true; - } - else return false; - }else return false; - - -} - -bool AbstractionLayer_Histogram::CompareHistogram(Mat hist_img1,Mat hist_img2) -{ - // Correlation - double Correlation = compareHist(hist_img1, hist_img2, CV_COMP_CORREL); - - if(Correlation > 0.95 ){ - - return true; - } - else - return false; -} - -bool AbstractionLayer_Histogram::SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_Histogram_Properties constraint) -{ - m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].image=constraint.image; - //m_constraintMatrix[constraintCoordinate.col+1][constraintCoordinate.row+1].m_connections=constraint.m_connections; -} - -bool AbstractionLayer_Histogram::RemoveConstraintOnPosition(const coor constraintCoordinate) -{ - Mat dummy(1,1,0); - m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].image = dummy; -} -bool HistogramComparer::getImages() { - - Mat src; - - for (int i = 0; i < nr_parts; i++) { - if (DISPLAY) cout << "Bild " << i << endl; - Mat img = readImages(i); - - if (!img.data) { - cerr << "Error: No pic found!!" << endl; - return false; - } - else return true; - } -} \ No newline at end of file diff --git a/Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram.h b/Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram.h deleted file mode 100644 index 9c69ff8..0000000 --- a/Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// Created by Niko on 1/11/2018. -// - -#ifndef MPK_PUZZLE_ABSTRACTIONLAYER_HISTOGRAM_H -#define MPK_PUZZLE_ABSTRACTIONLAYER_HISTOGRAM_H -#define DISPLAY false -//#define PATH "..\\..\\..\\pieces\\%04d.jpg" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/imgproc/imgproc.hpp" -#include "AbstractionLayer_Histogram_Properties.h" -#include "../AbstraktionLayer_Base.h" - -using namespace std; -using namespace cv; - -class AbstractionLayer_Histogram : public AbstractionLayer_Base -{ -public: - bool PreProcessing(coor mySize, const vector* partArray) override ; - bool EvaluateQuality ( coor constraintCoordinate, qualityVector& qVector)override; - bool RemoveConstraintOnPosition( coor constraintCoordinate)override; - bool PlaceOfPartGood(coor myCoor, Mat& myPart); - bool SetConstraintOnPosition( coor constraintCoordinate, AbstractionLayer_Histogram_Properties constraint)override; - qualityVector returnInBox(vector& PuzzleBox); - void printConstraintMatrix(); - bool CompareHistogram(Mat Part, Mat RefPart); - -private: -}; - -class HistogramComparer{ -public: - explicit HistogramComparer(int s = 1008): nr_parts(s){} - Mat readImages(int); - bool getImages(); -private: - int nr_parts; - -}; - -#endif //MPK_PUZZLE_ABSTRACTIONLAYER_HISTOGRAM_H - diff --git a/Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram_Properties.h b/Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram_Properties.h deleted file mode 100644 index bb1270a..0000000 --- a/Source/functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram_Properties.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// Created by Niko on 1/11/2018. -// - -#ifndef MPK_PUZZLE_ABSTRACTIONLAYER_HISTOGRAM_PROPERTIES_H -#define MPK_PUZZLE_ABSTRACTIONLAYER_HISTOGRAM_PROPERTIES_H -#include -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/imgproc/imgproc.hpp" - -using namespace cv; -class AbstractionLayer_Histogram_Properties -{ -public: - AbstractionLayer_Histogram_Properties() : Correlation(-1){} - double getCorrelation(){return Correlation;} - Mat getmHistogram(){return m_Histogram;} - -private: - - double Correlation; - Mat m_Histogram; - Mat image; - friend class AbstractionLayer_Histogram; - - -}; -#endif //MPK_PUZZLE_ABSTRACTIONLAYER_HISTOGRAM_PROPERTIES_H - diff --git a/Source/functions/solve/puzzleExtension.cpp b/Source/functions/solve/puzzleExtension.cpp index 59b6cea..aa93449 100644 --- a/Source/functions/solve/puzzleExtension.cpp +++ b/Source/functions/solve/puzzleExtension.cpp @@ -70,7 +70,7 @@ void Puzzle::removeConstrains(coor removeCoordinates) this->a3.RemoveConstraintOnPosition(removeCoordinates); this->a4.RemoveConstraintOnPosition(removeCoordinates); this->acm.RemoveConstraintOnPosition(removeCoordinates); - this->his.RemoveConstraintOnPosition(removeCoordinates); + this->a2.RemoveConstraintOnPosition(removeCoordinates); //TODO!! Add other layer remove here } void Puzzle::setConstraints(coor setConstraints, Part* constraintPiece) @@ -93,7 +93,7 @@ void Puzzle::setConstraints(coor setConstraints, Part* constraintPiece) this->acm.SetConstraintOnPosition(setConstraints,constraintPiece->m_acm); //his - this->his.SetConstraintOnPosition(setConstraints,constraintPiece->m_his); + this->a2.SetConstraintOnPosition(setConstraints,constraintPiece->m_a2); //TODO!! Add other layer remove here } diff --git a/Source/functions/solve/structure.cpp b/Source/functions/solve/structure.cpp index 883f2bd..9a66c18 100755 --- a/Source/functions/solve/structure.cpp +++ b/Source/functions/solve/structure.cpp @@ -58,27 +58,25 @@ coor calculateNextCoor(vector& log, Puzzle& puzzleMat) { if (log.size() == 1) -// return {0,0}; -return {1,1}; + return {0,0}; unsigned int col= log.rbegin()[1].myCoor.col; unsigned int row= log.rbegin()[1].myCoor.row; //level 2 edges first -// if(col == 0 && row < 27) -// return {col,++row}; -// if(row== 27 && col < 35) -// return {++col,row}; -// if(col == 35 && row >0) -// return {col, --row}; -// if(col >1&& row ==0) -// return{--col,row}; -// if(col==1 && row==0) -// return {1,1}; + if(col == 0 && row < 27) + return {col,++row}; + if(row== 27 && col < 35) + return {++col,row}; + if(col == 35 && row >0) + return {col, --row}; + if(col >1&& row ==0) + return{--col,row}; + if(col==1 && row==0) + return {1,1}; - -// log.pop_back();//vis only!!! -// puzzleMat.resultImage(log);//vis only!!! + log.pop_back();//vis only!!! + puzzleMat.resultImage(log);//vis only!!! if(row& log,Puzzle& puzzleMat) //TODO!! Add more layers here switch(log.back().abstractionLevel) { - case 10://pömpel + case 0://pömpel puzzleMat.a1.EvaluateQuality(log.back().myCoor,log.back().PieceCollector); break; - case 2://SURFFeature + case 4://SURFFeature // return; puzzleMat.a4.EvaluateQuality(log.back().myCoor,log.back().PieceCollector); break; @@ -117,8 +115,8 @@ void solve(vector& log,Puzzle& puzzleMat) case 1://color puzzleMat.acm.EvaluateQuality(log.back().myCoor,log.back().PieceCollector); break; - case 0://histogram - puzzleMat.his.EvaluateQuality(log.back().myCoor,log.back().PieceCollector); + case 2://KantenLaenge + puzzleMat.a2.EvaluateQuality(log.back().myCoor,log.back().PieceCollector); break; case -1://random setsolution(log,puzzleMat); diff --git a/Source/header/input.h b/Source/header/input.h index 794e16b..61f13be 100755 --- a/Source/header/input.h +++ b/Source/header/input.h @@ -10,7 +10,7 @@ #include "../functions/AbstractionLayers/Layer3_PoempelPosition/AbstractionLayer_PoempelPosition_Properties.h" #include "../functions/AbstractionLayers/Layer_ColorMatching/AbstractionLayer_ColorMatching_Properties.h" #include "../functions/AbstractionLayers/Layer_SURFFeatures/AbstractionLayer_SURFFeatures_Properties.h" -#include "../functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram_Properties.h" +#include "../functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge_Properties.h" class LayerContainer; class Part @@ -47,7 +47,7 @@ public: AbstractionLayer_PoempelPosition_Properties m_a3; AbstractionLayer_SURFFeatures_Properties m_a4; AbstractionLayer_ColorMatching_Properties m_acm; - AbstractionLayer_Histogram_Properties m_his; + AbstractionLayer_KantenLaenge_Properties m_a2; private: int32_t m_partID; uint8_t m_numOfRotations; diff --git a/Source/header/solve.h b/Source/header/solve.h index c1447ad..7ff0872 100755 --- a/Source/header/solve.h +++ b/Source/header/solve.h @@ -9,7 +9,7 @@ #include "../functions/AbstractionLayers/Layer3_PoempelPosition/AbstractionLayer_PoempelPosition.h" #include "../functions/AbstractionLayers/Layer_SURFFeatures/AbstractionLayer_SURFFeatures.h" #include "../functions/AbstractionLayers/Layer_ColorMatching/AbstractionLayer_ColorMatching.h" -#include "../functions/AbstractionLayers/Layer_Histogram/AbstractionLayer_Histogram.h" +#include "../functions/AbstractionLayers/Layer2_KantenLaenge/AbstractionLayer_KantenLaenge.h" #include "../functions/AbstractionLayers/DestructionPower/DestructionPower.h" using namespace std; @@ -57,7 +57,7 @@ public: if(!a3.PreProcessing({cols,rows}, &p_myBox)) return false; if(!a4.PreProcessing({cols,rows}, &p_myBox)) return false; if(!acm.PreProcessing({cols,rows}, &p_myBox)) return false; - if(!his.PreProcessing({cols,rows}, &p_myBox)) return false; + if(!a2.PreProcessing({cols,rows}, &p_myBox)) return false; return true; } @@ -69,7 +69,7 @@ public: AbstractionLayer_PoempelPosition a3; AbstractionLayer_SURFFeatures a4; AbstractionLayer_ColorMatching acm; - AbstractionLayer_Histogram his; + AbstractionLayer_KantenLaenge a2; void removeConstrains(coor removeCoordinates); void setConstraints(coor setConstraints, Part *constraintPiece);