看看周围
the documenation of OpenCV
,并且考虑到张量流张量总是行主张量,您应该能够执行如下操作:
const auto patch_side = 256;
int batch_id = 0;
for (auto i = 0; i < grid_shape.second; ++i) {
for (auto j = 0; j < grid_shape.first; ++j) {
auto size = patch_side * patch_side * depth;
cv::Mat p(patch_side, patch_side, CV_32FC(depth), patches.data() + batch_id * size);
cv::imshow("p", p);
cv::waitKey();
/*
ml(cv::Rect(i * patch_side, j * patch_side, patch_side,
patch_side)) =
cv::Mat(cv::Size(patch_side, patch_side), CV_32F, patches.slice
patches.data() + (i + j) * patch_side * patch_side);
*/
std::cout << "i,j" << i << "," << j << "\n";
batch_id++;
}
}
注意这是
不
复制张量数据,但创建
cv::Mat
这就是问题所在。