removed minor changes

This commit is contained in:
Raphael Maenle 2018-01-27 16:06:03 +01:00
parent d3d7d53a45
commit e906b63dc1
5 changed files with 19 additions and 26 deletions

View File

@ -22,7 +22,7 @@
#define DISPLAY false #define DISPLAY false
#ifdef _WIN32 #ifdef _WIN32
#define PATH "..\\..\\..\\pieces\\%04d.jpg" #define PATH "..\\..\\..\\pieces_bb\\%04d.jpg"
#elif defined __unix__ #elif defined __unix__
#define PATH "..//..//..//pieces//%04d.jpg" #define PATH "..//..//..//pieces//%04d.jpg"
#elif defined __APPLE__ #elif defined __APPLE__

View File

@ -6,7 +6,7 @@
#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/imgproc/imgproc.hpp"
#ifdef _WIN32 #ifdef _WIN32
#define PATH_FULL_PUZZLE "..\\..\\..\\puzzle_img\\puzzle2.jpg" #define PATH_FULL_PUZZLE "..\\..\\..\\puzzle_img_bb\\puzzle2.jpg"
#elif defined __unix__ #elif defined __unix__
#define PATH_FULL_PUZZLE "..//..//..//puzzle_img//puzzle1.jpg" #define PATH_FULL_PUZZLE "..//..//..//puzzle_img//puzzle1.jpg"
#elif defined __APPLE__ #elif defined __APPLE__
@ -14,7 +14,7 @@
#endif #endif
#ifdef _WIN32 //TODO: Code duplicate from AbstractionLayer_1.h #ifdef _WIN32 //TODO: Code duplicate from AbstractionLayer_1.h
#define PATH1 "..\\..\\..\\pieces\\%04d.jpg" #define PATH1 "..\\..\\..\\pieces_bb\\%04d.jpg"
#elif defined __unix__ #elif defined __unix__
#define PATH1 "..//..//..//pieces//%04d.jpg" #define PATH1 "..//..//..//pieces//%04d.jpg"
#elif defined __APPLE__ #elif defined __APPLE__

View File

@ -66,7 +66,7 @@ void Puzzle::shuffle()
void Puzzle::removeConstrains(coor removeCoordinates) void Puzzle::removeConstrains(coor removeCoordinates)
{ {
this->a1.RemoveConstraintOnPosition(removeCoordinates); this->a1.RemoveConstraintOnPosition(removeCoordinates);
//this->a3.RemoveConstraintOnPosition(removeCoordinates); this->a3.RemoveConstraintOnPosition(removeCoordinates);
this->a4.RemoveConstraintOnPosition(removeCoordinates); this->a4.RemoveConstraintOnPosition(removeCoordinates);
//TODO!! Add other layer remove here //TODO!! Add other layer remove here
} }
@ -81,7 +81,7 @@ void Puzzle::setConstraints(coor setConstraints, Part* constraintPiece)
this->a1.SetConstraintOnPosition(setConstraints,constraintPiece->m_a1); this->a1.SetConstraintOnPosition(setConstraints,constraintPiece->m_a1);
//a3 //a3
//this->a3.SetConstraintOnPosition(setConstraints,constraintPiece->m_a3); this->a3.SetConstraintOnPosition(setConstraints,constraintPiece->m_a3);
//a4 //a4
this->a4.SetConstraintOnPosition(setConstraints,constraintPiece->m_a4); this->a4.SetConstraintOnPosition(setConstraints,constraintPiece->m_a4);

View File

