OpenCVSharp⼩知识Mat的序列化和反序列化最近太忙,简单写写.
OpenCVSharp提供了Mat的序列化和反序列化⽅法-----FileStorage类,下⾯简单演⽰⽤法,
Mat src = new Mat(3, 3, MatType.CV_8UC1);
Cv2.Randu(src, Scalar.All(0d), Scalar.All(255d));
Console.WriteLine("序列化:" );
Console.WriteLine(Cv2.Format(src, FormatType.Python));
FileStorage storagewrite = new FileStorage("l", FileStorage.Mode.Write);
storagewrite.Write("src", src);
storagewrite.Release();writeline和write的区别python
Console.WriteLine("反序列化:");
FileStorage storageread = new FileStorage("l", FileStorage.Mode.Read);
Mat loadsrc = storageread["src"].ToMat();
Console.WriteLine(Cv2.Format(loadsrc, FormatType.Python));
Console.ReadKey();
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论