twain3.0/huagao/ImageProcess/ImageApplyCrop.cpp

40 lines
630 B
C++
Raw Normal View History

#include "ImageApplyCrop.h"
CImageApplyCrop::CImageApplyCrop(void)
{
}
CImageApplyCrop::~CImageApplyCrop(void)
{
}
void CImageApplyCrop::apply(cv::Mat& pDib,int side)
{
if (pDib.empty())
{
return;
}
if (m_roi.x < 0 || m_roi.y < 0 || m_roi.br().x >= pDib.cols || m_roi.br().y >= pDib.rows || m_roi.width == 0 || m_roi.height == 0)
{
return;
}
pDib = pDib(m_roi).clone();
}
void CImageApplyCrop::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
{
if (mats.empty()) return;
if (!mats[0].empty()) {
apply(mats[0], 0);
}
if (isTwoSide && mats.size() > 1) {
if (!mats[1].empty())
apply(mats[1], 1);
}
}