added base structure into code

needs picture information
expanded evaluation prototype
This commit is contained in:
Raphael Maenle 2018-01-20 16:02:44 +01:00
parent 9863c8b9e8
commit 5950ba7c5e
12 changed files with 112 additions and 69 deletions

View File

@ -10,6 +10,7 @@ set(SOURCE_FILES
functions/solve/structure.cpp
functions/AbstractionLayers/AbstraktionLayer_Base.h
functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp
functions/AbstractionLayers/Layer3_PoempelPosition/AbstractionLayer_PoempelPosition.cpp
functions/AbstractionLayers/DestructionPower/DestructionPower.cpp
header/solve.h
header/input.h

View File

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

View File

@ -36,7 +36,7 @@ bool AbstractionLayer_1::PreProcessing(coor mySize, const vector<Part*>* partAr
//Zugriff auf den vector mit den einzelnen teilen: part[0].getConnenctions() entspricht pömpel von bild 0.jpg und liefert ein unsigned char, poempl Belegung wie ausgemacht
InitialiseConstraintMatrixSize(mySize.col+2, mySize.row+2); //col row switched in this function
InitialiseConstraintMatrixSize(mySize.col+2, mySize.row+2);
setEdgeZero();
cout << "Done!" << endl;
@ -73,15 +73,11 @@ int AbstractionLayer_1::PoempelSum(uint8_t constraint)
//it through qualityVector and removes all that do not trigger PlaceOfPartGood
bool AbstractionLayer_1::EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector)
{
if(constraintCoordinate.row==23 && constraintCoordinate.col==35)
cout << "in" << endl;
//evaluateQuality = evaluateProbabilaty
for(int i = 0;i<qVector.size();i++)
{
if(PlaceOfPartGood(constraintCoordinate, qVector[i].second->m_a1.m_connections))
{
qVector[i].first=1;
continue;
}
qVector[i].first=0;

View File

@ -45,10 +45,10 @@ using namespace cv;
class AbstractionLayer_1 : public AbstractionLayer_Base<AbstractionLayer_1_Properties>
{
public:
bool PreProcessing(coor mySize, const vector<Part*>* partArray) override ;
bool EvaluateQuality ( coor constraintCoordinate, qualityVector& qVector)override;
bool SetConstraintOnPosition( coor constraintCoordinate, AbstractionLayer_1_Properties constraint)override;
bool RemoveConstraintOnPosition( coor constraintCoordinate)override;
bool PreProcessing(coor mySize, const vector<Part*>* 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);

View File

@ -0,0 +1,56 @@
#include "AbstractionLayer_PoempelPosition.h"
#include "../../../header.h"
bool AbstractionLayer_PoempelPosition::PreProcessing(coor mySize, const vector<Part*>* partArray)
{
//get layer information here
cout << "Abstraction Poempel Position Preprocessing... " << flush;
InitialiseConstraintMatrixSize(mySize.col, mySize.row);
cout << "Done" << endl;
return false;
}
//it through qualityVector and removes all that do not trigger PlaceOfPartGood
bool AbstractionLayer_PoempelPosition::EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector)
{
for(int i = 0;i<qVector.size();i++)
{
float value = PlaceOfPartGood(constraintCoordinate, qVector[i].second->m_a3.SideLength));
if(value > 0.8)//TODO find threshold
{
qVector[i].first=value;
continue;
}
qVector[i].first=0;
}
}
bool AbstractionLayer_PoempelPosition::SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_PoempelPosition_Properties constraint)
{
m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].SideLength=constraint.SideLength;
}
bool AbstractionLayer_PoempelPosition::RemoveConstraintOnPosition(const coor constraintCoordinate)
{
m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].SideLength={0,0,0,0,0,0,0,0};
}
float AbstractionLayer_PoempelPosition::PlaceOfPartGood(coor myCoor, vector<float> myPart)
{
//sets coordinates to correct position for layer
//create negativePart, watch out for edges
//check vector against negative part
//return of well it fits within threshold
}
//shifts vector i steps to the right (8-2i to the left)
void AbstractionLayer_PoempelPosition_Properties::shift(int i)
{
rotate(SideLength.begin(),SideLength.begin()+(8-2*i),SideLength.end());
}

View File

@ -0,0 +1,22 @@
#pragma once
#include "AbstractionLayer_PoempelPosition_Properties.h"
#include "../AbstraktionLayer_Base.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace std;
using namespace cv;
class AbstractionLayer_PoempelPosition : public AbstractionLayer_Base<AbstractionLayer_PoempelPosition_Properties>
{
public:
bool PreProcessing(coor mySize, const vector<Part*>* partArray) final ;
bool EvaluateQuality ( coor constraintCoordinate, qualityVector& qVector)final;
bool SetConstraintOnPosition( coor constraintCoordinate, AbstractionLayer_PoempelPosition_Properties constraint)final;
bool RemoveConstraintOnPosition( coor constraintCoordinate)final;
float PlaceOfPartGood(coor myCoor, vector<float> myPart);
private:
};

View File

@ -0,0 +1,17 @@
#pragma once
#include <vector>
using namespace std;
class AbstractionLayer_PoempelPosition_Properties
{
public:
AbstractionLayer_PoempelPosition_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<float> SideLength;
friend class AbstractionLayer_PoempelPosition;
};

