twain3/ImageProcess/ImageApplyCustomCrop.cpp

33 lines
600 B
C++

#include "ImageApplyCustomCrop.h"
CImageApplyCustomCrop::CImageApplyCustomCrop(const cv::Rect &rect)
: m_rect(rect)
{
}
CImageApplyCustomCrop::~CImageApplyCustomCrop()
{
}
void CImageApplyCustomCrop::apply(cv::Mat &pDib, int side)
{
(void)side;
if(pDib.empty()) return;
pDib = pDib(cv::Rect(0, 0, pDib.cols, pDib.rows) & m_rect).clone();
}
void CImageApplyCustomCrop::apply(std::vector<cv::Mat> &mats, bool isTwoSide)
{
(void)isTwoSide;
int i = 0;
for (cv::Mat& var : mats) {
if (i != 0 && isTwoSide == false)
break;
if (!var.empty())
apply(var, 0);
i++;
}
}