twain2/ImageOutHole.h

23 lines
1.2 KiB
C++

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