我有一个需要复制到字节数组的uchar向量。目前我正按元素复制elemenet。有没有更有效的方法来使用Copy :: Marshal?
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];
}
这是整个代码
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];
}