#include <vector>
#include <cmath>
#include "opencv2/core.hpp"
#include <iterator>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstdlib>
#include "csv_reader.h"
#include "H5Cpp.h"
Go to the source code of this file.
Macros | |
#define | _USE_MATH_DEFINES |
Functions | |
void | vectorToFile (std::vector< double > const &vec, std::string const &filename) |
void | MatToFile (cv::Mat &image, std::string const &filename) |
std::vector< double > | decompose_matrix (cv::Mat mat) |
cv::Mat | compose_matrix (std::vector< double > parameters) |
std::vector< std::size_t > | compute_sort_order (const std::vector< double > &v) |
void | show_cv_matrix (cv::Mat img, std::string windowname) |
void | print_cv_matrix_info (cv::Mat img, std::string imagename) |
double | interpolate (const std::map< double, double > &data, double x) |
herr_t | file_info (hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata) |
Macro Definition Documentation
#define _USE_MATH_DEFINES |
Function Documentation
cv::Mat compose_matrix | ( | std::vector< double > | parameters | ) |
Composes 2x3 transformation matrix from shear, scale, rotation and translation parameters.
- Parameters
-
parameters [sx, sy, shear, , tx, ty]
- Returns
- 2x3 transformation matrix
std::vector<std::size_t> compute_sort_order | ( | const std::vector< double > & | v | ) |
Calculates sorted index array of a given vector.
Equivalent to numpy.argsort
- Parameters
-
v vector to be sorted
- Returns
- array of indices that would sort the vector v
std::vector<double> decompose_matrix | ( | cv::Mat | mat | ) |
Decomposes a 2x3 affine transformation matrix into its underlying geometric components.
A transformation matrix can be decomposed in rotation
, scale in X- and Y direction
, shearing
and translation in X- and Y
.
The decomposition is not unique, there exist other decompositions. However, it seems that this particular decomposition is rather stable and for each component one gets a rather smooth function across an order.
- Warning
- When rotation
is close to 0, it sometimes alters between
. This is a problem when trying to make a smooth spline across an order. Temporary fix is to add
when values are near
.
- Parameters
-
mat 2x3 transformation matrix
- Returns
- [sx, sy, shear,
, tx, ty]
herr_t file_info | ( | hid_t | loc_id, |
const char * | name, | ||
const H5L_info_t * | linfo, | ||
void * | opdata | ||
) |
double interpolate | ( | const std::map< double, double > & | data, |
double | x | ||
) |
void MatToFile | ( | cv::Mat & | image, |
std::string const & | filename | ||
) |
Saves an OpenCV matrix to a text file
This function saves a cv::Mat matrix to a text file. The file is essentially a CSV file, but the matrix is 'numpy' style, which means that is begins with [ and ends with ] characters.
- Parameters
-
image matrix to be saved filename path to output file
void print_cv_matrix_info | ( | cv::Mat | img, |
std::string | imagename | ||
) |
Prints out basic information about a Matrix/Image.
Prints type, dimensions, min- and max value.
- Parameters
-
img Matrix/Image to be evaluated. imagename Name of the matrix
void show_cv_matrix | ( | cv::Mat | img, |
std::string | windowname | ||
) |
Plots an OpenCV matrix of type CV_32.
For plotting a double/float matrix, the matrix needs to be rescaled before plotted on screen.
- Parameters
-
img Matrix/Image to be plotted windowname name of the window containing the plot
void vectorToFile | ( | std::vector< double > const & | vec, |
std::string const & | filename | ||
) |
Saves vector to CSV File
This function saves a std double vector to a CSV file e.g. for easy plotting with python
- Parameters
-
vec vector to be saved filename path to output file