将一维数组转换为opencv的Mat格式
cv::Mat Array2Mat(uint8_t *a, int rows, int cols) {
cv::Mat M(rows, cols, CV_8UC1);
for (int i = 0; i < M.rows; ++i) {
uchar *p = M.ptr<uchar>(i);
for (int j = 0; j < M.cols; ++j)
p[j] = a[i*cols + j];
}
return M;
}
// 使用说明:
histBuff[0] = Array2Mat(historyImage, frame.rows, frame.cols);
histBuff[1] = Array2Mat(historyImage + frame.rows * frame.cols, frame.rows, frame.cols);