twain2/hugaotwainds/ImageOutHole.h

27 lines
1.1 KiB
C++

#pragma once
#include "ImageApply.h"
#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
class ImageOutHole
{
public:
ImageOutHole(void);
~ImageOutHole(void);
public:
void puncture(Mat& front, Mat& back, double threshold, float edgeScale, double areaThreshold);
private:
cv::Mat threshold_mat(const Mat& src, double threshold);
void findContours22(const Mat& src, vector<vector<Point>>& contours, vector<Vec4i>& hierarchy, int retr = RETR_CCOMP, int method = CHAIN_APPROX_SIMPLE, Point offset = Point(0, 0));
vector<Point> getMaxContour(const vector<vector<Point>>& contours, const vector<Vec4i>& hierarchy, int areaThreshold = 20000);
void getRoi(RotatedRect rrect_front, RotatedRect rrect_back, Size srcSize, Rect& roi_front, Rect& roi_back, RotatedRect& mask_rotatedRect);
Point rotatedPoint(Point p, Point center, double angle);
vector<Point> getVertices(RotatedRect rect);
void filterPoly(const Mat& mask, vector<vector<Point>>& contours, RotatedRect roi, float edgeScale, double areaThreshold);
void fillPuncture(Mat& src, const Mat& mask, Rect roi);
};