2021. 1. 18. 15:14
Computer Vision/OpenCVSharp
작성날짜 : 2021.01.18
운영체제 : Windows 10
VS Tool : VS2019
.NetFramework ver : 4.7.2
출처 : blog.naver.com/PostView.nhn?blogId=nuren1&logNo=220727174546&redirect=Dlog&widgetTypeCall=true
Mat -> System.Drawing.Bitmap
Mat mat = new Mat("foobar.jpg", ImreadModes.Color);
Bitmap bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat);
System.Drawing.Bitmap -> Mat
Bitmap bitmap = new Bitmap("foobar.jpg");
Mat mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
Mat -> byte[]
Mat mat = new Mat("foobar.jpg", ImreadModes.Color);
byte[] bytes1 = mat.ToBytes(".png");
byte[] bytes2; Cv2.ImEncode(".jpg", mat, out bytes2);
byte[] -> Mat
byte[] imageData = System.IO.File.ReadAllBytes("foobar.jpg");
Mat colorMat = Mat.FromImageData(imageData, ImreadModes.Color);
Mat grayscaleMat = Mat.FromImageData(imageData, ImreadModes.GrayScale);
Mat alt = Cv2.ImDecode(imageData, ImreadModes.GrayScale);
'Computer Vision > OpenCVSharp' 카테고리의 다른 글
DllNotFoundException:DLL'OpenCvSharpExtern' (0) | 2020.12.16 |
---|