#ifndef MYCVDIGITPROPROC_H
#define MYCVDIGITPROPROC_H

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/features2d/features2d.hpp"

using namespace std;
using namespace cv;

// mode defines
#define PROC_MODE_GENERAL 0
#define PROC_MODE_NORMALIZE 1

class mycvDigitProproc
{
private:
    /*!
     * \brief mImgActFrame original frame
     */
    Mat mImgActFrame;

    /*!
     * \brief mActDigit actual digit boundaries
     */
    Rect mActDigit;

    /*!
     * \brief mNormSize norm image size
     */
    Size mNormSize;

    /**
     * @brief General digit preprocessing
     * @param aDst output image
     * @return
     */
    int procGeneral(Mat &aDst);

    /**
     * @brief Check rectangle boundaries
     */
    void checkRect();

public:
    mycvDigitProproc();
    ~mycvDigitProproc();

    /**
     * @brief Load BGR image of frame
     * @param aFrame Frame Mat
     */
    void loadFrame(const Mat &aFrame);

    /**
     * @brief Public fce for digit preprocessing
     * @param aDst output image
     * @param aDigit region of image
     * @param aMode mode of preprocessing
     * @return
     */
    int preproc(Mat &aDst, Rect &aDigit, int aMode);

    /**
     * @brief Normalize digit (used by ANN)
     * @param aDst output image
     * @return
     */
    int procNormalize(const Mat &aSrc, Mat &aDst);

};

#endif // MYCVDIGITPROPROC_H
