一、QImage 的截取
QImage 可以直接使用copy库函数,也是传入坐标以及宽高
QImage ImageScale(QImage image,int x,int y,int width,int height)
{
QImage dst = image.copy(x,y,width,height);
}
二、Mat 的截取
Mat 的截取可以借助Rect 来完成
QImage ImageHandle::ImageScale(QImage image, int x, int y, int width, int height)
{
cv::Mat src = this->GetBRGMat(image);
//创建一个矩形区域
cv::Rect rect(x,y,width,height);
// 对传入Rect图片进行截取
cv::Mat dst = src(rect);
return this->Mat2QImage(dst);
}