C# 将MatOfByte转换为Base64字符串
我使用以下代码将matofbyte转换为base64C# 将MatOfByte转换为Base64字符串,c#,opencv,unity3d,opencvsharp,C#,Opencv,Unity3d,Opencvsharp,我使用以下代码将matofbyte转换为base64 Mat img = Imgcodecs.imread(paths.GetValue(0).ToString()); MatOfByte vect = new MatOfByte(); Imgcodecs.imencode(".JPG", img,vect); string encodedByte = System.Convert.ToBase64String((System.Text.Encodi
Mat img = Imgcodecs.imread(paths.GetValue(0).ToString());
MatOfByte vect = new MatOfByte();
Imgcodecs.imencode(".JPG", img,vect);
string encodedByte = System.Convert.ToBase64String((System.Text.Encoding.ASCII.GetBytes( vect.toArray().ToString())));
但是,通过1920x1080的图像大小,编码字符串太小。我做得对吗?试着不要调用
字节[]
上的字符串
您将vect
转换为byte[]
然后转换为字符串,因此GetBytes
将字符串转换为类似“System.byte[]”的形式
string encodedByte = System.Convert.ToBase64String((System.Text.Encoding.ASCII.GetBytes( vect.toArray())));