Skip to content

File processer.h

File List > processer.h

Go to the documentation of this file

#pragma once
#ifdef DLL_EXPORT
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif

#include "type.h"

#include <Windows.h>
#include <opencv2/opencv.hpp>

using namespace cv;

namespace inspection
{
    class Preprocesser
    {
    private:
        TaskType _task;
        int _imageWidth;
        int _imageHeight;
        string _crop;

        void CropCenter(Mat& image);
        void ConvertGrayscale(Mat& image);
        void Normalize(Mat& image);
        void AddPadding(Mat& image, int imageWidth, int imageHeight);

    public:
        Preprocesser(TaskType task, int imageWidth, int imageHeight, string crop);
        Mat ProcessImage(Mat& image);
    };

    class Postprocesser
    {
    private:
        TaskType _task;
        int _imageWidth;
        int _imageHeight;
        int _numOfClass;
        string _crop;

        void Argmax(Mat& images);
        Mat ConvertMat(float* tensor, int classNum, int width, int height);
        Mat Crop(Mat images, int x, int y, int w, int h);
        void AddPadding(Mat& image, int imageWidth, int imageHeight);

    public:
        Postprocesser(TaskType task, int imageWidth, int imageHeight, int numOfClass, string crop);
        Mat ProcessImage(float* results, int originWidth, int originHeight);
    };


}