Fixed errors due to no pictures in pieces folder
This commit is contained in:
parent
4c59e04fa7
commit
cba4d204c8
@ -26,7 +26,7 @@ public:
|
|||||||
* @brief pure virtual method for the pre processing of the layer
|
* @brief pure virtual method for the pre processing of the layer
|
||||||
* @param [in] partArray - References of all Parts, in which the properties of the Layer will be written
|
* @param [in] partArray - References of all Parts, in which the properties of the Layer will be written
|
||||||
*/
|
*/
|
||||||
virtual void PreProcessing(coor mySize, const vector<Part*>* partArray) = 0;
|
virtual bool PreProcessing(coor mySize, const vector<Part*>* partArray) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief pure virtual method for the quality evaluation of the layer
|
* @brief pure virtual method for the quality evaluation of the layer
|
||||||
|
@ -11,9 +11,11 @@ map<int,float> DestructionPower_Properties::SpeedTable =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void DestructionPower::PreProcessing(coor mySize,const vector<Part*>* partArray)
|
bool DestructionPower::PreProcessing(coor mySize,const vector<Part*>* partArray)
|
||||||
{
|
{
|
||||||
InitialiseConstraintMatrixSize(mySize.row,mySize.col);
|
InitialiseConstraintMatrixSize(mySize.row,mySize.col);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//it through qualityVector and removes all that do not trigger PlaceOfPartGood
|
//it through qualityVector and removes all that do not trigger PlaceOfPartGood
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
class DestructionPower : public AbstractionLayer_Base<DestructionPower_Properties>
|
class DestructionPower : public AbstractionLayer_Base<DestructionPower_Properties>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void PreProcessing(coor mySize,const vector<Part*>* partArray)override;
|
bool PreProcessing(coor mySize,const vector<Part*>* partArray)override;
|
||||||
bool EvaluateQuality (coor constraintCoordinate, qualityVector& qVector) override;
|
bool EvaluateQuality (coor constraintCoordinate, qualityVector& qVector) override;
|
||||||
bool SetConstraintOnPosition(coor constraintCoordinate, DestructionPower_Properties constraint);
|
bool SetConstraintOnPosition(coor constraintCoordinate, DestructionPower_Properties constraint);
|
||||||
bool RemoveConstraintOnPosition(coor constraintCoordinate)override;
|
bool RemoveConstraintOnPosition(coor constraintCoordinate)override;
|
||||||
|
@ -8,19 +8,28 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
void AbstractionLayer_1::PreProcessing(coor mySize, const vector<Part*>* partArray)
|
bool AbstractionLayer_1::PreProcessing(coor mySize, const vector<Part*>* partArray)
|
||||||
{
|
{
|
||||||
|
|
||||||
analyseParts analyse(1008);
|
analyseParts analyse(1008);
|
||||||
vector<Part> parts;
|
vector<Part> parts;
|
||||||
Part buf;
|
Part buf;
|
||||||
unsigned char tabs = 0;
|
|
||||||
for(int i = 0; i < 1008; i++){
|
|
||||||
tabs = analyse.getTabs(i);
|
|
||||||
buf.m_a1.m_connections=tabs;
|
|
||||||
parts.push_back(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(!analyse.getImages())
|
||||||
|
{
|
||||||
|
cerr << "Error: No pictures found!" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned char tabs = 0;
|
||||||
|
for(int i = 0; i < 1008; i++)
|
||||||
|
{
|
||||||
|
tabs = analyse.getTabs(i);
|
||||||
|
buf.m_a1.m_connections=tabs;
|
||||||
|
parts.push_back(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//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
|
//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
|
||||||
|
|
||||||
@ -28,6 +37,8 @@ void AbstractionLayer_1::PreProcessing(coor mySize, const vector<Part*>* partAr
|
|||||||
|
|
||||||
InitialiseConstraintMatrixSize(mySize.col+2, mySize.row+2);
|
InitialiseConstraintMatrixSize(mySize.col+2, mySize.row+2);
|
||||||
setEdgeZero();
|
setEdgeZero();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//it through qualityVector and removes all that do not trigger PlaceOfPartGood
|
//it through qualityVector and removes all that do not trigger PlaceOfPartGood
|
||||||
@ -204,7 +215,11 @@ Mat analyseParts::readImages(int count)
|
|||||||
|
|
||||||
Mat src = imread(name, 1);
|
Mat src = imread(name, 1);
|
||||||
if (!src.data)
|
if (!src.data)
|
||||||
|
{
|
||||||
cerr << "Problem loading image!!!" << endl;
|
cerr << "Problem loading image!!!" << endl;
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
|
||||||
if(DISPLAY)imshow("src",src);
|
if(DISPLAY)imshow("src",src);
|
||||||
|
|
||||||
Mat im_gray, im_bw;
|
Mat im_gray, im_bw;
|
||||||
@ -328,7 +343,7 @@ float analyseParts::angle(Point one, Point two, Point three) {
|
|||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void analyseParts::getImages(){
|
bool analyseParts::getImages(){
|
||||||
Details mask;
|
Details mask;
|
||||||
Mat src;
|
Mat src;
|
||||||
vector<vector<Point> > contours;
|
vector<vector<Point> > contours;
|
||||||
@ -342,6 +357,13 @@ void analyseParts::getImages(){
|
|||||||
for (int i = 0; i < nr_parts; i++) {
|
for (int i = 0; i < nr_parts; i++) {
|
||||||
if(DISPLAY) cout << "Bild " << i << endl;
|
if(DISPLAY) cout << "Bild " << i << endl;
|
||||||
Mat im_bw = readImages(i);
|
Mat im_bw = readImages(i);
|
||||||
|
|
||||||
|
if(!im_bw.data)
|
||||||
|
{
|
||||||
|
cerr << "Error: No pic found!!" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Mat dst = morphDilateErode(im_bw);
|
Mat dst = morphDilateErode(im_bw);
|
||||||
contours1 = findingContours(dst);
|
contours1 = findingContours(dst);
|
||||||
mask_gray = polyApprox(contours1);
|
mask_gray = polyApprox(contours1);
|
||||||
@ -356,6 +378,8 @@ void analyseParts::getImages(){
|
|||||||
masks.push_back(mask);
|
masks.push_back(mask);
|
||||||
destroyAllWindows();
|
destroyAllWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point analyseParts::findCenter(Mat img){
|
Point analyseParts::findCenter(Mat img){
|
||||||
|
@ -37,7 +37,7 @@ using namespace cv;
|
|||||||
class AbstractionLayer_1 : public AbstractionLayer_Base<AbstractionLayer_1_Properties>
|
class AbstractionLayer_1 : public AbstractionLayer_Base<AbstractionLayer_1_Properties>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void PreProcessing(coor mySize, const vector<Part*>* partArray) override ;
|
bool PreProcessing(coor mySize, const vector<Part*>* partArray) override ;
|
||||||
bool EvaluateQuality ( coor constraintCoordinate, qualityVector& qVector)override;
|
bool EvaluateQuality ( coor constraintCoordinate, qualityVector& qVector)override;
|
||||||
bool SetConstraintOnPosition( coor constraintCoordinate, AbstractionLayer_1_Properties constraint)override;
|
bool SetConstraintOnPosition( coor constraintCoordinate, AbstractionLayer_1_Properties constraint)override;
|
||||||
bool RemoveConstraintOnPosition( coor constraintCoordinate)override;
|
bool RemoveConstraintOnPosition( coor constraintCoordinate)override;
|
||||||
@ -81,7 +81,7 @@ private:
|
|||||||
|
|
||||||
class analyseParts{
|
class analyseParts{
|
||||||
public:
|
public:
|
||||||
explicit analyseParts(int s = 1008): nr_parts(s){getImages();}
|
explicit analyseParts(int s = 1008): nr_parts(s){}
|
||||||
Mat getImage(int i){if(i>= nr_parts)return masks[nr_parts-1].getImage(); else return masks[i].getImage();}
|
Mat getImage(int i){if(i>= nr_parts)return masks[nr_parts-1].getImage(); else return masks[i].getImage();}
|
||||||
vector<vector<Point>> getContour(int i){if(i>= nr_parts)return masks[nr_parts-1].getContour(); else return masks[i].getContour();}
|
vector<vector<Point>> getContour(int i){if(i>= nr_parts)return masks[nr_parts-1].getContour(); else return masks[i].getContour();}
|
||||||
Point getCenter(int i){if(i>= nr_parts)return masks[nr_parts-1].getCenter(); else return masks[i].getCenter();}
|
Point getCenter(int i){if(i>= nr_parts)return masks[nr_parts-1].getCenter(); else return masks[i].getCenter();}
|
||||||
@ -95,8 +95,8 @@ public:
|
|||||||
Mat morphDilateErode(Mat&);
|
Mat morphDilateErode(Mat&);
|
||||||
vector<vector<Point>> findingContours(Mat&);
|
vector<vector<Point>> findingContours(Mat&);
|
||||||
Mat polyApprox(vector<vector<Point>> &);
|
Mat polyApprox(vector<vector<Point>> &);
|
||||||
|
bool getImages();
|
||||||
private:
|
private:
|
||||||
void getImages();
|
|
||||||
float lengthTwoPoints(Point, Point);
|
float lengthTwoPoints(Point, Point);
|
||||||
float angle(Point, Point, Point);
|
float angle(Point, Point, Point);
|
||||||
vector<Details> masks;
|
vector<Details> masks;
|
||||||
|
@ -40,9 +40,11 @@ class Puzzle
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Puzzle(unsigned int newcols,unsigned int newrows):rows(newrows),cols(newcols)
|
Puzzle(unsigned int newcols,unsigned int newrows):rows(newrows),cols(newcols) {}
|
||||||
|
|
||||||
|
bool PreProcessing()
|
||||||
{
|
{
|
||||||
a1.PreProcessing({rows,cols}, nullptr);
|
return a1.PreProcessing({rows,cols}, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
coor getSizeAsCoor()
|
coor getSizeAsCoor()
|
||||||
|
@ -9,6 +9,12 @@ int main()
|
|||||||
|
|
||||||
vector<LogEntry> log;
|
vector<LogEntry> log;
|
||||||
Puzzle puzzleMat(cols, rows);
|
Puzzle puzzleMat(cols, rows);
|
||||||
|
if(!puzzleMat.PreProcessing())
|
||||||
|
{
|
||||||
|
cerr << "Error occured at PreProcessing!";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
puzzleMat.createRandomBox();
|
puzzleMat.createRandomBox();
|
||||||
cout << "here" << endl;
|
cout << "here" << endl;
|
||||||
puzzleMat.a1.printConstraintMatrix();
|
puzzleMat.a1.printConstraintMatrix();
|
||||||
|
Loading…
Reference in New Issue
Block a user