changed col rows

This commit is contained in:
Raphael Maenle 2018-01-26 23:01:21 +01:00
parent 9a3661647a
commit b0cb1aa417
2 changed files with 9 additions and 8 deletions

View File

@ -31,7 +31,7 @@ bool AbstractionLayer_SURFFeatures::EvaluateQuality (coor constraintCoordinate,
// Calculate absolute difference between constraints and each piece and safe it // Calculate absolute difference between constraints and each piece and safe it
for( int i = 0; i < qVector.size(); i++ ) for( int i = 0; i < qVector.size(); i++ )
{ {
float diff = abs(m_constraintMatrix[constraintCoordinate.row][constraintCoordinate.col].m_numberOfFeaturesDetected - qVector[i].second->m_a4.m_numberOfFeaturesDetected); float diff = abs(m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].m_numberOfFeaturesDetected - qVector[i].second->m_a4.m_numberOfFeaturesDetected);
qVector[i].first = 1 - diff; qVector[i].first = 1 - diff;
//cout << fixed << qVector[i].first << endl; //cout << fixed << qVector[i].first << endl;
} }
@ -81,8 +81,8 @@ bool AbstractionLayer_SURFFeatures::PreProcessingFullImg(coor mySize)
goodFeaturesToTrack( image, corners, maxCorners, qualityLevel, minDistance, mask, blockSize, useHarrisDetector, k ); goodFeaturesToTrack( image, corners, maxCorners, qualityLevel, minDistance, mask, blockSize, useHarrisDetector, k );
// Empty the matrix // Empty the matrix
for( int j = 0; j < mySize.row ; j++ ) for( int j = 0; j < mySize.col ; j++ )
{ for( int i = 0; i < mySize.col; i++ ) { for( int i = 0; i < mySize.row; i++ )
{ {
m_constraintMatrix[j][i].m_numberOfFeaturesDetected = 0; m_constraintMatrix[j][i].m_numberOfFeaturesDetected = 0;
} }
@ -94,15 +94,15 @@ bool AbstractionLayer_SURFFeatures::PreProcessingFullImg(coor mySize)
for( int i = 0; i < corners.size(); i++ ) // For all found features for( int i = 0; i < corners.size(); i++ ) // For all found features
{ {
// Increment number of found pieces // Increment number of found pieces
m_constraintMatrix[int(corners[i].y/pieceRowSize)][int(corners[i].x/pieceColSize)].m_numberOfFeaturesDetected++; m_constraintMatrix[int(corners[i].x/pieceColSize)][int(corners[i].y/pieceRowSize)].m_numberOfFeaturesDetected++;
} }
// Get minimal and maximal number of features -> TODO: Do in first loop to safe time? // Get minimal and maximal number of features -> TODO: Do in first loop to safe time?
int minFeatures = int(m_constraintMatrix[0][0].m_numberOfFeaturesDetected); int minFeatures = int(m_constraintMatrix[0][0].m_numberOfFeaturesDetected);
int maxFeatures = int(m_constraintMatrix[0][0].m_numberOfFeaturesDetected); int maxFeatures = int(m_constraintMatrix[0][0].m_numberOfFeaturesDetected);
for( int j = 0; j < mySize.row ; j++ ) for( int j = 0; j < mySize.col ; j++ )
{ {
for( int i = 0; i < mySize.col; i++ ) for( int i = 0; i < mySize.row; i++ )
{ {
if(m_constraintMatrix[j][i].m_numberOfFeaturesDetected < minFeatures) minFeatures = int(m_constraintMatrix[j][i].m_numberOfFeaturesDetected); if(m_constraintMatrix[j][i].m_numberOfFeaturesDetected < minFeatures) minFeatures = int(m_constraintMatrix[j][i].m_numberOfFeaturesDetected);
if(m_constraintMatrix[j][i].m_numberOfFeaturesDetected > maxFeatures) maxFeatures = int(m_constraintMatrix[j][i].m_numberOfFeaturesDetected); if(m_constraintMatrix[j][i].m_numberOfFeaturesDetected > maxFeatures) maxFeatures = int(m_constraintMatrix[j][i].m_numberOfFeaturesDetected);
@ -110,9 +110,9 @@ bool AbstractionLayer_SURFFeatures::PreProcessingFullImg(coor mySize)
} }
// Calculate percentage from 0 to 100% (normalized 0-1) with numberOfFeatures and safe it // Calculate percentage from 0 to 100% (normalized 0-1) with numberOfFeatures and safe it
for( int j = 0; j < mySize.row ; j++ ) for( int j = 0; j < mySize.col ; j++ )
{ {
for( int i = 0; i < mySize.col; i++ ) for( int i = 0; i < mySize.row; i++ )
{ {
m_constraintMatrix[j][i].m_numberOfFeaturesDetected = (m_constraintMatrix[j][i].m_numberOfFeaturesDetected - minFeatures) / (maxFeatures - minFeatures); m_constraintMatrix[j][i].m_numberOfFeaturesDetected = (m_constraintMatrix[j][i].m_numberOfFeaturesDetected - minFeatures) / (maxFeatures - minFeatures);
//cout << fixed << m_constraintMatrix[i][j].m_numberOfFeaturesDetected << " "; //cout << fixed << m_constraintMatrix[i][j].m_numberOfFeaturesDetected << " ";

View File

@ -187,6 +187,7 @@ Mat Puzzle::resultImage( vector<LogEntry>& log){
sprintf(name, PATH, imageNumber); sprintf(name, PATH, imageNumber);
Mat img = imread(name, 1); Mat img = imread(name, 1);
cout << name << endl;
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 );