/* #########################################
 * Traffic monitoring using Raspberry PI
 * Author: Michal Zacpal
 * Library: Image processing tools
 * 2015
 * ######################################### */
#ifndef IMAGEPROCESSING_H
#define IMAGEPROCESSING_H

#include <QImage>
#include "opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <math.h>
#include "roadlane.h"

#define CONST_THRESH 100

using namespace cv;
// Structure for TVTM
typedef struct{
    Mat TvtmImg;
    int a;
    int b;
    int c;
    Point *lut;
}TVTM ;
TVTM computeTVTM(Mat TVTMImg, double H, double f, double theta);
TVTM OptimizeTVTM(Mat TVTMImg, double H, double f, double theta);
Mat RetTVImg(Mat inputImh, TVTM TVTModel, bool bCrop);
Mat InterpolTVTM(Mat InputImg);
QImage Mat2QImage(Mat img, int iWidth, int iHeight);
Mat ImEdge(Mat InImg);
vector<int> HorizHist(Mat InImg);
Mat ImageThresholdIter(Mat inputImg, int iMaxIter);
vector<int> HorizHistU(Mat InImg);
Mat CropLane(Mat InImg, int iPosition, int iLaneOffset);
RoadLane ProcessLane(Mat InImg,int iMinWidth, int iMaxWidth);
LaneCoordinates LaneBorder(Mat InImg, int iMinLaneWidth, int iMaxLaneWidth, int iPosition, int iLaneOffset);

#endif // IMAGEPROCESSING_H
