0

I have a uchar vector that I need to copy to a byte array. Currently I am copying elemenet by element. Is there a more efficient way to do it using Copy::Marshal for example?

vector<uchar> buf1;//buffer for coding
array <Byte>^ hh1 = gcnew array<Byte> (img_sz1);
    for(int i=0; i <  buf1.size(); i++)
    {
    hh1[i] = buf1[i];
    }

This is the whole code

cv::Mat ovrImagePrevious=cv::imread('imagetest.jpg');
vector<uchar> buf1;//buffer for coding
vector<int> param = vector<int>(2);
param[0]=CV_IMWRITE_JPEG_QUALITY;
param[1]=100;//default(95) 0-100
int img_sz1=ovrImagePrevious.cols*ovrImagePrevious.rows;
array <Byte>^ hh1 = gcnew array<Byte> (img_sz1);

cv::imencode(".jpeg", ovrImagePrevious, buf1, param);
for(int i=0; i <  buf1.size(); i++)
    {
    hh1[i] = buf1[i];
    }
fmvpsenior
  • 197
  • 7
  • 22

0 Answers0