lundi 1 juillet 2019

C++ Good-Practice of Classes Designs

I made a small software, for image processing, that does some small and basics edits. I wrote this code in C++, by not checking any good practice of C++ Designs. At the beginning, my point was just made some code work. Those are the classes with methods and attributes:

MasterPH.h

class MasterPH
{
public:
    cv::Mat img;
    cv::Mat tmp;
    cv::Mat original;

    cv::Mat hist_Mat_r;
    cv::Mat hist_Mat_g;
    cv::Mat hist_Mat_b;

    int exposure_val = 0;
    int red_val = 0;
    int green_val = 0;
    int blue_val = 0;
    double contrast_val = 0;

    int hue = 0;
    int luminance = 0;
    int saturation = 0;
};

imgprocessing.h

class ImgProcessing
{
public:
    ImgProcessing();

    void processMaster(cv::Mat& img, cv::Mat& tmp, int brightness, int red, int green, int blue, double contrast);
    void processHLS(cv::Mat& img, cv::Mat& tmp, int hue, int luminance, int saturation);
    void black_n_white(cv::Mat& img, cv::Mat& tmp);
    void sepia(cv::Mat& img, cv::Mat& tmp);
};

ImgHandling.h

class ImgHandling
{
public:
    ImgHandling();

    void imgLoad(cv::Mat& img, cv::Mat& tmp, cv::Mat& original, QString& path);
    void imgSave(QString& path, cv::Mat& img);

    void calculateHist(cv::Mat& img, cv::Mat& hist_Mat, int color);
};

imgdistortions.h

class ImgDistortions
{
public:
    ImgDistortions();


    void rotate(cv::Mat& img, cv::Mat& tmp, int angle);
    void flipH(cv::Mat& img, cv::Mat& tmp);
    void flipV(cv::Mat& img, cv::Mat& tmp);
};

imgconvolution.h

class ImgConvolution
{
public:
    ImgConvolution();

    void applyKernel(); // To implement still
};

Plus a class containing all the buttons & sliders, that just call these functions.

So now I need some advice on how I can step from this kind of Procedural-Code, to a more Object Oriented one, via using all the possible Good Practice design of C ++.

I'm new to C++, so I'm still learning on how I can apply polymorphism etc...

Aucun commentaire:

Enregistrer un commentaire