//
//  mat_utils.h
//  TestApp
//
//  Created by Jakub Tomczyński on 01.09.2017.
//
//

#ifndef mat_utils_h
#define mat_utils_h

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include <QVector>
#include <QImage>
#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif
#ifndef M_PI_2
    #define M_PI_2 3.14159265358979323846/2
#endif
//#define _USE_MATH_DEFINES
//QTextStream& operator<<( QTextStream& str, const cv::Mat &data);
//QTextStream& operator>>( QTextStream& str, cv::Mat &data);

/**
 @brief Converts cv::Mat to row major QVector<QVector<double> >

 @param input input matrix
 */
QVector<QVector<double> > Mat_to_QVector2D(const cv::Mat &input);
/**
 @brief Converts row major QVector<QVector<double> > to cv::Mat
 
 @param input input matrix
 */
cv::Mat QVector2D_to_Mat(const QVector<QVector<double> > &input, int type=CV_64F);
/**
 @brief Converts cv::Mat to QImage

 @param input input image
 */
QImage Mat_to_QImage(const cv::Mat &input);

/**
 @brief Checks if point is inside a RotatedRect
 
 @param rectangle boundary rectangle
 @param point point to check
 */
bool is_inside_rectangle(cv::RotatedRect rectangle, cv::Point2d point);

/**
 @brief Checks if point is inside a RotatedRect
 
 @param rectangle boundary rectangle
 @param point point to check
 */
QStringList split_with_escape(QString input, char separator=',', char escape_char='\\');

#endif /* mat_utils_h */
