mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-04-05 11:25:20 +08:00
65 lines
2.1 KiB
C#
65 lines
2.1 KiB
C#
using OpenCvSharp;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Vision.Recognition.Helper.OpenCv
|
|
{
|
|
/// <summary>
|
|
/// 图片剪裁
|
|
/// </summary>
|
|
public class CutHelper
|
|
{
|
|
public static Mat CutRightTop(Mat srcMat, int saveRightWidth, int saveTopHeight)
|
|
{
|
|
srcMat = new Mat(srcMat, new Rect(srcMat.Width - saveRightWidth, 0, saveRightWidth, saveTopHeight));
|
|
return srcMat;
|
|
}
|
|
|
|
public static Mat CutRightBottom(Mat srcMat, int saveRightWidth, int saveBottomHeight)
|
|
{
|
|
srcMat = new Mat(srcMat, new Rect(srcMat.Width - saveRightWidth, srcMat.Height - saveBottomHeight, saveRightWidth, saveBottomHeight));
|
|
return srcMat;
|
|
}
|
|
|
|
public static Mat CutLeftTop(Mat srcMat, int saveLeftWidth, int saveTopHeight)
|
|
{
|
|
srcMat = new Mat(srcMat, new Rect(0, 0, saveLeftWidth, saveTopHeight));
|
|
return srcMat;
|
|
}
|
|
|
|
public static Mat CutLeftBottom(Mat srcMat, int saveLeftWidth, int saveBottomHeight)
|
|
{
|
|
srcMat = new Mat(srcMat, new Rect(0, srcMat.Height - saveBottomHeight, saveLeftWidth, saveBottomHeight));
|
|
return srcMat;
|
|
}
|
|
|
|
public static Mat CutTop(Mat srcMat, int saveTopHeight)
|
|
{
|
|
srcMat = new Mat(srcMat, new Rect(0, 0, srcMat.Width, saveTopHeight));
|
|
return srcMat;
|
|
}
|
|
|
|
public static Mat CutBottom(Mat srcMat, int saveBottomHeight)
|
|
{
|
|
srcMat = new Mat(srcMat, new Rect(0, srcMat.Height- saveBottomHeight, srcMat.Width, saveBottomHeight));
|
|
return srcMat;
|
|
}
|
|
|
|
public static Mat CutRight(Mat srcMat, int saveRightWidth)
|
|
{
|
|
srcMat = new Mat(srcMat, new Rect(srcMat.Width - saveRightWidth, 0, saveRightWidth, srcMat.Height));
|
|
return srcMat;
|
|
}
|
|
|
|
public static Mat CutLeft(Mat srcMat, int saveLeftWidth)
|
|
{
|
|
srcMat = new Mat(srcMat, new Rect(0, 0, saveLeftWidth, srcMat.Height));
|
|
return srcMat;
|
|
}
|
|
|
|
}
|
|
}
|