C# 将MatOfByte转换为Base64字符串

C# 将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

我使用以下代码将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.Encoding.ASCII.GetBytes( vect.toArray().ToString())));

但是,通过1920x1080的图像大小,编码字符串太小。我做得对吗?

试着不要调用
字节[]
上的
字符串
您将
vect
转换为
byte[]
然后转换为字符串,因此
GetBytes
将字符串转换为类似“System.byte[]”的形式

string encodedByte = System.Convert.ToBase64String((System.Text.Encoding.ASCII.GetBytes( vect.toArray())));