From 5848e751683ad1a352e51c27ee97f0ff8ff03bf1 Mon Sep 17 00:00:00 2001 From: Ievgen Khvedchenia Date: Sat, 5 Apr 2014 15:25:59 +0300 Subject: [PATCH] Clean-up from unused utils.h/utils/cpp --- modules/features2d/src/akaze/AKAZE.h | 1 - modules/features2d/src/akaze/utils.cpp | 196 ------------------------- modules/features2d/src/akaze/utils.h | 54 ------- modules/features2d/src/kaze/KAZE.h | 1 - modules/features2d/src/kaze/fed.cpp | 2 +- modules/features2d/src/kaze/utils.cpp | 92 ------------ modules/features2d/src/kaze/utils.h | 41 ------ 7 files changed, 1 insertion(+), 386 deletions(-) delete mode 100644 modules/features2d/src/akaze/utils.cpp delete mode 100644 modules/features2d/src/akaze/utils.h delete mode 100644 modules/features2d/src/kaze/utils.cpp delete mode 100644 modules/features2d/src/kaze/utils.h diff --git a/modules/features2d/src/akaze/AKAZE.h b/modules/features2d/src/akaze/AKAZE.h index 9785b0c42f..ad0364e7a2 100644 --- a/modules/features2d/src/akaze/AKAZE.h +++ b/modules/features2d/src/akaze/AKAZE.h @@ -15,7 +15,6 @@ // Includes #include "config.h" #include "fed.h" -#include "utils.h" #include "nldiffusion_functions.h" //************************************************************************************* diff --git a/modules/features2d/src/akaze/utils.cpp b/modules/features2d/src/akaze/utils.cpp deleted file mode 100644 index eb14abcd51..0000000000 --- a/modules/features2d/src/akaze/utils.cpp +++ /dev/null @@ -1,196 +0,0 @@ -//============================================================================= -// -// utils.cpp -// Authors: Pablo F. Alcantarilla (1), Jesus Nuevo (2) -// Institutions: Georgia Institute of Technology (1) -// TrueVision Solutions (2) -// -// Date: 15/09/2013 -// Email: pablofdezalc@gmail.com -// -// AKAZE Features Copyright 2013, Pablo F. Alcantarilla, Jesus Nuevo -// All Rights Reserved -// See LICENSE for the license information -//============================================================================= - -/** - * @file utils.cpp - * @brief Some utilities functions - * @date Sep 15, 2013 - * @author Pablo F. Alcantarilla, Jesus Nuevo - */ - -#include "precomp.hpp" -#include "utils.h" - -// Namespaces -using namespace std; -using namespace cv; - -//************************************************************************************* -//************************************************************************************* - -/** - * @brief This function computes the minimum value of a float image - * @param src Input image - * @param value Minimum value - */ -void compute_min_32F(const cv::Mat &src, float &value) { - - float aux = 1000.0; - - for (int i = 0; i < src.rows; i++) { - for (int j = 0; j < src.cols; j++) { - if (src.at(i,j) < aux) { - aux = src.at(i,j); - } - } - } - - value = aux; -} - -//************************************************************************************* -//************************************************************************************* - -/** - * @brief This function computes the maximum value of a float image - * @param src Input image - * @param value Maximum value - */ -void compute_max_32F(const cv::Mat &src, float &value) { - - float aux = 0.0; - - for (int i = 0; i < src.rows; i++) { - for (int j = 0; j < src.cols; j++) { - if (src.at(i,j) > aux) { - aux = src.at(i,j); - } - } - } - - value = aux; -} - -//************************************************************************************* -//************************************************************************************* - -/** - * @brief This function converts the scale of the input image prior to visualization - * @param src Input/Output image - * @param value Maximum value - */ -void convert_scale(cv::Mat &src) { - - float min_val = 0, max_val = 0; - - compute_min_32F(src,min_val); - - src = src - min_val; - - compute_max_32F(src,max_val); - src = src / max_val; -} - -//************************************************************************************* -//************************************************************************************* - -/** - * @brief This function copies the input image and converts the scale of the copied - * image prior visualization - * @param src Input image - * @param dst Output image - */ -void copy_and_convert_scale(const cv::Mat &src, cv::Mat dst) { - - float min_val = 0, max_val = 0; - - src.copyTo(dst); - compute_min_32F(dst,min_val); - - dst = dst - min_val; - - compute_max_32F(dst,max_val); - dst = dst / max_val; -} - -//************************************************************************************* -//************************************************************************************* - -const size_t length = string("--descriptor_channels").size() + 2; -static inline std::ostream& cout_help() -{ cout << setw(length); return cout; } - -static inline std::string toUpper(std::string s) -{ - std::transform(s.begin(), s.end(), s.begin(), ::toupper); - return s; -} - -//************************************************************************************* -//************************************************************************************* - -/** - * @brief This function shows the possible command line configuration options - */ -void show_input_options_help(int example) { - - fflush(stdout); - cout << "A-KAZE Features" << endl; - cout << "Usage: "; - if (example == 0) { - cout << "./akaze_features -i img.jpg [options]" << endl; - } - else if (example == 1) { - cout << "./akaze_match img1.jpg img2.pgm homography.txt [options]" << endl; - } - else if (example == 2) { - cout << "./akaze_compare img1.jpg img2.pgm homography.txt [options]" << endl; - } - - cout << endl; - cout_help() << "Options below are not mandatory. Unless specified, default arguments are used." << endl << endl; - // Justify on the left - cout << left; - // Generalities - cout_help() << "--help" << "Show the command line options" << endl; - cout_help() << "--verbose " << "Verbosity is required" << endl; - cout_help() << endl; - // Scale-space parameters - cout_help() << "--soffset" << "Base scale offset (sigma units)" << endl; - cout_help() << "--omax" << "Maximum octave of image evolution" << endl; - cout_help() << "--nsublevels" << "Number of sublevels per octave" << endl; - cout_help() << "--diffusivity" << "Diffusivity function. Possible values:" << endl; - cout_help() << " " << "0 -> Perona-Malik, g1 = exp(-|dL|^2/k^2)" << endl; - cout_help() << " " << "1 -> Perona-Malik, g2 = 1 / (1 + dL^2 / k^2)" << endl; - cout_help() << " " << "2 -> Weickert diffusivity" << endl; - cout_help() << " " << "3 -> Charbonnier diffusivity" << endl; - cout_help() << endl; - // Feature detection parameters. - cout_help() << "--dthreshold" << "Feature detector threshold response for keypoints" << endl; - cout_help() << " " << "(0.001 can be a good value)" << endl; - cout_help() << endl; - // Descriptor parameters. - cout_help() << "--descriptor" << "Descriptor Type. Possible values:" << endl; - cout_help() << " " << "0 -> SURF_UPRIGHT" << endl; - cout_help() << " " << "1 -> SURF" << endl; - cout_help() << " " << "2 -> M-SURF_UPRIGHT," << endl; - cout_help() << " " << "3 -> M-SURF" << endl; - cout_help() << " " << "4 -> M-LDB_UPRIGHT" << endl; - cout_help() << " " << "5 -> M-LDB" << endl; - - cout_help() << "--descriptor_channels " << "Descriptor Channels for M-LDB. Valid values: " << endl; - cout_help() << " " << "1 -> intensity" << endl; - cout_help() << " " << "2 -> intensity + gradient magnitude" << endl; - cout_help() << " " << "3 -> intensity + X and Y gradients" < show detection results." << endl; - cout_help() << " " << "0 -> don't show detection results" << endl; - cout_help() << endl; -} diff --git a/modules/features2d/src/akaze/utils.h b/modules/features2d/src/akaze/utils.h deleted file mode 100644 index 894c836ed0..0000000000 --- a/modules/features2d/src/akaze/utils.h +++ /dev/null @@ -1,54 +0,0 @@ - -#ifndef _UTILS_H_ -#define _UTILS_H_ - -//****************************************************************************** -//****************************************************************************** - -// OpenCV Includes -#include "precomp.hpp" - -// System Includes -#include -#include -#include -#include -#include -#include -#include - -//****************************************************************************** -//****************************************************************************** - -// Stringify common types such as int, double and others. -template -inline std::string to_string(const T& x) { - std::stringstream oss; - oss << x; - return oss.str(); -} - -//****************************************************************************** -//****************************************************************************** - -// Stringify and format integral types as follows: -// to_formatted_string( 1, 2) produces string: '01' -// to_formatted_string( 5, 2) produces string: '05' -// to_formatted_string( 19, 2) produces string: '19' -// to_formatted_string( 19, 3) produces string: '019' -template -inline std::string to_formatted_string(Integer x, int num_digits) { - std::stringstream oss; - oss << std::setfill('0') << std::setw(num_digits) << x; - return oss.str(); -} - -//****************************************************************************** -//****************************************************************************** - -void compute_min_32F(const cv::Mat& src, float& value); -void compute_max_32F(const cv::Mat& src, float& value); -void convert_scale(cv::Mat& src); -void copy_and_convert_scale(const cv::Mat& src, cv::Mat& dst); - -#endif diff --git a/modules/features2d/src/kaze/KAZE.h b/modules/features2d/src/kaze/KAZE.h index 1d7fb0beb1..3e86ab2d86 100644 --- a/modules/features2d/src/kaze/KAZE.h +++ b/modules/features2d/src/kaze/KAZE.h @@ -17,7 +17,6 @@ #include "config.h" #include "nldiffusion_functions.h" #include "fed.h" -#include "utils.h" //************************************************************************************* //************************************************************************************* diff --git a/modules/features2d/src/kaze/fed.cpp b/modules/features2d/src/kaze/fed.cpp index 0bd228673a..f07d072d61 100644 --- a/modules/features2d/src/kaze/fed.cpp +++ b/modules/features2d/src/kaze/fed.cpp @@ -28,7 +28,7 @@ * DAGM, 2010 * */ - +#include "precomp.hpp" #include "fed.h" using namespace std; diff --git a/modules/features2d/src/kaze/utils.cpp b/modules/features2d/src/kaze/utils.cpp deleted file mode 100644 index 7b55ac45f7..0000000000 --- a/modules/features2d/src/kaze/utils.cpp +++ /dev/null @@ -1,92 +0,0 @@ - -//============================================================================= -// -// utils.cpp -// Author: Pablo F. Alcantarilla -// Institution: University d'Auvergne -// Address: Clermont Ferrand, France -// Date: 29/12/2011 -// Email: pablofdezalc@gmail.com -// -// KAZE Features Copyright 2012, Pablo F. Alcantarilla -// All Rights Reserved -// See LICENSE for the license information -//============================================================================= - -/** - * @file utils.cpp - * @brief Some useful functions - * @date Dec 29, 2011 - * @author Pablo F. Alcantarilla - */ - -#include "utils.h" - -using namespace std; -using namespace cv; - -//************************************************************************************* -//************************************************************************************* - -/** - * @brief This function copies the input image and converts the scale of the copied - * image prior visualization - * @param src Input image - * @param dst Output image - */ -void copy_and_convert_scale(const cv::Mat& src, cv::Mat& dst) { - - float min_val = 0, max_val = 0; - - src.copyTo(dst); - compute_min_32F(dst,min_val); - - dst = dst - min_val; - - compute_max_32F(dst,max_val); - dst = dst / max_val; -} - -//************************************************************************************* -//************************************************************************************* - -/* -void show_input_options_help(int example) { - - fflush(stdout); - - cout << endl; - cout << endl; - cout << "KAZE Features" << endl; - cout << "***********************************************************" << endl; - cout << "For running the program you need to type in the command line the following arguments: " << endl; - - if (example == 0) { - cout << "./kaze_features img.jpg [options]" << endl; - } - else if (example == 1) { - cout << "./kaze_match img1.jpg img2.pgm homography.txt [options]" << endl; - } - else if (example == 2) { - cout << "./kaze_compare img1.jpg img2.pgm homography.txt [options]" << endl; - } - - cout << endl; - cout << "The options are not mandatory. In case you do not specify additional options, default arguments will be used" << endl << endl; - cout << "Here is a description of the additional options: " << endl; - cout << "--verbose " << "\t\t if verbosity is required" << endl; - cout << "--help" << "\t\t for showing the command line options" << endl; - cout << "--soffset" << "\t\t the base scale offset (sigma units)" << endl; - cout << "--omax" << "\t\t maximum octave evolution of the image 2^sigma (coarsest scale)" << endl; - cout << "--nsublevels" << "\t\t number of sublevels per octave" << endl; - cout << "--dthreshold" << "\t\t Feature detector threshold response for accepting points (0.001 can be a good value)" << endl; - cout << "--descriptor" << "\t\t Descriptor Type 0 -> SURF, 1 -> M-SURF, 2 -> G-SURF" << endl; - cout << "--use_fed" "\t\t 1 -> Use FED, 0 -> Use AOS for the nonlinear diffusion filtering" << endl; - cout << "--upright" << "\t\t 0 -> Rotation Invariant, 1 -> No Rotation Invariant" << endl; - cout << "--extended" << "\t\t 0 -> Normal Descriptor (64), 1 -> Extended Descriptor (128)" << endl; - cout << "--output keypoints.txt" << "\t\t For saving the detected keypoints into a .txt file" << endl; - cout << "--save_scale_space" << "\t\t 1 in case we want to save the nonlinear scale space images. 0 otherwise" << endl; - cout << "--show_results" << "\t\t 1 in case we want to show detection results. 0 otherwise" << endl; - cout << endl; -} -*/ \ No newline at end of file diff --git a/modules/features2d/src/kaze/utils.h b/modules/features2d/src/kaze/utils.h deleted file mode 100644 index 848bfe3f53..0000000000 --- a/modules/features2d/src/kaze/utils.h +++ /dev/null @@ -1,41 +0,0 @@ - -/** - * @file utils.h - * @brief Some useful functions - * @date Dec 29, 2011 - * @author Pablo F. Alcantarilla - */ - -#ifndef UTILS_H_ -#define UTILS_H_ - -//****************************************************************************** -//****************************************************************************** - -// OPENCV Includes -#include "precomp.hpp" - -// System Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//************************************************************************************* -//************************************************************************************* - -// Declaration of Functions -void compute_min_32F(const cv::Mat& src, float& value); -void compute_max_32F(const cv::Mat& src, float& value); -void convert_scale(cv::Mat& src); -void copy_and_convert_scale(const cv::Mat &src, cv::Mat& dst); - -//************************************************************************************* -//************************************************************************************* - -#endif // UTILS_H_