#ifndef MYCVDIGITSEGM_H
#define MYCVDIGITSEGM_H

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

#include "mycv.h"
#include "mycvdigitpreproc.h"
#include "mycvdigitprocann.h"
#include "mycvdigitprocfeatures.h"
#include "mycvdigitprocgeometric.h"

// Modes of detection
#define MODE_DETECT_VERT_PROJ   0
#define MODE_DETECT_CONTOURS    1

using namespace std;
using namespace cv;

class mycvDigitsSegm
{
private:
    /// Digit preprocession class
    mycvDigitProproc mcDigitPreproc;

    /// Matching by shape
    vector<vector<Point>> mPatternsContours;  // contours of ideal numbers 0-9
    mycvDigitProcGeometric mcDigitGeometric;
    mycvDigitProcFeatures mcDigitFeatures;

    /// ANN
    mycvDigitProcANN mcANN;

    void segmentNumVerticalProj(const Mat &aFrame, Mat &aDst, vector<Mat> &aDigits);
    void segmentNumContours(const Mat &aFrame, Mat &aDst, vector<Mat> &aDigits);
    void mycvPreprocCount(const Mat &aSrc, Mat &aDst);
public:
    mycvDigitsSegm();
    mycvDigitsSegm(mycvDigitProcFeatures &aCFeatures);
    mycvDigitsSegm(mycvDigitProcANN &aCANN);
    ~mycvDigitsSegm();

    void segmentNum(const Mat &aFrame, Mat &aDst, vector<Mat> &aDigits, int aMode);
};

#endif // MYCVDIGITSEGM_H
