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:
Raphael Maenle 2018-01-26 22:27:46 +01:00
parent 3a57fbd5e9
commit 7920e73bfb
8 changed files with 26 additions and 25 deletions

View File

@ -1,6 +1,6 @@
#pragma once
//TODO!! increase Destructioncount
#define DESTRUCTION_COUNT 3
#define DESTRUCTION_COUNT 1
#include "DestructionPower_Properties.h"
#include "../AbstraktionLayer_Base.h"

View File

@ -271,7 +271,7 @@ Mat analyseParts::readImages(int count)
return src;
}
if(DISPLAY)imshow("src",src);
//if(DISPLAY)imshow("src",src);
Mat im_gray, im_bw;
cvtColor(src, im_gray, CV_RGB2GRAY);

View File

@ -1,7 +1,3 @@
//
// Created by mpapa on 05.12.2017.
//
#ifndef SOURCE_ABSTRACTIONLAYER_1_H
#define SOURCE_ABSTRACTIONLAYER_1_H

View File

@ -2,6 +2,8 @@
#define SOURCE_ABSTRACTIONLAYER_SURFFEATURES_H
#include "../AbstraktionLayer_Base.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#ifdef _WIN32
#define PATH_FULL_PUZZLE "..\\..\\..\\puzzle_img\\puzzle1.jpg"

View File

@ -65,23 +65,23 @@ void Puzzle::shuffle()
//deletes all constraints from all abstractionlayers
void Puzzle::removeConstrains(coor removeCoordinates)
{
this->a1.RemoveConstraintOnPosition(removeCoordinates);
this->a3.RemoveConstraintOnPosition(removeCoordinates);
// this->a1.RemoveConstraintOnPosition(removeCoordinates);
// this->a3.RemoveConstraintOnPosition(removeCoordinates);
this->a4.RemoveConstraintOnPosition(removeCoordinates);
//TODO!! Add other layer remove here
}
void Puzzle::setConstraints(coor setConstraints, Part* constraintPiece)
{
//dp
this->dp.m_constraintMatrix[setConstraints.col][setConstraints.row].DestructionArray.clear();
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.clear();
// for(auto it:this->tmp_destructionArray)
// this->dp.m_constraintMatrix[setConstraints.col][setConstraints.row].DestructionArray.emplace_back(it);
//a1
this->a1.SetConstraintOnPosition(setConstraints,constraintPiece->m_a1);
//this->a1.SetConstraintOnPosition(setConstraints,constraintPiece->m_a1);
//a3
this->a3.SetConstraintOnPosition(setConstraints,constraintPiece->m_a3);
//this->a3.SetConstraintOnPosition(setConstraints,constraintPiece->m_a3);
//a4
this->a4.SetConstraintOnPosition(setConstraints,constraintPiece->m_a4);
@ -187,7 +187,6 @@ Mat Puzzle::resultImage( vector<LogEntry>& log){
sprintf(name, PATH, imageNumber);
Mat img = imread(name, 1);
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
bitwise_not ( img, invert );

View File

@ -43,7 +43,7 @@ void createNextLogElement(vector<LogEntry>& log, Puzzle& puzzleMat)
{
log.emplace_back(LogEntry(coor(0, 0)));
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
for(auto it:puzzleMat.p_myBox)
if(!it->set)
@ -78,13 +78,15 @@ void solve(vector<LogEntry>& log,Puzzle& puzzleMat)
switch(log.back().abstractionLevel)
{
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;
case 1://poempelposition
return;
puzzleMat.a3.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
break;
case 4://SURFFeature
puzzleMat.a3.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
break;
case -1://random
cout << endl;
@ -95,10 +97,8 @@ void solve(vector<LogEntry>& log,Puzzle& puzzleMat)
}
float worth = capLogElements(log);
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);
}
@ -227,7 +227,7 @@ float capLogElements(vector<LogEntry>& log)
newid = id;
}
}
cut(log,newid);
//cut(log,newid);
vectorsizeAfter = log.back().PieceCollector.size();
destroyed = ((double)vectorsizeBefore - (double)vectorsizeAfter) / (double)vectorsizeBefore;
@ -241,7 +241,11 @@ float capLogElements(vector<LogEntry>& log)
void cut(vector<LogEntry>& log, int& cutID)
{
while(cutID<log.back().PieceCollector.size())
{
cerr << "!";
log.back().PieceCollector.erase(log.back().PieceCollector.begin()+cutID);
}
cerr << endl;
}
// -------------------- Part David: SetBest and CalculateCombinedQuality --------------------

View File

@ -44,9 +44,9 @@ public:
bool PreProcessing()
{
createBox(); createp_box();
/*if(!dp.PreProcessing({cols,rows}, nullptr)) return false;
if(!a1.PreProcessing({cols,rows}, &p_myBox)) return false;
if(!a3.PreProcessing({cols,rows}, &p_myBox)) return false;*/
// if(!dp.PreProcessing({cols,rows}, nullptr)) return false;
// if(!a1.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;
return true;

View File

@ -25,6 +25,6 @@ int main()
puzzleMat.resultImage(log);
puzzleMat.printPuzzle();
//puzzleMat.printPuzzle();
return 0;
}