You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.5 KiB
C

2 months ago
#ifndef REMOVE_BORDER_H
#define REMOVE_BORDER_H
#include <opencv2/opencv.hpp>
#include <string>
#include <vector>
#include "../common.h"
#include "../image_utilities.h"
using namespace std;
/**
*
* Pythonoffset(tx, ty, ws, hs, ta)
*/
struct Offset {
float tx; // x方向平移
float ty; // y方向平移
float ws; // 宽度缩放
float hs; // 高度缩放
float ta; // 角度调整
Offset(float tx = 0.0f, float ty = 0.0f, float ws = 0.0f, float hs = 0.0f, float ta = 0.0f)
: tx(tx), ty(ty), ws(ws), hs(hs), ta(ta) {}
};
/**
*
*
* args:
* imgshape:
* shapeType:
* filter_border:
* returns:
* filterMask:
*/
cv::Mat get_filterBorderMask(const cv::Size& imgshape, const string& shapeType, const cv::RotatedRect& filter_border);
/**
* offsets
*
* args:
* img:
* shapeType:
* mrect:
* offsets:
* inverse: TrueFalse
* bg_val:
* returns:
* best_mrect:
*/
cv::RotatedRect _find_bestfit(const cv::Mat& img, const string& shapeType, const cv::RotatedRect& mrect,
const vector<Offset>& offsets, bool inverse = false, int bg_val = 255);
/**
*
*
* args:
* img:
* shapeinfo:
* bg_val:
* returns:
* filterMask: mask
* new_shapeinfo:
* inner_border:
*/
cv::Mat _getFilterMask(const cv::Mat& img, const ShapeInfo& shapeinfo, cv::RotatedRect& inner_border, int bg_val = 255);
/**
*
*
* args:
* img:
* shapeinfo:
* bg_val: , bg_val0
* returns:
* img1:
* mask:
* new_shapeinfo:
* inner_border:
*/
cv::Mat remove_border(const cv::Mat& img, const ShapeInfo& shapeinfo, cv::Mat& mask, ShapeInfo& new_shapeinfo, cv::RotatedRect& inner_border, int bg_val = 255);
#endif // REMOVE_BORDER_H