#ifndef MYCVDIGITPROCANN_H
#define MYCVDIGITPROCANN_H

// Debug
#define DEBUG_DIGIT

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

using namespace std;
using namespace cv;

class mycvDigitProcANN
{
private:
    CvANN_MLP mcANN;
    int mNumOfChars;
    bool mbTrained;

    Mat mDataSet;
    Mat mLabels;
public:
    mycvDigitProcANN();
    ~mycvDigitProcANN();

    /**
     * @brief Load XML structure of trained ANN
     * @param aStr
     */
    void loadXML(string aStr);

    /**
     * @brief saveXML
     * @param aStr
     */
    void saveXML(string aStr);

    /**
     * @brief adds one Mat to data set with proper label
     * @param aDat one train sample Mat
     * @param aLabel proper label of sample
     * @return 1 - success, 0 - error
     */
    int addData(const Mat &aDat, int aLabel);

    /**
     * @brief clears dataset
     */
    void clearData();

    /**
     * @brief Creates and train ANN
     * @param aTrainData Training data Mat, rows - samples, cols - features
     * @param aClasses Vector of samples labels
     * @param aHiddenNeurons Number of neurons in hidden layer
     */
    int train(int aHiddenNeurons);

    /**
     * @brief Tests input data
     * @param aTest Test sample
     * @return Classified number from 0 to 9.5 (0.5 step)
     */
    float test(Mat aTest);

};

#endif // MYCVDIGITPROCANN_H