@ -72,8 +72,7 @@ coor calculateNextCoor(vector<LogEntry>& log, Puzzle& puzzleMat)
void solve(vector<LogEntry>& log,Puzzle& puzzleMat) void solve(vector<LogEntry>& log,Puzzle& puzzleMat)
{ {
log.back().abstractionLevel = puzzleMat.dp.getNextAbstractionLayer(log.back().myCoor,log.back().abstractionLevel); //sets in abstractionLevel log.back().abstractionLevel = puzzleMat.dp.getNextAbstractionLayer(log.back().myCoor,log.back().abstractionLevel); //sets in abstractionLevel
cout << "abs: " << log.back().abstractionLevel; //status(log,p_Box,puzzleMat);
//status(log,p_Box,puzzleMat);
//TODO!! Add more layers here //TODO!! Add more layers here
switch(log.back().abstractionLevel) switch(log.back().abstractionLevel)
{ {
@ -81,14 +80,14 @@ void solve(vector<LogEntry>& log,Puzzle& puzzleMat)
puzzleMat.a1.EvaluateQuality(log.back().myCoor,log.back().PieceCollector); puzzleMat.a1.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
//puzzleMat.a1.EvaluateQuality(log.back().myCoor, log.back().PieceCollector); //puzzleMat.a1.EvaluateQuality(log.back().myCoor, log.back().PieceCollector);
break; break;
case 1://poempelposition case 1://SURFFeature
// return; // return;
puzzleMat.a4.EvaluateQuality(log.back().myCoor,log.back().PieceCollector); puzzleMat.a4.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
break; break;
case 4://SURFFeature case 2://poempelposition
puzzleMat.a3.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
break; break;
case -1://random case -1://random
cout << endl;
setsolution(log,puzzleMat); setsolution(log,puzzleMat);
return; return;
default: default:
@ -117,12 +116,11 @@ void setsolution(vector<LogEntry>& log, Puzzle& puzzleMat)
puzzleMat.setConstraints(log.back().myCoor,log.back().PieceCollector.begin()->second); puzzleMat.setConstraints(log.back().myCoor,log.back().PieceCollector.begin()->second);
cout << "set:" << log.back().myCoor.col << "," << log.back().myCoor.row << endl; cout << "set:" << log.back().myCoor.col << "," << log.back().myCoor.row << endl;
//cout << "ID: " << log.back().PieceCollector[0].second->GetPartID() << endl; //cout << "ID: " << log.back().PieceCollector[0].second->GetPartID() << endl;
cout << "Size of Log: " << log.back().PieceCollector.size() << endl; if(log.back().myCoor.col==32 && log.back().myCoor.row==16)
//if(log.back().myCoor.col==32 && log.back().myCoor.row==16) {
//{ puzzleMat.resultImage(log);
// puzzleMat.resultImage(log); waitKey(0);
// waitKey(0); }
// }
} }
bool backtrack(vector<LogEntry>& log, Puzzle& puzzleMat) bool backtrack(vector<LogEntry>& log, Puzzle& puzzleMat)
@ -133,7 +131,6 @@ bool backtrack(vector<LogEntry>& log, Puzzle& puzzleMat)
cout << "Puzzle not solveable!" << endl; cout << "Puzzle not solveable!" << endl;
return false; return false;
} }
cout << "Size of Log: " << log.back().PieceCollector.size() << endl;
puzzleMat.combinedQualityVector.clear(); //remove all data from temp quality save puzzleMat.combinedQualityVector.clear(); //remove all data from temp quality save
//if more pieces possible, tset piece as not logged //if more pieces possible, tset piece as not logged
if((log.back().PieceCollector.size())>1) if((log.back().PieceCollector.size())>1)
@ -144,20 +141,18 @@ bool backtrack(vector<LogEntry>& log, Puzzle& puzzleMat)
//remove similar in log //remove similar in log
Part myPart = *log.back().PieceCollector[0].second;//tmpsaves bad part //Part myPart = *log.back().PieceCollector[0].second;//tmpsaves bad part
log.back().PieceCollector.erase(log.back().PieceCollector.begin());//removes bad part from log log.back().PieceCollector.erase(log.back().PieceCollector.begin());//removes bad part from log
puzzleMat.removeSimilar(log.back().PieceCollector,myPart); //removes all pieces from log that are similar to bad part //puzzleMat.removeSimilar(log.back().PieceCollector,myPart); //removes all pieces from log that are similar to bad part
//TODO reprogram similar removal to allow multilayer tracking //TODO reprogram similar removal to allow multilayer tracking
if(log.back().PieceCollector.size()) // this checks if 'removeSimilar' has cleared entire LogElement if(log.back().PieceCollector.size()) // this checks if 'removeSimilar' has cleared entire LogElement
{ {
cout << "next Piece" << endl;
if(log.back().PieceCollector.size()==1) if(log.back().PieceCollector.size()==1)
log.back().decreaseRandomed(); log.back().decreaseRandomed();
setsolution(log,puzzleMat); setsolution(log,puzzleMat);
return true; return true;
} }
} }
cout << "more backtrack" << endl;
//else remove log element and backtrack once more //else remove log element and backtrack once more
puzzleMat.removeConstrains(log.back().myCoor); //this should remove constraints from all layers puzzleMat.removeConstrains(log.back().myCoor); //this should remove constraints from all layers
if((log.back().PieceCollector.size())) //unset all if((log.back().PieceCollector.size())) //unset all
@ -229,7 +224,8 @@ float capLogElements(vector<LogEntry>& log)
newid = id; newid = id;
} }
} }
cut(log,newid); // if(log.back().abstractionLevel==0)
cut(log,newid);
vectorsizeAfter = log.back().PieceCollector.size(); vectorsizeAfter = log.back().PieceCollector.size();
destroyed = ((double)vectorsizeBefore - (double)vectorsizeAfter) / (double)vectorsizeBefore; destroyed = ((double)vectorsizeBefore - (double)vectorsizeAfter) / (double)vectorsizeBefore;
@ -243,10 +239,7 @@ float capLogElements(vector<LogEntry>& log)
void cut(vector<LogEntry>& log, int& cutID) void cut(vector<LogEntry>& log, int& cutID)
{ {
while(cutID<log.back().PieceCollector.size()) while(cutID<log.back().PieceCollector.size())
{
log.back().PieceCollector.erase(log.back().PieceCollector.begin()+cutID); log.back().PieceCollector.erase(log.back().PieceCollector.begin()+cutID);
}
cerr << endl;
} }
// -------------------- Part David: SetBest and CalculateCombinedQuality -------------------- // -------------------- Part David: SetBest and CalculateCombinedQuality --------------------

View File

@ -46,7 +46,7 @@ public:
createBox(); createp_box(); createBox(); createp_box();
if(!dp.PreProcessing({cols,rows}, nullptr)) return false; if(!dp.PreProcessing({cols,rows}, nullptr)) return false;
if(!a1.PreProcessing({cols,rows}, &p_myBox)) return false; if(!a1.PreProcessing({cols,rows}, &p_myBox)) return false;
// if(!a3.PreProcessing({cols,rows}, &p_myBox)) return false; if(!a3.PreProcessing({cols,rows}, &p_myBox)) return false;
if(!a4.PreProcessing({cols,rows}, &p_myBox)) return false; if(!a4.PreProcessing({cols,rows}, &p_myBox)) return false;
return true; return true;