parent
17f305140b
commit
5848e75168
7 changed files with 1 additions and 386 deletions
@ -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<float>(i,j) < aux) { |
||||
aux = src.at<float>(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<float>(i,j) > aux) { |
||||
aux = src.at<float>(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" <<endl; |
||||
|
||||
cout_help() << "--descriptor_size" << "Descriptor size for M-LDB in bits." << endl; |
||||
cout_help() << " " << "0: means the full length descriptor (486)!!" << endl; |
||||
cout_help() << endl; |
||||
// Save results?
|
||||
cout_help() << "--show_results" << "Possible values below:" << endl; |
||||
cout_help() << " " << "1 -> show detection results." << endl; |
||||
cout_help() << " " << "0 -> don't show detection results" << endl; |
||||
cout_help() << endl; |
||||
} |
@ -1,54 +0,0 @@ |
||||
|
||||
#ifndef _UTILS_H_ |
||||
#define _UTILS_H_ |
||||
|
||||
//******************************************************************************
|
||||
//******************************************************************************
|
||||
|
||||
// OpenCV Includes
|
||||
#include "precomp.hpp" |
||||
|
||||
// System Includes
|
||||
#include <stdlib.h> |
||||
#include <stdio.h> |
||||
#include <cstdlib> |
||||
#include <vector> |
||||
#include <fstream> |
||||
#include <iostream> |
||||
#include <iomanip> |
||||
|
||||
//******************************************************************************
|
||||
//******************************************************************************
|
||||
|
||||
// Stringify common types such as int, double and others.
|
||||
template <typename T> |
||||
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 <typename Integer> |
||||
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 |
@ -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; |
||||
} |
||||
*/ |
@ -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 <stdlib.h> |
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
#include <cstdlib> |
||||
#include <string> |
||||
#include <vector> |
||||
#include <fstream> |
||||
#include <assert.h> |
||||
#include <math.h> |
||||
|
||||
//*************************************************************************************
|
||||
//*************************************************************************************
|
||||
|
||||
// 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_
|
Loading…
Reference in new issue