| 12345678910111213141516171819202122232425262728293031 |
- using OpenCvSharp;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MvvmScaffoldFrame48.DLL.ImageAlgorithm
- {
- public static class OpenCvImageAlgorihm
- {
- /// <summary>
- /// 将Bitmap转换为Mat(输出为彩色图)
- /// 转换后的图像可以增加彩色框
- /// </summary>
- /// <param name="bitmap">源Bitmap</param>
- /// <returns>对应的Mat对象</returns>
- public static Mat BitmapToMat(Bitmap bitmap)
- {
- using (var ms = new MemoryStream())
- {
- bitmap.Save(ms, ImageFormat.Bmp);
- ms.Position = 0;
- return Mat.FromStream(ms, ImreadModes.Color);
- }
- }
- }
- }
|