From be49687f313b8c76844b8800be04f3d8a9588f21 Mon Sep 17 00:00:00 2001 From: JRauer Date: Sat, 27 Jan 2018 12:35:14 +0100 Subject: [PATCH] Debug-Stuff, Part turned 4x for partArray, Unbelieveable slow when layer is on... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unbelieveable slow when layer is on... -> may be a solver problem? Solution found (see slack). Pömpel ignored. No Seg-Faults anymore --- .../DestructionPower/DestructionPower.h | 2 +- .../AbstractionLayer_SURFFeatures.cpp | 38 +++++++++++-------- .../AbstractionLayer_SURFFeatures.h | 2 +- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h index 8d8eb9f..f51fc35 100644 --- a/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h +++ b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h @@ -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" diff --git a/Source/functions/AbstractionLayers/Layer_SURFFeatures/AbstractionLayer_SURFFeatures.cpp b/Source/functions/AbstractionLayers/Layer_SURFFeatures/AbstractionLayer_SURFFeatures.cpp index 977f2f3..5656cbe 100644 --- a/Source/functions/AbstractionLayers/Layer_SURFFeatures/AbstractionLayer_SURFFeatures.cpp +++ b/Source/functions/AbstractionLayers/Layer_SURFFeatures/AbstractionLayer_SURFFeatures.cpp @@ -23,6 +23,7 @@ bool AbstractionLayer_SURFFeatures::PreProcessing(coor mySize, const vectorm_a4.m_numberOfFeaturesDetected); qVector[i].first = 1 - diff; - //cout << fixed << qVector[i].first << endl; + // cout << i << " " << fixed << qVector[i].first << endl; } + // cout << " Matrix: " << m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row].m_numberOfFeaturesDetected << endl; return true; } @@ -69,7 +71,7 @@ bool AbstractionLayer_SURFFeatures::PreProcessingFullImg(coor mySize) //cout << "POST: " << image.cols << " x " << image.rows << endl; // PARAMETERS (for description see top of file) - int maxCorners = 10000; + int maxCorners = 12000; double qualityLevel = 0.01; double minDistance = .5; Mat mask; @@ -81,11 +83,13 @@ bool AbstractionLayer_SURFFeatures::PreProcessingFullImg(coor mySize) goodFeaturesToTrack( image, corners, maxCorners, qualityLevel, minDistance, mask, blockSize, useHarrisDetector, k ); // Empty the matrix - for( int j = 0; j < mySize.col ; j++ ) - { for( int i = 0; i < mySize.row; i++ ) + for( int j = 0; j < mySize.row ; j++ ) + { for( int i = 0; i < mySize.col; i++ ) { - m_constraintMatrix[j][i].m_numberOfFeaturesDetected = 0; + m_constraintMatrix[i][j].m_numberOfFeaturesDetected = 0; + //cout << m_constraintMatrix[i][j].m_numberOfFeaturesDetected << " "; } + //cout << endl; } int pieceColSize = image.cols/mySize.col; @@ -100,21 +104,23 @@ bool AbstractionLayer_SURFFeatures::PreProcessingFullImg(coor mySize) // 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 maxFeatures = int(m_constraintMatrix[0][0].m_numberOfFeaturesDetected); - for( int j = 0; j < mySize.col ; j++ ) + for( int j = 0; j < mySize.row ; j++ ) { - for( int i = 0; i < mySize.row; i++ ) + for( int i = 0; i < mySize.col; i++ ) { - 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[i][j].m_numberOfFeaturesDetected < minFeatures) minFeatures = int(m_constraintMatrix[i][j].m_numberOfFeaturesDetected); + if(m_constraintMatrix[i][j].m_numberOfFeaturesDetected > maxFeatures) maxFeatures = int(m_constraintMatrix[i][j].m_numberOfFeaturesDetected); + //cout << fixed << m_constraintMatrix[i][j].m_numberOfFeaturesDetected << " "; } + //cout << endl; } // Calculate percentage from 0 to 100% (normalized 0-1) with numberOfFeatures and safe it - for( int j = 0; j < mySize.col ; j++ ) + for( int j = 0; j < mySize.row ; j++ ) { - for( int i = 0; i < mySize.row; i++ ) + for( int i = 0; i < mySize.col; i++ ) { - m_constraintMatrix[j][i].m_numberOfFeaturesDetected = (m_constraintMatrix[j][i].m_numberOfFeaturesDetected - minFeatures) / (maxFeatures - minFeatures); + m_constraintMatrix[i][j].m_numberOfFeaturesDetected = (m_constraintMatrix[i][j].m_numberOfFeaturesDetected - minFeatures) / (maxFeatures - minFeatures); //cout << fixed << m_constraintMatrix[i][j].m_numberOfFeaturesDetected << " "; } //cout << endl; @@ -161,19 +167,21 @@ bool AbstractionLayer_SURFFeatures::PreProcessingPieces(coor mySize, const vecto useHarrisDetector, k); if (corners.size() < minFeatures) minFeatures = corners.size(); if (corners.size() > maxFeatures) maxFeatures = corners.size(); - partArray->at(imgID)->m_a4.m_numberOfFeaturesDetected = corners.size(); + for(int rotate = 0; rotate < 4; rotate++) + partArray->at(imgID*4 + rotate)->m_a4.m_numberOfFeaturesDetected = corners.size(); + //cout << imgID << ":" << partArray->at(imgID*4)->m_a4.m_numberOfFeaturesDetected << endl; + //cout << imgID << " " << corners.size() << endl; /*for( size_t i = 0; i < corners.size(); i++ ) { cv::circle( src, corners[i], 2, cv::Scalar( 255. ), -1 ); } cv::namedWindow( "Output", CV_WINDOW_AUTOSIZE ); cv::imshow( "Output", src ); - cout << count << " " << corners.size() << endl; cv::waitKey(0);*/ } } // Calculate percentage from 0 to 100% (normalized 0-1) with numberOfFeatures and safe it - for( unsigned i = 0; i < mySize.col*mySize.row; i++ ) + for( unsigned i = 0; i < partArray->size(); i++ ) { partArray->at(i)->m_a4.m_numberOfFeaturesDetected = (partArray->at(i)->m_a4.m_numberOfFeaturesDetected - minFeatures) / (maxFeatures - minFeatures); //cout << fixed << partArray->at(i)->m_a4.m_numberOfFeaturesDetected << endl; diff --git a/Source/functions/AbstractionLayers/Layer_SURFFeatures/AbstractionLayer_SURFFeatures.h b/Source/functions/AbstractionLayers/Layer_SURFFeatures/AbstractionLayer_SURFFeatures.h index bacda38..5dd0070 100644 --- a/Source/functions/AbstractionLayers/Layer_SURFFeatures/AbstractionLayer_SURFFeatures.h +++ b/Source/functions/AbstractionLayers/Layer_SURFFeatures/AbstractionLayer_SURFFeatures.h @@ -6,7 +6,7 @@ #include "opencv2/imgproc/imgproc.hpp" #ifdef _WIN32 -#define PATH_FULL_PUZZLE "..\\..\\..\\puzzle_img\\puzzle1.jpg" +#define PATH_FULL_PUZZLE "..\\..\\..\\puzzle_img\\puzzle2.jpg" #elif defined __unix__ #define PATH_FULL_PUZZLE "..//..//..//puzzle_img//puzzle1.jpg" #elif defined __APPLE__