View File

@ -1,35 +0,0 @@
//
// Created by Niko on 1/15/2018.
//
#ifndef MPK_PUZZLE_ABSTRACTIONLAYER_MEANDIFFERENCE_H
#define MPK_PUZZLE_ABSTRACTIONLAYER_MEANDIFFERENCE_H
#define DISPLAY false
#define PATH "..\\..\\..\\pieces\\%04d.jpg"
using namespace std;
using namespace cv;
class AbstractionLayer_MeanDifference : public AbstractionLayer_Base<AbstractionLayer_MeanDifference_Properties>
{
public:
bool PreProcessing(coor mySize, const vector<Part*>* partArray) override ;
bool EvaluateQuality ( coor constraintCoordinate, qualityVector& qVector)override;
bool SetConstraintOnPosition( coor constraintCoordinate, AbstractionLayer_1_Properties constraint)override;
bool RemoveConstraintOnPosition( coor constraintCoordinate)override;
bool PlaceOfPartGood(coor myCoor, Mat& myPart);
qualityVector returnInBox(vector<Part>& PuzzleBox);
void printConstraintMatrix();
private:
};
class cMeanDifference{
public:
Mat readImages(int);
bool calculateMeanDifference(Mat Part, Mat RefPart);
private:
};
#endif //MPK_PUZZLE_ABSTRACTIONLAYER_MEANDIFFERENCE_H

View File

@ -1,20 +0,0 @@
//
// Created by Niko on 1/15/2018.
//
#ifndef MPK_PUZZLE_ABSTRACTIONLAYER_MEANDIFFERENCE_PROPERTIES_H
#define MPK_PUZZLE_ABSTRACTIONLAYER_MEANDIFFERENCE_PROPERTIES_H
class AbstractionLayer_MeanDifference_Properties
{
public:
AbstractionLayer_MeanDifference_Properties() : MeanDifference(-1){}
double getMeanDifference(){return MeanDifference;};
private:
double MeanDifference;
friend class AbstractionLayer_MeanDifference;
Mat image;
};
#endif //MPK_PUZZLE_ABSTRACTIONLAYER_MEANDIFFERENCE_PROPERTIES_H

View File

@ -37,12 +37,14 @@ void Puzzle::putIntoBox()
{
tmpPart.m_a1=this->a1.m_constraintMatrix[i+1][j+1];
tmpPart.m_a3=this->a3.m_constraintMatrix[i][j];
//sets part id
tmpPart.SetPartID(id++);
// adds all 4 rotations to Box
for(int rotations=0;rotations<4;rotations++)
{
tmpPart.m_a1.shift(1);
tmpPart.m_a3.shift(1);
//TODO! add all other layer with their rotaionvariance into "tmpPart"
//if it piece is roation invariant no need to do anything
myBox.emplace_back(tmpPart);
@ -63,6 +65,7 @@ void Puzzle::shuffle()
void Puzzle::removeConstrains(coor removeCoordinates)
{
this->a1.RemoveConstraintOnPosition(removeCoordinates);
this->a3.RemoveConstraintOnPosition(removeCoordinates);
//TODO!! Add other layer remove here
}
void Puzzle::setConstraints(coor setConstraints, Part* constraintPiece)
@ -75,6 +78,8 @@ void Puzzle::setConstraints(coor setConstraints, Part* constraintPiece)
//a1
this->a1.SetConstraintOnPosition(setConstraints,constraintPiece->m_a1);
//a3
this->a3.SetConstraintOnPosition(setConstraints,constraintPiece->m_a3);
//TODO!! Add other layer remove here
}
@ -139,6 +144,7 @@ Mat Puzzle::readImage(int fileIndex, const char* inputDir){
Mat source = imread(inputstr,1);
return source;
}
Mat Puzzle::resultImage( vector<LogEntry>& log){
int Y_size = 1200; // chose this to fit your monitor!
int separator = 1;

View File

@ -8,7 +8,7 @@
#include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1_Properties.h"
#include "../functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h"
#include "../functions/AbstractionLayers/Layer3_PoempelPosition/AbstractionLayer_PoempelPosition_Properties.h"
class LayerContainer;
class Part
@ -42,6 +42,7 @@ public:
bool set;
AbstractionLayer_1_Properties m_a1;
AbstractionLayer_PoempelPosition_Properties m_a3;
private:
int32_t m_partID;
uint8_t m_numOfRotations;

View File

@ -1,6 +1,3 @@
//
// Created by mpapa on 05.12.2017.
//
#pragma once
#include <vector>
#include <iostream>
@ -8,6 +5,7 @@
#include <opencv2/imgproc/imgproc.hpp>
#include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1.h"
#include "../functions/AbstractionLayers/Layer3_PoempelPosition/AbstractionLayer_PoempelPosition.h"
#include "../functions/AbstractionLayers/DestructionPower/DestructionPower.h"
using namespace std;
@ -54,6 +52,7 @@ public:
DestructionPower dp;
AbstractionLayer_1 a1;
AbstractionLayer_PoempelPosition a3;
void removeConstrains(coor removeCoordinates);
void setConstraints(coor setConstraints, Part *constraintPiece);