removed calls to other layers to get into solver
problem with imread in preprocess when multiple layers make call. This was subv. by deactivating these layers.
This commit is contained in:
parent
3a57fbd5e9
commit
7920e73bfb
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
//TODO!! increase Destructioncount
|
//TODO!! increase Destructioncount
|
||||||
#define DESTRUCTION_COUNT 3
|
#define DESTRUCTION_COUNT 1
|
||||||
|
|
||||||
#include "DestructionPower_Properties.h"
|
#include "DestructionPower_Properties.h"
|
||||||
#include "../AbstraktionLayer_Base.h"
|
#include "../AbstraktionLayer_Base.h"
|
||||||
|
@ -271,7 +271,7 @@ Mat analyseParts::readImages(int count)
|
|||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DISPLAY)imshow("src",src);
|
//if(DISPLAY)imshow("src",src);
|
||||||
|
|
||||||
Mat im_gray, im_bw;
|
Mat im_gray, im_bw;
|
||||||
cvtColor(src, im_gray, CV_RGB2GRAY);
|
cvtColor(src, im_gray, CV_RGB2GRAY);
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
//
|
|
||||||
// Created by mpapa on 05.12.2017.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef SOURCE_ABSTRACTIONLAYER_1_H
|
#ifndef SOURCE_ABSTRACTIONLAYER_1_H
|
||||||
#define SOURCE_ABSTRACTIONLAYER_1_H
|
#define SOURCE_ABSTRACTIONLAYER_1_H
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#define SOURCE_ABSTRACTIONLAYER_SURFFEATURES_H
|
#define SOURCE_ABSTRACTIONLAYER_SURFFEATURES_H
|
||||||
|
|
||||||
#include "../AbstraktionLayer_Base.h"
|
#include "../AbstraktionLayer_Base.h"
|
||||||
|
#include "opencv2/highgui/highgui.hpp"
|
||||||
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define PATH_FULL_PUZZLE "..\\..\\..\\puzzle_img\\puzzle1.jpg"
|
#define PATH_FULL_PUZZLE "..\\..\\..\\puzzle_img\\puzzle1.jpg"
|
||||||
|
@ -65,23 +65,23 @@ void Puzzle::shuffle()
|
|||||||
//deletes all constraints from all abstractionlayers
|
//deletes all constraints from all abstractionlayers
|
||||||
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
|
||||||
}
|
}
|
||||||
void Puzzle::setConstraints(coor setConstraints, Part* constraintPiece)
|
void Puzzle::setConstraints(coor setConstraints, Part* constraintPiece)
|
||||||
{
|
{
|
||||||
//dp
|
//dp
|
||||||
this->dp.m_constraintMatrix[setConstraints.col][setConstraints.row].DestructionArray.clear();
|
// this->dp.m_constraintMatrix[setConstraints.col][setConstraints.row].DestructionArray.clear();
|
||||||
for(auto it:this->tmp_destructionArray)
|
// for(auto it:this->tmp_destructionArray)
|
||||||
this->dp.m_constraintMatrix[setConstraints.col][setConstraints.row].DestructionArray.emplace_back(it);
|
// this->dp.m_constraintMatrix[setConstraints.col][setConstraints.row].DestructionArray.emplace_back(it);
|
||||||
|
|
||||||
//a1
|
//a1
|
||||||
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);
|
||||||
@ -187,7 +187,6 @@ Mat Puzzle::resultImage( vector<LogEntry>& log){
|
|||||||
|
|
||||||
sprintf(name, PATH, imageNumber);
|
sprintf(name, PATH, imageNumber);
|
||||||
Mat img = imread(name, 1);
|
Mat img = imread(name, 1);
|
||||||
|
|
||||||
copyMakeBorder(img,img,200,200,200,200,BORDER_CONSTANT,Scalar(255,255,255));
|
copyMakeBorder(img,img,200,200,200,200,BORDER_CONSTANT,Scalar(255,255,255));
|
||||||
Mat invert = Mat::ones(img.size(), CV_8UC3); // invert for rotation to work correctly
|
Mat invert = Mat::ones(img.size(), CV_8UC3); // invert for rotation to work correctly
|
||||||
bitwise_not ( img, invert );
|
bitwise_not ( img, invert );
|
||||||
|
@ -43,7 +43,7 @@ void createNextLogElement(vector<LogEntry>& log, Puzzle& puzzleMat)
|
|||||||
{
|
{
|
||||||
log.emplace_back(LogEntry(coor(0, 0)));
|
log.emplace_back(LogEntry(coor(0, 0)));
|
||||||
log.back().myCoor = calculateNextCoor(log, puzzleMat);
|
log.back().myCoor = calculateNextCoor(log, puzzleMat);
|
||||||
puzzleMat.dp.DestructionOfSurrounding(log.back().myCoor);//calculate dp from surrounding
|
// puzzleMat.dp.DestructionOfSurrounding(log.back().myCoor);//calculate dp from surrounding
|
||||||
//get all not set pieces
|
//get all not set pieces
|
||||||
for(auto it:puzzleMat.p_myBox)
|
for(auto it:puzzleMat.p_myBox)
|
||||||
if(!it->set)
|
if(!it->set)
|
||||||
@ -78,13 +78,15 @@ void solve(vector<LogEntry>& log,Puzzle& puzzleMat)
|
|||||||
switch(log.back().abstractionLevel)
|
switch(log.back().abstractionLevel)
|
||||||
{
|
{
|
||||||
case 0://pömpel
|
case 0://pömpel
|
||||||
puzzleMat.a1.EvaluateQuality(log.back().myCoor, log.back().PieceCollector);
|
puzzleMat.a4.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
|
||||||
|
//puzzleMat.a1.EvaluateQuality(log.back().myCoor, log.back().PieceCollector);
|
||||||
break;
|
break;
|
||||||
case 1://poempelposition
|
case 1://poempelposition
|
||||||
|
return;
|
||||||
puzzleMat.a3.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
|
puzzleMat.a3.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
|
||||||
break;
|
break;
|
||||||
case 4://SURFFeature
|
case 4://SURFFeature
|
||||||
puzzleMat.a3.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
|
|
||||||
break;
|
break;
|
||||||
case -1://random
|
case -1://random
|
||||||
cout << endl;
|
cout << endl;
|
||||||
@ -95,10 +97,8 @@ void solve(vector<LogEntry>& log,Puzzle& puzzleMat)
|
|||||||
}
|
}
|
||||||
float worth = capLogElements(log);
|
float worth = capLogElements(log);
|
||||||
cout << " | " << worth << endl;
|
cout << " | " << worth << endl;
|
||||||
if(worth && log.back().abstractionLevel)
|
|
||||||
cerr << "removed something!" << endl;
|
|
||||||
|
|
||||||
calculateTrueDestructionPower(log,puzzleMat, worth);
|
// calculateTrueDestructionPower(log,puzzleMat, worth);
|
||||||
CalculateNewCombinedQuality(log, log.back().PieceCollector, puzzleMat.combinedQualityVector);
|
CalculateNewCombinedQuality(log, log.back().PieceCollector, puzzleMat.combinedQualityVector);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ float capLogElements(vector<LogEntry>& log)
|
|||||||
newid = id;
|
newid = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cut(log,newid);
|
//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;
|
||||||
@ -241,7 +241,11 @@ 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())
|
||||||
|
{
|
||||||
|
cerr << "!";
|
||||||
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 --------------------
|
||||||
|
@ -44,9 +44,9 @@ public:
|
|||||||
bool PreProcessing()
|
bool PreProcessing()
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -25,6 +25,6 @@ int main()
|
|||||||
puzzleMat.resultImage(log);
|
puzzleMat.resultImage(log);
|
||||||
|
|
||||||
|
|
||||||
puzzleMat.printPuzzle();
|
//puzzleMat.printPuzzle();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user